-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
42 lines (34 loc) · 1.01 KB
/
app.ts
File metadata and controls
42 lines (34 loc) · 1.01 KB
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
import dotenv from "dotenv";
dotenv.config();
import axios from "axios";
import bodyParser from "body-parser";
import express from "express";
import phalanx from "./phalanx";
import router from "./routes";
const app = express();
app.use(bodyParser.raw({ limit: "10kb" }));
app.use(bodyParser.json({ limit: "10kb" }));
const port = process.env.PORT || 8000;
const appId = process.env.APP_ID || "phalanx-test";
const serverId = process.env.SERVER_ID || "test-server-1";
// Config Phalanx Formation
const PHALANX_FORMATION_OPTIONS = { appId, serverId, app, axios };
phalanx.formation(PHALANX_FORMATION_OPTIONS);
// Config Routes
app.get("/", (_, res) => {
res.send("This is THE Phalanx Test Server");
});
// Setup Demo Routes
app.use("/api/v1", router);
// Config Phalanx
const PHALANX_DEPLOY_OPTIONS = {
app,
appId,
serverId,
baseUrl: "http://localhost:8001",
};
phalanx.deploy(PHALANX_DEPLOY_OPTIONS);
// Start Server
app.listen(port, () => {
console.log(`Server is running on port ${port} on Time: ${new Date()}`);
});