Files
freeCodeCamp/api/db/index.ts
Oliver Eyton-Williams 5f59b2b8c7 feat(api): validate environment variables before use (#49613)
* feat(api): validate environment variables before use

This is similar in concept to ensure-env, but a little simpler since
there is no need to put the data in a file before the api can consume
it.

* refactor: combine the two env files
2023-03-07 10:03:46 -08:00

15 lines
396 B
TypeScript

import fastifyPlugin from 'fastify-plugin';
import fastifyMongo from '@fastify/mongodb';
import { FastifyInstance } from 'fastify';
import { MONGOHQ_URL } from '../utils/env';
async function connect(fastify: FastifyInstance) {
fastify.log.info(`Connecting to Mongodb`);
await fastify.register(fastifyMongo, {
url: MONGOHQ_URL
});
}
export const dbConnector = fastifyPlugin(connect);