Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Route{
- constructor(locals){
- this.sql = locals.sql;
- this.logger = locals.logger;
- this.token = locals.config.token;
- }
- _checkAuth(){
- let clientToken = this.req.headers['authorization'].replace('Bearer', '');
- if (this.token === clientToken){
- return true;
- }
- return false;
- }
- send(status = 200, data = {}){
- this.res.status(status).send(data);
- }
- exec(){}
- run(req, res){
- this.req = req;
- this.res = res;
- if(this._checkAuth){
- this.exec()
- }else{
- this.send(400);
- }
- }
- }
- module.exports = Route;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement