fastify-typeorm
Fastify plugin to work with TypeORM
install
npm install fastify-typeorm
Usage
const fastify = require('fastify')();
const ftypeorm = require('fastify-typeorm');
const typeormConfig = {
instance: 'db',
typeormConfig
};
fastify.register(ftypeorm, typeormConfig).ready();
fastify.get('/',async function(req, res) =>{
const repo = fastify.db.getRepository(Model)
return repo.find()
})
fastify.listen(3000, () => {
console.log('> listening on port 3000');
});
instance: (optional) the name of instance will be mapped to fastify, default is db
typeormConfig: all typeorm configurations, you can see here.