forked from docluv/Love2Dev-Code-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.js
46 lines (25 loc) · 791 Bytes
/
generate.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
35
36
37
38
39
40
41
42
43
44
45
46
const fs = require( "fs" ),
path = require( "path" ),
faker = require( "faker" ),
utf8 = "utf-8";
let db = fs.readFileSync( path.resolve( "api/db.json" ), utf8 );
db = JSON.parse( db );
function fakeEmails() {
var emails = [],
length = faker.random.number( 25 );
for ( let i = 0; i < length; i++ ) {
emails.push( faker.internet.email() );
}
return emails;
}
function fakeSearchTerms() {
var terms = [],
length = faker.random.number( 50 );
for ( let i = 0; i < length; i++ ) {
terms.push( faker.random.words( faker.random.number( 4 ) + 1 ) );
}
return terms;
}
db.emails = fakeEmails();
db.terms = fakeSearchTerms();
fs.writeFileSync( path.resolve( "api/db.json" ), JSON.stringify( db ), utf8 );