-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
74 lines (52 loc) · 1.71 KB
/
index.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import config from './config.json'
import HttpServer from './src/base/HttpServer'
import bodyParser from 'body-parser'
import cors from 'cors'
// v2 paths
import GetVideoById from './src/routes/video/GetVideoById'
import AddVideo from './src/routes/video/AddVideo'
import GetVideos from './src/routes/video/GetVideos'
import UpdateVideo from './src/routes/video/UpdateVideo'
import DeleteVideo from './src/routes/video/DeleteVideo'
import ReplaceVideo from './src/routes/video/ReplaceVideo'
import SearchVideo from './src/routes/video/SearchVideo'
// user-related routes
import CreateUser from './src/routes/user/CreateUser'
import LoginUser from './src/routes/user/LoginUser'
import GetLibrary from './src/routes/user/GetLibrary'
import CreateOrder from './src/routes/orders/CreateOrder'
import CaptureOrder from './src/routes/orders/CaptureOrder'
import GetPlans from './src/routes/plans/GetPlans'
import GetUser from './src/routes/user/GetUser'
const main = async () => {
const http = new HttpServer(config)
// set restana middlewares
http.restana.use(
bodyParser.json()
)
http.restana.use(
cors()
)
// v2 paths
await http.register(GetVideoById)
await http.register(AddVideo)
await http.register(GetVideos)
await http.register(UpdateVideo)
await http.register(DeleteVideo)
await http.register(ReplaceVideo)
await http.register(SearchVideo)
await http.register(CreateUser)
await http.register(LoginUser)
await http.register(GetLibrary)
await http.register(CreateOrder)
await http.register(CaptureOrder)
await http.register(GetPlans)
await http.register(GetUser)
try {
await http.ready()
await http.log('Backend ready')
} catch(err) {
console.error(err)
}
}
main()