All files / app/api index.ts

100% Statements 32/32
100% Branches 2/2
100% Functions 0/0
100% Lines 32/32

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 331x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 12x 12x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { Router, Request, Response, NextFunction } from 'express';
import inputRouter from './input/index.js';
import outputRouter from './output/index.js';
import { Logger } from '../utils/logger.js';
import { rateLimiter } from './middlewares/rateLimiter.js';
import { slowDownLimiter } from './middlewares/slowDownLimiter.js';
import { errorHandler } from './middlewares/errorHandler.js';
import { notFoundHandler } from './middlewares/notFoundHandler.js';
 
const router = Router();
 
router.use((req: Request, res: Response, next: NextFunction) => {
  Logger.log(`request: ${req.method} ${req.originalUrl}`);
  return next();
});
 
router.get('/health', (req: Request, res: Response) => {
  res.status(200).json({ message: 'OK', time: new Date().toISOString() });
});
 
router.use(slowDownLimiter);
router.use(rateLimiter);
 
router.use('/input', inputRouter);
 
router.use('/output', outputRouter);
 
router.use(notFoundHandler);
 
router.use(errorHandler);
 
export default router;