/[sudobot]/branches/2.x/src/api/PublicRouter.ts
ViewVC logotype

Annotation of /branches/2.x/src/api/PublicRouter.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 912 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 import express, { NextFunction, Request, RequestHandler, Response, Router } from "express";
2     import { lstatSync, readdir } from "fs";
3     import path from "path";
4     import DiscordClient from "../client/Client";
5     import auth from "./Auth";
6     import { loadRoutes } from "./Router";
7     import apiRoute from "./routes";
8    
9     const router = Router();
10    
11     router.use(express.json());
12     router.use(express.urlencoded({
13     extended: false
14     }));
15    
16     router.use((req: Request, res: Response, next: NextFunction) => {
17     res.setHeader('Access-Control-Allow-Origin', DiscordClient.client.config.props.global.cp_host);
18     res.setHeader('Access-Control-Allow-Methods', '*');
19     res.setHeader('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers, Access-Control-Allow-Origin, Access-Control-Allow-Methods, Content-Type, Content-Length');
20     next();
21     });
22    
23     loadRoutes(path.resolve(__dirname, 'public-routes'), router);
24    
25     export default router;

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26