Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import { Elysia } from 'elysia'; import { swagger } from '@elysiajs/swagger'; import { logger } from '@rasla/logify'; import { registerCompanyRoutes } from './routes/companyRoutes'; const app = new Elysia({ prefix: '/api/company' }); app .use( swagger({ documentation: { info: { title: 'proyectoNIST company-service API', version: '1.0.0', }, }, }) ) .use(logger({ includeIp: true })) // Registrar rutas de empresas .use(registerCompanyRoutes) // Gestión de errores y lanzamiento del servidor .onError(({ code, set }) => { if (code === 'VALIDATION') { set.status = 400; // Definimos objetos vacíos con tipos específicos const errorMessages: Record<string, string> = {}; // Objeto que tendrá claves de tipo string y valores de tipo string const invalidValues: Record<string, any> = {}; // Objeto que tendrá claves de tipo string y valores de cualquier tipo return { success: false, message: 'Error de validación', details: errorMessages, invalidValues, }; } return { success: false, message: 'Error interno del servidor', }; }) .listen(Bun.env.SERVICE_PORT ?? 4002); console.log( `[COMPANY_SVC] ejecutándose en http://${app.server?.hostname}:${app.server?.port}` ); |