-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
73 lines (50 loc) · 1.28 KB
/
index.js
File metadata and controls
73 lines (50 loc) · 1.28 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import restify from 'restify';
import dbConnection from './Providers/DatabaseProviders';
import app_config from './config/app';
import graphqlHTTP from 'express-graphql';
import UserSchema from './config/graphql';
const server = restify.createServer({
name : app_config.app_name,
ignoreTrailingSlash: true
});
//load the dotenv
require("dotenv").load();
//server can read header
server.use(restify.plugins.acceptParser(server.acceptable));
// server can read request body
server.use(restify.plugins.bodyParser());
// server can read query string
server.use(restify.plugins.queryParser());
server.get("/" , function (req , res) {
res.json({
name: server.name,
status: "Active"
})
});
/**
* Config route core graphQL
*/
server.post('/graphql' , graphqlHTTP({
schema: UserSchema,
graphiql: false
}));
server.get('/graphql' , graphqlHTTP({
schema: UserSchema,
graphiql: true
}));
/**
* Import all Providers
*/
dbConnection;
/**
* import all config from config/ dir
*/
require('./config/app');
/**
* Import all routes from app/http/route
*/
const router = require('./app/Http/Route/index');
router.applyRoutes(server);
server.listen(app_config.app_port , function () {
console.log('Server start at port '+app_config.app_port);
});