mirror of
https://github.com/danbulant/koa-plugins
synced 2026-06-18 13:51:08 +00:00
27 lines
No EOL
581 B
JavaScript
27 lines
No EOL
581 B
JavaScript
console.log("[INFO] Starting...");
|
|
|
|
const Koa = require("koa");
|
|
const app = new Koa;
|
|
const Hooks = require("./hooks");
|
|
const hooks = new Hooks;
|
|
const isElevated = require('is-elevated');
|
|
|
|
const PORT = 80;
|
|
|
|
hooks.registerPlugins(app);
|
|
|
|
app.use(async ctx => {
|
|
await hooks.runPlugins(ctx);
|
|
});
|
|
|
|
console.log("Plugins loaded, starting webserver");
|
|
|
|
(async()=>{
|
|
if(!await isElevated() && PORT < 1024){
|
|
console.error("Ports lower than 1024 requires elevated shell.");
|
|
process.exit(1);
|
|
}
|
|
app.listen(PORT, ()=>{
|
|
console.log("Web ready");
|
|
})
|
|
})(); |