This repository was archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (43 loc) · 1.3 KB
/
index.js
File metadata and controls
46 lines (43 loc) · 1.3 KB
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
/* eslint-disable no-console */
const app = require('./app');
const port = app.get('port');
const host = app.get('host');
process.on('unhandledRejection', function (err) {
throw err;
});
process.on('uncaughtException', function (err) {
app.error(err);
});
// Start server
const server = app.listen(port, host);
server.on('listening', () => {
// Start seeder, after database is setup
if (app.get('seeder').runOnInit === true) {
app.on('mongooseInit', () => {
app.service('users').find({ query: { $limit: 0 }})
.then(async (res) => {
app.debug(res);
if (res.total > 0) {
return null;
}
app.info(`Feathers application started on ${app.get('host')}:${port}`);
app.info('>>>>>> RUN SEEDER <<<<<<');
await app.seed();
});
});
} else {
app.service('categories').find({ query: { $limit: 0 }})
.then(async (res) => {
if (res.total < 1) {
app.service('admin').create({ seedBaseCategories: true });
}
});
app.service('badges').find({ query: { $limit: 0 }})
.then(async (res) => {
if (res.total < 1) {
app.service('admin').create({ seedBaseBadges: true });
}
});
app.info(`Feathers application started on ${app.get('host')}:${port}`);
}
});