-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (24 loc) · 702 Bytes
/
index.js
File metadata and controls
27 lines (24 loc) · 702 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
const express = require('express');
const app = express();
const graphqlHTTP = require('express-graphql');
const graphQLSchema = require('swagger-to-graphql');
const API_BASE_URL = 'https://api.sipgate.com/v2';
graphQLSchema('./swagger.json').then(schema => {
app.use('/graphql', graphqlHTTP(req => {
const authorization = req.param('authorization');
console.log({ authorization });
return {
schema,
context: {
GQLProxyBaseUrl: API_BASE_URL,
BearerToken: `Bearer ${authorization}`
},
graphiql: true
};
}));
app.listen(3009, 'localhost', () => {
console.info(`API is here localhost:3009/graphql`);
});
}).catch(e => {
throw e;
});