Skip to content

Commit 95c828b

Browse files
committed
Merge branch 'development'
2 parents b6857d2 + 7a1d1a1 commit 95c828b

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

faker/genusers.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env node
2+
const faker = require("faker");
3+
const fs = require("fs");
4+
5+
function generateUsers() {
6+
7+
let users = [];
8+
9+
for (let id=1; id <= 100; id++) {
10+
11+
let firstName = faker.name.firstName();
12+
let lastName = faker.name.lastName();
13+
let email = faker.internet.email();
14+
15+
users.push({
16+
"id": id,
17+
"first_name": firstName,
18+
"last_name": lastName,
19+
"email": email
20+
});
21+
}
22+
23+
return { "data": users };
24+
}
25+
26+
let dataObj = generateUsers();
27+
fs.writeFileSync("data.json", JSON.stringify(dataObj, null, "\t"));

faker/getdata.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env node
2+
const request = require("request");
3+
4+
request("http://localhost:3004/data?_start=4&_end=8", (err, resp, body) => {
5+
if (err) {
6+
console.error("request failed");
7+
console.error(err);
8+
} else {
9+
console.log(body);
10+
}
11+
});
12+

faker/jsonserver

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
json-server --watch data.json --port 3004

0 commit comments

Comments
 (0)