Skip to content

Instantly share code, notes, and snippets.

@jalasem
Created July 22, 2019 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jalasem/17cd0b618d62e681ff4a38517ea55079 to your computer and use it in GitHub Desktop.
Save jalasem/17cd0b618d62e681ff4a38517ea55079 to your computer and use it in GitHub Desktop.
class based express server
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