mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-30 15:04:00 -05:00
* 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
15 lines
396 B
TypeScript
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);
|