34 lines
953 B
JavaScript
34 lines
953 B
JavaScript
const express = require("express");
|
|
const { NetHelperModule } = global.moduleApi;
|
|
|
|
const HTTPReverse = require("../components/http-reverse");
|
|
|
|
module.exports = class CustomAuthPage extends NetHelperModule {
|
|
constructor () {
|
|
super();
|
|
this.router = express.Router();
|
|
|
|
this.certbot = new this.statics.Operator("certbot", (argv) => {
|
|
return argv.length === 2;
|
|
}, (argv, self, syntaxTree) => {
|
|
if (![HTTPReverse].includes(syntaxTree.Type)) {
|
|
throw new SyntaxError("Unsupported type of server");
|
|
}
|
|
const [ pathToFile, secretKey ] = argv;
|
|
const router = this.router;
|
|
|
|
router.get(pathToFile, (req, res, next) => {
|
|
res.send(secretKey);
|
|
});
|
|
});
|
|
|
|
this.operators.push(this.certbot);
|
|
}
|
|
|
|
bind (type) {
|
|
super.bind(type);
|
|
this.serverType.routelist.push(this.router);
|
|
}
|
|
};
|
|
|