-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathashe.ts
34 lines (31 loc) · 969 Bytes
/
ashe.ts
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
import express, { type Application, type RequestHandler } from 'express'
import cors from 'cors'
import Route from './Route'
import { api_port } from './config'
import { cyan } from 'colors'
import Database from './Database';
import Middleware from './Middleware'
export default class Ashe
{
private static app: Application;
public static api()
{
Ashe.app = express()
Ashe.useMiddleware(cors())
Ashe.useMiddleware(Middleware.auth)
Ashe.useMiddleware(express.json())
Database.getTables().then(tables => {
tables.forEach((table: string) => {
Ashe.useMiddleware(new Route(table).router)
console.log(cyan(`> ${table} route ready !`))
});
console.log(cyan(`\n> All routes ready !`))
})
Ashe.app.listen(api_port)
}
public static useMiddleware(middleware: RequestHandler)
{
Ashe.app.use(middleware)
}
}
Ashe.api()