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