Skip to content

Instantly share code, notes, and snippets.

@LazyFatArrow
Last active January 4, 2019 14:18
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 LazyFatArrow/940b1895442e355c8ef41cd6c9b7a8bb to your computer and use it in GitHub Desktop.
Save LazyFatArrow/940b1895442e355c8ef41cd6c9b7a8bb to your computer and use it in GitHub Desktop.
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