mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor: clean up errors + unused code (#49473)
* 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.
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
8812d4557a
commit
1c9004046b
+2
-2
@@ -3,10 +3,10 @@ import fastifyMongo from '@fastify/mongodb';
|
||||
import { FastifyInstance } from 'fastify';
|
||||
|
||||
const URI = process.env.MONGOHQ_URL || 'mongodb://localhost:27017/freecodecamp';
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
|
||||
async function connect(fastify: FastifyInstance) {
|
||||
fastify.log.info(`Connecting to : ${URI}`);
|
||||
void fastify.register(fastifyMongo, {
|
||||
await fastify.register(fastifyMongo, {
|
||||
url: URI
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { FastifyInstance } from 'fastify';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
export async function auth0Routes(fastify: FastifyInstance) {
|
||||
fastify.get('/oauth/token', async (_request, _reply) => {
|
||||
return { a: 'b' };
|
||||
});
|
||||
}
|
||||
+5
-5
@@ -1,8 +1,7 @@
|
||||
import { FastifyInstance } from 'fastify';
|
||||
import { FastifyPluginCallback } from 'fastify';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
export async function testRoutes(fastify: FastifyInstance) {
|
||||
const collection = fastify?.mongo?.db?.collection('user');
|
||||
export const testRoutes: FastifyPluginCallback = (fastify, _options, done) => {
|
||||
const collection = fastify.mongo.db?.collection('user');
|
||||
|
||||
fastify.get('/test', async (_request, _reply) => {
|
||||
if (!collection) {
|
||||
@@ -11,4 +10,5 @@ export async function testRoutes(fastify: FastifyInstance) {
|
||||
const user = await collection?.findOne({ email: 'bar@bar.com' });
|
||||
return { user };
|
||||
});
|
||||
}
|
||||
done();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user