> npm install
> npm start
app.use(async (ctx, next) => {
...
await next()
...
})
const convert = require('koa-convert')
const _use = app.use
app.use = x => _use.call(app, convert(x))
const views = require('koa-views')
app.use(views(path.resolve(__dirname, './views'), {
extension: 'ejs'
}))
const server = require('koa-static')
app.use(server(path.resolve(__dirname, './static')))
ssl证书免费申请:(腾讯云)https://console.qcloud.com/ssl
let options = {
key: fs.readFileSync(__dirname+'/ssl/server.key'),
cert: fs.readFileSync(__dirname+'/ssl/server.crt')
};
https.createServer(options, app.callback()).listen(443,()=>{
console.log("https://127.0.0.1:443 is runing");
opener("https://127.0.0.1:443");
});