-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.ts
50 lines (46 loc) · 1.12 KB
/
routes.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import homeController from '@/controllers/home'
import GenerateImageController from '@/controllers/generate-image'
import GeneratePdfController from '@/controllers/generate-pdf'
import GenerateSimplePdfController from '@/controllers/generate-simple-pdf'
import GenerateCombinePdfController from '@/controllers/generate-combine-pdf'
import type Router from 'koa-router'
type HttpMethodKeys = Extract<keyof Router,
| 'get'
| 'post'
| 'put'
| 'delete'
>
interface RouteConfig {
path: string
// method: string | 'get' | 'post' | 'delete' | 'put'
method: HttpMethodKeys
action: Router.IMiddleware<any, any>
}
const routes: Array<RouteConfig> = [
{
path: '/',
method: 'get',
action: homeController.hello
},
{
path: '/image',
method: 'get',
action: GenerateImageController.generate
},
{
path: '/pdf',
method: 'post',
action: GeneratePdfController.generate
},
{
path: '/simple-pdf',
method: 'get',
action: GenerateSimplePdfController.generate
},
{
path: '/combine-pdf',
method: 'post',
action: GenerateCombinePdfController.generate
}
]
export default routes