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; |