mirror of
https://github.com/danbulant/koa-plugins
synced 2026-05-19 04:08:43 +00:00
35 lines
No EOL
774 B
JavaScript
35 lines
No EOL
774 B
JavaScript
const PORT = 80;
|
|
|
|
module.exports = (PORT)=>{
|
|
|
|
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');
|
|
|
|
|
|
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");
|
|
})
|
|
})();
|
|
}
|
|
|
|
if(require.main === module){
|
|
module.exports(PORT);
|
|
} |