forked from ef37/graphql-dataloader-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repl.js
34 lines (26 loc) · 784 Bytes
/
repl.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
// @flow
import 'reify/repl';
import 'isomorphic-fetch';
import 'babel-polyfill';
import REPL from 'repl';
import replPromised from 'repl-promised';
import history from 'repl.history';
import connectDatabase from './src/database';
import * as M from './src/model';
import { generateToken } from './src/auth';
(async() => {
try {
const info = await connectDatabase();
console.log(`Connected to ${info.host}:${info.port}/${info.name}`);
const repl = REPL.start({
prompt: 'awesome > ',
});
repl.context.M = M;
repl.context.generateToken = generateToken;
history(repl, `${process.env.HOME}/.node_history`);
replPromised.promisify(repl);
} catch (error) {
console.error('Unable to connect to database');
process.exit(1);
}
})();