-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (25 loc) · 762 Bytes
/
app.js
File metadata and controls
30 lines (25 loc) · 762 Bytes
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
const express = require('express'),
{ expressConfigs, expressMiddlewares } = require('./config'),
{ rootRoute, loginRoute, registerRoute, phonebookRoute, logoutRoute } = require('./routes'),
cors = require('cors'),
graphqlHTTP = require('express-graphql'),
{ schema, rootValue } = require('./graphql'),
{ isAuth } = require('./middlewares');
const app = express();
app.use(isAuth);
app.use(cors());
app.use('/graphql', cors(), graphqlHTTP({
schema,
rootValue,
graphiql: true
}));
expressConfigs(app);
expressMiddlewares(express, app);
rootRoute(app);
loginRoute(app);
registerRoute(app);
phonebookRoute(app);
logoutRoute(app);
app.listen(process.env.PORT || 8080, () => {
console.log('Server is running...');
});