-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
68 lines (59 loc) · 1.69 KB
/
app.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
// const express = require("express");
const Koa = require("koa");
const bodyParser = require("koa-bodyparser");
const morgan = require("morgan");
const nugu = require("./nugu");
const { SERVER_PORT } = require("./config.js");
// const routes = require("./routes");
const Router = require("koa-router");
// const app = express();
const app = new Koa();
// let router = express.Router();
let router = new Router();
// app.use(bodyParser.json());
// app.use(morgan("common"));
// app.use((err, req, res, next) => next());
let users = {};
app.use(bodyParser());
// router.route("/GameStartAction").post((req, res, next) => {
// console.log("GameStartAction");
// nugu(req, res, next, users);
// });
router.post("/GameStartAction", (ctx, next) => {
console.log("GameStartAction");
console.log(JSON.stringify(ctx.request.body));
nugu(ctx, users);
});
router.post("/ResultAction", (ctx, next) => {
console.log("ResultAction");
nugu(ctx, users);
});
router.post("/WinGameAction", (ctx, next) => {
console.log("WinGameAction");
nugu(ctx, users);
});
router.post("/ResultAction2", (ctx, next) => {
console.log("ResultAction2");
nugu(ctx, users);
});
router.post("/addAction", (ctx, next) => {
console.log("addAction");
nugu(ctx, users);
});
router.post("/CheckAction", (ctx, next) => {
console.log("CheckAction");
nugu(ctx, users);
});
router.post("/WinGameAction2", (ctx, next) => {
console.log("WinGameAction2");
nugu(ctx, users);
});
router.get("/health", (ctx, next) => {
ctx.body = "OK";
ctx.status = 200;
});
// app.use("/", router);
app.use(router.routes()).use(router.allowedMethods());
app.listen(SERVER_PORT, () => {
console.log(`Server is running on ${SERVER_PORT} port`);
});