@practica/create-node-app
Version:
Create Node.js app that is packed with best practices AND strive for simplicity
22 lines (16 loc) • 527 B
text/typescript
import fastify from 'fastify';
import { Server } from 'http';
import { JWTVerifier } from '../jwt-verifier-plugin';
let httpServer: Server;
export const startTestServer = async (JWTSecret: string) => {
const app = fastify({ logger: true });
app.register(JWTVerifier, { secret: JWTSecret });
app.get('/', async () => ({ message: 'Hello, world!' }));
await app.listen({ port: 3000 });
httpServer = app.server;
};
export const stopTestServer = async () => {
if (httpServer) {
await httpServer.close();
}
};