TypeScript-Node-Starter
TypeScript-Node-Starter copied to clipboard
RepositoryNotFoundError w/ Express
I have a modified version of the express example that uses the latest version. When referencing the entity class
photos = await getEntityManager().getRepository(Photo).find()
I receive an error, however when using the entity string "Photo"
photos = await getEntityManager().getRepository("Photo").find()
everything works fine. This only occurs inside of the controller class. If I move the same code into the createConnection
callback, everything works fine:
createConnection({
...configuration
})
.then(connection => {
const repo = getEntityManager().getRepository(Photo).find().then(console.log)
// const app = express()
// app.use(bodyParser.json())
// routes.forEach(route => {
// app[route.method](route.path, (request: Request, response: Response, next: Function) => {
// route.action(request, response).then(() => next).catch(err => next(err))
// })
// })
// app.listen(3000)
})