Skip to content

Commit 8db8c06

Browse files
initial
0 parents  commit 8db8c06

File tree

7 files changed

+2785
-0
lines changed

7 files changed

+2785
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

app.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const express = require('express');
2+
const app = express();
3+
const routes = require('./routes');
4+
5+
app.use(express.json());
6+
app.use('/api', routes);
7+
8+
app.use((req, res, next) => {
9+
const err = new Error("Not Found");
10+
err.status = 404;
11+
next(err);
12+
});
13+
14+
app.use((err, req, res, next) => {
15+
res.status(err.status || 500);
16+
res.json({
17+
error: {
18+
message: err.message
19+
}
20+
});
21+
});
22+
23+
app.listen(3000, () => console.log('Quote API listening on port 3000!'));
24+

data.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"records": [
3+
{
4+
"id": 8721,
5+
"quote": "We must accept finite disappointment, but we must never lose infinite hope.",
6+
"author": "Martin Luther King, Jr."
7+
},
8+
{
9+
"id": 5779,
10+
"quote": "Use what you’ve been through as fuel, believe in yourself and be unstoppable!",
11+
"author": "Yvonne Pierre"
12+
},
13+
{
14+
"id": 3406,
15+
"quote": "To succeed, you have to do something and be very bad at it for a while. You have to look bad before you can look really good.",
16+
"author": "Barbara DeAngelis"
17+
}
18+
]
19+
}

0 commit comments

Comments
 (0)