-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (56 loc) · 1.58 KB
/
index.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
const path = require("path");
const express = require("express");
const cors = require("cors");
const morgan = require("morgan");
const { init: initDB, Counter } = require("./db");
const logger = morgan("tiny");
const app = express();
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(cors());
app.use(logger);
// 首页
app.get("/", async (req, res) => {
res.sendFile(path.join(__dirname, "index.html"));
});
// 小程序调用,获取微信 Open ID
app.get("/api/wx_openid", async (req, res) => {
if (req.headers["x-wx-source"]) {
res.send(req.headers["x-wx-openid"]);
}
});
const port = process.env.PORT || 80;
async function bootstrap() {
await initDB();
app.listen(port, () => {
console.log("启动成功", port);
});
}
bootstrap();
System.register(["./application.js"], function (_export, _context) {
"use strict";
var Application, canvas, $p, bcr, application;
function topLevelImport(url) {
return System["import"](url);
}
return {
setters: [function (_applicationJs) {
Application = _applicationJs.Application;
}],
execute: function () {
canvas = document.getElementById('GameCanvas');
$p = canvas.parentElement;
bcr = $p.getBoundingClientRect();
canvas.width = bcr.width;
canvas.height = bcr.height;
application = new Application();
topLevelImport('cc').then(function (engine) {
return application.init(engine);
}).then(function () {
return application.start();
})["catch"](function (err) {
console.error(err);
});
}
};
});