Created
July 22, 2019 10:07
-
-
Save jalasem/17cd0b618d62e681ff4a38517ea55079 to your computer and use it in GitHub Desktop.
class based express server
This file contains 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 path = require('path') | |
const open = require('open') | |
class Server { | |
constructor(port, app) { | |
this.port = port | |
this.app = app | |
} | |
core() { | |
this.app.get('/', (req, res)=> res.send('working...') | |
this.app.listen(this.port, () => { open(`http://localhost:${this.port}`) }) | |
} | |
} | |
let server = new Server(3000, express()) | |
server.core() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment