-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.ts
37 lines (34 loc) · 1.48 KB
/
server.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
import express, { Express, Request, Response } from "express";
import route, { Res } from "./lib/route";
import { buildXml, parseXml, sleep } from "./lib/utils";
import { ParsedArgs } from "minimist";
import {
routeCancelControlNumber as routev4CancelControlNumber,
routeRequestControlNumber as routev4RequestControlNumber,
routeReuseControlNumber as routev4ReuseControlNumber,
} from "./v4/routes";
import { routev5Push, routev5Submission } from "./v5/routes";
export default function server(app$argv: ParsedArgs) {
console.log("Starting server....");
const app: Express = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.raw({ type: "application/*" }));
const url: string = process.env.URL_CONTROL_NUMBER_CALLBACK as string;
if (!url) console.log(`URL_CONTROL_NUMBER_CALLBACK not provided`);
if (app$argv.v) console.log(url);
app.use((req, res, next) => {
(req as any).app$argv = app$argv;
next();
})
app.post("/api/bill/sigqrequest", route(routev4RequestControlNumber));
app.post("/api/bill/sigqrequest_reuse", route(routev4ReuseControlNumber));
app.post("/api/bill/sigcancel_request", route(routev4CancelControlNumber));
app.post("/api/bill/20/submission", route(routev5Submission));
app.post("/api/bill/20/push", route(routev5Push));
if (app$argv.autopay) console.log("^ Auto Pay enabled");
const port = app$argv.port || 3005;
app.listen(port, () => {
console.log(`GePGfun App started :${port}`);
});
}