mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-07 09:01:13 -05:00
* refactor: use await/done to mollify eslint * refactor: clean up unused code It's also more of an express pattern. Fastify routes should be registered as plugins.
15 lines
426 B
TypeScript
15 lines
426 B
TypeScript
import fastifyPlugin from 'fastify-plugin';
|
|
import fastifyMongo from '@fastify/mongodb';
|
|
import { FastifyInstance } from 'fastify';
|
|
|
|
const URI = process.env.MONGOHQ_URL || 'mongodb://localhost:27017/freecodecamp';
|
|
|
|
async function connect(fastify: FastifyInstance) {
|
|
fastify.log.info(`Connecting to : ${URI}`);
|
|
await fastify.register(fastifyMongo, {
|
|
url: URI
|
|
});
|
|
}
|
|
|
|
export const dbConnector = fastifyPlugin(connect);
|