Created
March 11, 2019 16:19
-
-
Save tkssharma/4e3cf9a3a057f4f32c713581b403c977 to your computer and use it in GitHub Desktop.
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
import * as express from "express"; | |
import * as bodyParser from "body-parser"; | |
import { Request, Response } from "express"; | |
class App { | |
constructor() { | |
this.app = express(); | |
this.config(); | |
this.routes(); | |
} | |
public app: express.Application; | |
private config(): void { | |
this.app.use(bodyParser.json()); | |
this.app.use(bodyParser.urlencoded({ extended: false })); | |
} | |
private routes(): void { | |
const router = express.Router(); | |
router.get('/', (req: Request, res: Response) => { | |
res.status(200).send({ | |
message: 'Hello World!' | |
}) | |
}); | |
this.app.use('/', router) | |
} | |
} | |
export default new App().app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment