|
1 | | -import Fastify from 'fastify'; |
| 1 | +import path from 'node:path'; |
| 2 | +import { fileURLToPath } from 'node:url'; |
| 3 | + |
| 4 | +import cookie from '@fastify/cookie'; |
2 | 5 | import cors from '@fastify/cors'; |
3 | 6 | import helmet from '@fastify/helmet'; |
4 | 7 | import jwt from '@fastify/jwt'; |
5 | | -import cookie from '@fastify/cookie'; |
6 | 8 | import multipart from '@fastify/multipart'; |
7 | | -import fastifyStatic from '@fastify/static'; |
8 | 9 | import rateLimit from '@fastify/rate-limit'; |
9 | | -import path from 'path'; |
10 | | -import { fileURLToPath } from 'url'; |
| 10 | +import fastifyStatic from '@fastify/static'; |
| 11 | +import Fastify, {type FastifyInstance} from 'fastify'; |
11 | 12 |
|
12 | 13 | import { prismaPlugin } from './plugins/prisma.js'; |
13 | 14 | import { redisPlugin } from './plugins/redis.js'; |
| 15 | +import { analyticsRoutes } from './routes/analytics.js'; |
14 | 16 | import { authRoutes } from './routes/auth.js'; |
15 | | -import { profileRoutes } from './routes/profiles.js'; |
16 | 17 | import { cardRoutes } from './routes/cards.js'; |
17 | | -import { publicRoutes } from './routes/public.js'; |
18 | | -import { followRoutes } from './routes/follow.js'; |
19 | 18 | import { connectRoutes } from './routes/connect.js'; |
20 | | -import { analyticsRoutes } from './routes/analytics.js'; |
21 | | -import { nfcRoutes } from './routes/nfc.js'; |
22 | 19 | import { eventRoutes } from './routes/event.js'; |
| 20 | +import { followRoutes } from './routes/follow.js'; |
| 21 | +import { nfcRoutes } from './routes/nfc.js'; |
| 22 | +import { profileRoutes } from './routes/profiles.js'; |
| 23 | +import { publicRoutes } from './routes/public.js'; |
23 | 24 | import { validateEnv } from './utils/validateEnv.js'; |
24 | 25 |
|
25 | 26 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
26 | 27 |
|
27 | | -export async function buildApp() { |
| 28 | +export async function buildApp():Promise<FastifyInstance> { |
28 | 29 | // Validate all required secrets before registering any plugin. |
29 | 30 | // If validation fails the process exits here — no partially-initialised |
30 | 31 | // auth state can exist because Fastify is not yet instantiated. |
@@ -93,7 +94,7 @@ export async function buildApp() { |
93 | 94 | app.decorate('authenticate', async function (request: any, reply: any) { |
94 | 95 | try { |
95 | 96 | await request.jwtVerify(); |
96 | | - } catch (err) { |
| 97 | + } catch (_err) { |
97 | 98 | reply.status(401).send({ error: 'Unauthorized' }); |
98 | 99 | } |
99 | 100 | }); |
|
0 commit comments