-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
25 lines (21 loc) · 815 Bytes
/
Copy pathserver.ts
File metadata and controls
25 lines (21 loc) · 815 Bytes
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
import Koa, { Middleware } from 'koa';
import favicon from 'koa-favicon';
import views from 'koa-views';
import serve from 'koa-static';
import Router from '@koa/router';
import path from 'path';
import { path as appPath } from 'app-root-path';
const app = new Koa();
const router = new Router();
const port = process.env.PORT || 3000;
router.get('/', async function (ctx) {
await ctx.render('index');
});
app.use(views(path.join(appPath, '/dist/views'), { extension: 'html' }))
.use(favicon(path.join(appPath, '/dist/web/favicon.ico')) as Middleware)
.use(serve(path.join(appPath, '/dist/')) as Middleware)
.use(router.routes() as Middleware)
.use(router.allowedMethods() as Middleware)
.listen(port, () => {
console.log(`Game application is running on port ${port}.`);
});