Last active
January 4, 2019 14:18
-
-
Save LazyFatArrow/940b1895442e355c8ef41cd6c9b7a8bb to your computer and use it in GitHub Desktop.
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
import * as express from 'express' | |
import * as bodyParser from 'body-parser' | |
import MoviesApi from './api/MoviesApi' | |
const app = express() | |
const moviesApi = new MoviesApi() | |
app.use(bodyParser.json()) | |
app.post('/movies', (req: express.Request, res: express.Response) => { | |
res.json(moviesApi.create(req.body)) | |
}) | |
app.get('/movies', (req: express.Request, res: express.Response) => { | |
res.json(moviesApi.findMany()) | |
}) | |
app.listen(5000, () => { | |
console.log('server started on port 5000') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment