Skip to content

Commit

Permalink
feat: Bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed Jun 20, 2024
1 parent 280accc commit 470e4ed
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@

import fs from 'fs';
import Koa from 'koa';
import dayjs from 'dayjs';
import files from 'koa-files';
import compress from 'koa-compress';

const port = 8000;
const app = new Koa();
const port = parseInt(process.env.PORT) || 8080;

app.proxy = true;

app.use(compress());

app.use(files('wwwroot'));

app.use(async ctx => {
ctx.type = 'text/html; charset=utf-8';
ctx.body = fs.createReadStream('wwwroot/app.html');
});

app.on('error', error => {
!httpError(error) && console.error(error);
app.use(async context => {
context.type = 'text/html; charset=utf-8';
context.body = fs.createReadStream('wwwroot/app.html');
});

app.listen(port, () => {
console.log(`server run at: \u001B[36mhttp://127.0.0.1:${port}\u001B[0m`);
const host = `http://127.0.0.1:${port}`;
const now = dayjs().format('YYYY-MM-DD hh:mm:ss');

console.log(`[${now}] server run at: \u001B[36m${host}\u001B[0m`);
});

0 comments on commit 470e4ed

Please sign in to comment.