Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

Stephan Raab: backend submission #2

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Create an API written in Node.js that passes as many of the tests in `test/crud.spec.js` as you can.

Data **DOES NOT** need to persist between server restarts, unless you already have extensive Node.js experience and want to show us your chops.
In that case, we recommend using a lightweight document store like like [LokiJS](https://rawgit.com/techfort/LokiJS/master/jsdoc/tutorial-Persistence%20Adapters.html)
In that case, we recommend using a lightweight document store like [LokiJS](https://rawgit.com/techfort/LokiJS/master/jsdoc/tutorial-Persistence%20Adapters.html)
or [lowdb](https://github.com/typicode/lowdb), but feel free to use anything so long as it can be installed with `npm install`.

### Requirements
Expand Down
23 changes: 9 additions & 14 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
const http = require('http')
const port = 8080
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const catsRouter = require('./routes/cats')

const requestHandler = (request, response) => {
response.end("You might want some more request handlers")
}
app.use(bodyParser.json())
app.use(catsRouter)
app.use(express.static('public'))

const server = http.createServer(requestHandler)

server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}

console.log(`server is listening on port ${port}`)
})
const port = process.env.port || 8080
app.listen(port, () => console.info(`Server running on localhost:${port}`))
Loading