-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.js
144 lines (100 loc) · 3.87 KB
/
server.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import * as Environment from "~/node_common/environment";
import * as ScriptLogging from "~/node_common/script-logging";
import APIRouteIndex from "~/pages";
import APIRouteUpload from "~/pages/upload";
import APIRouteUploadExternalV1 from "~/pages/v1/external-upload";
import APIRouteSlateUploadExternalV1 from "~/pages/v1/external-slate-upload";
import APIRouteUploadExternalV2 from "~/pages/v2/external-upload";
import APIRouteSlateUploadExternalV2 from "~/pages/v2/external-slate-upload";
import APIRouteUploadExternalV3 from "~/pages/v3/external-upload";
import APIRouteSlateUploadExternalV3 from "~/pages/v3/external-slate-upload";
import APIRouteUploadZip from "~/pages/upload-zip";
import APICreateZipToken from "~/pages/create-zip-token";
import APIDownloadByToken from "~/pages/download-by-token";
import APIRouteUploadUrl from "~/pages/upload-by-url";
import APIRouteUploadCidExternalV2 from "~/pages/v2/external-upload-by-cid";
import APIRouteUploadUrlExternalV2 from "~/pages/v2/external-upload-by-url";
import APIRouteUploadCidExternalV3 from "~/pages/v3/external-upload-by-cid";
import APIRouteUploadUrlExternalV3 from "~/pages/v3/external-upload-by-url";
import express from "express";
import cors from "cors";
import bodyParser from "body-parser";
const server = express();
const SHOVEL = "SERVER START ";
server.use(cors());
server.use(bodyParser.json());
server.get("/favicon.ico", (req, res) => res.status(204));
server.get("/", async (req, res) => {
return await APIRouteIndex(req, res);
});
server.post("/api/public", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadExternalV1(req, res);
});
server.post("/api/public/:slate", async (req, res) => {
req.setTimeout(0);
return await APIRouteSlateUploadExternalV1(req, res);
});
/* v2 endpoints */
server.post("/api/v2/public", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadExternalV2(req, res);
});
server.post("/api/v2/public/upload-by-cid", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadCidExternalV2(req, res);
});
server.post("/api/v2/public/upload-by-url", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadUrlExternalV2(req, res);
});
server.post("/api/v2/public/:slate", async (req, res) => {
req.setTimeout(0);
return await APIRouteSlateUploadExternalV2(req, res);
});
/* v3 endpoints */
server.post("/api/v3/public", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadExternalV3(req, res);
});
server.post("/api/v3/public/upload-by-cid", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadCidExternalV3(req, res);
});
server.post("/api/v3/public/upload-by-url", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadUrlExternalV3(req, res);
});
server.post("/api/v3/public/:slate", async (req, res) => {
req.setTimeout(0);
return await APIRouteSlateUploadExternalV3(req, res);
});
server.post("/api/data/url", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadUrl(req, res);
});
server.post("/api/data/:upload", async (req, res) => {
req.setTimeout(0);
return await APIRouteUpload(req, res);
});
server.post("/api/data/zip/:upload", async (req, res) => {
req.setTimeout(0);
return await APIRouteUploadZip(req, res);
});
server.post("/api/deal/:upload", async (req, res) => {
req.setTimeout(0);
return await APIRouteUpload(req, res, { bucketName: "stage-deal" });
});
server.post("/api/download/create-zip-token", async (req, res) => {
req.setTimeout(0);
return await APICreateZipToken(req, res);
});
server.get("/api/download/download-by-token", async (req, res) => {
req.setTimeout(0);
return await APIDownloadByToken(req, res);
});
const listenServer = server.listen(Environment.PORT, (e) => {
if (e) throw e;
ScriptLogging.log(SHOVEL, `http://localhost:${Environment.PORT}`);
});
listenServer.headersTimeout = 0;