-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·53 lines (44 loc) · 1.37 KB
/
main.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
47
48
49
50
51
52
53
const express = require('express');
const chalk = require('chalk');
const config = require('./config/application');
const app = express();
const PORT = config(app);
const initDB = require('./config/postgres');
const postgres = initDB(app);
let pgResource = require('./api/pg-resource');
pgResource = pgResource(postgres);
/**
* @TODO: Initialize Apollo Server
*
* When you've completed your schema, configured and connected to Postgres
* you're ready to start your Apollo Server.
*
* Uncomment the following lines when you're ready to start Apollo:
*
* const initApollo = require('./config/apollo')
* initApollo({ app, pgResource })
*/
const initApollo = require('./config/apollo')
initApollo({ app, pgResource })
postgres.on('error', (err, client) => {
console.error('Unexpected error on idle postgres client', err);
process.exit(-1);
});
const server = app.listen(PORT, () => {
console.log(`>> ${chalk.blue('Express running:')} http://localhost:${PORT}`);
console.log(
`>> ${chalk.magenta('GraphQL playground:')} http://localhost:${PORT}/graphql`
);
/**
* @TODO: Initialize Apollo Server
*
* Uncomment the following lines when you're ready to start Apollo:
*
* console.log(
* `>> ${chalk.magenta('GraphQL playground:')} http://localhost:${PORT}/graphql`
* );
*/
});
server.on('error', err => {
console.log(err);
});