Created
September 5, 2020 05:58
-
-
Save julioflima/aea3c814509fa45f795605ec5553a910 to your computer and use it in GitHub Desktop.
App in class to facilitate reuse.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const cors = require('cors'); | |
const { errors } = require('celebrate'); | |
module.exports = class App { | |
constructor(routes) { | |
this.routes = routes; | |
this.server = express(); | |
this.middleware(); | |
this.router(); | |
} | |
middleware() { | |
this.server.use( | |
cors() | |
// origin: '' | |
); | |
this.server.use(express.json()); | |
this.server.use(errors()); | |
} | |
router() { | |
this.server.use(this.routes); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment