sdk api add debug logging
This commit is contained in:
@@ -2,6 +2,7 @@ import cors from '@fastify/cors';
|
||||
import Fastify from 'fastify';
|
||||
import { FastifySSEPlugin } from 'fastify-sse-v2';
|
||||
import pino from 'pino';
|
||||
import { getClientIp } from 'request-ip';
|
||||
|
||||
import { redisPub } from '@mixan/redis';
|
||||
|
||||
@@ -20,13 +21,24 @@ const port = parseInt(process.env.API_PORT || '3000', 10);
|
||||
const startServer = async () => {
|
||||
try {
|
||||
const fastify = Fastify({
|
||||
logger: pino({ level: 'info' }),
|
||||
logger: pino({
|
||||
level: 'info',
|
||||
}),
|
||||
});
|
||||
|
||||
fastify.register(cors, {
|
||||
origin: '*',
|
||||
});
|
||||
|
||||
fastify.addHook('preHandler', (req, reply, done) => {
|
||||
const ip = getClientIp(req)!;
|
||||
console.log('---------------');
|
||||
console.log('ip', ip);
|
||||
console.log('heacders', req.headers);
|
||||
console.log('---------------');
|
||||
done();
|
||||
});
|
||||
|
||||
fastify.register(FastifySSEPlugin);
|
||||
fastify.decorateRequest('projectId', '');
|
||||
fastify.register(eventRouter, { prefix: '/event' });
|
||||
|
||||
Reference in New Issue
Block a user