Skip to content

Instantly share code, notes, and snippets.

@tkssharma
Created March 11, 2019 16:19
Show Gist options
  • Save tkssharma/4e3cf9a3a057f4f32c713581b403c977 to your computer and use it in GitHub Desktop.
Save tkssharma/4e3cf9a3a057f4f32c713581b403c977 to your computer and use it in GitHub Desktop.
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