-
Notifications
You must be signed in to change notification settings - Fork 6
/
server.js
executable file
·34 lines (31 loc) · 899 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import express from "express";
import bodyParser from "body-parser";
import faker from "faker";
import times from "lodash.times";
import random from "lodash.random";
import db from "./models";
import apiPost from "./app/api/post";
import apiAuthor from "./app/api/author";
const app = express();
app.use(bodyParser.json());
app.use(express.static("app/public"));
apiPost(app, db);
apiAuthor(app, db);
db.sequelize.sync().then(() => {
// populate author table with dummy data
db.author.bulkCreate(
times(10, () => ({
firstName: faker.name.firstName(),
lastName: faker.name.lastName()
}))
);
// populate post table with dummy data
db.post.bulkCreate(
times(10, () => ({
title: faker.lorem.sentence(),
content: faker.lorem.paragraph(),
authorId: random(1, 10)
}))
);
app.listen(8080, () => console.log("App listening on port 8080!"));
});