forked from ARIAv2/ARIABackend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
34 lines (30 loc) · 856 Bytes
/
app.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 bodyParser from "body-parser";
import cors from "cors";
import express, { Express } from "express";
import {
replyToFrontendGET,
replyToFrontendPOST,
} from "./controllers/dataresponse.js";
function setupMiddleware(app: Express): void {
app.use(cors({ origin: "http://aria-delta.vercel.app" }));
app.use(bodyParser.text({ type: "text/plain" }));
}
function setupRoutes(app: Express): void {
app.get(
"/",
replyToFrontendGET("text", "You requested data? Here it is: Hello!")
);
app.post("/", replyToFrontendPOST("text"));
}
function start(): void {
const app: Express = express();
const port: string | number = process.env.PORT || 3001;
setupMiddleware(app);
setupRoutes(app);
app.listen(port, () =>
console.log(
`SERVER STARTED ON https://ariabackend.onrender.com at port ${port}`
)
);
}
start();