mirror of
https://github.com/yldio/copilot.git
synced 2024-11-14 07:10:05 +02:00
47 lines
736 B
JavaScript
47 lines
736 B
JavaScript
|
import hapi from 'hapi';
|
||
|
import {
|
||
|
graphqlHapi,
|
||
|
graphiqlHapi
|
||
|
} from 'graphql-server-hapi';
|
||
|
import schema from './schema';
|
||
|
|
||
|
const server = new hapi.Server();
|
||
|
|
||
|
const HOST = 'localhost';
|
||
|
const PORT = 3000;
|
||
|
|
||
|
server.connection({
|
||
|
host: HOST,
|
||
|
port: PORT,
|
||
|
});
|
||
|
|
||
|
server.register({
|
||
|
register: graphqlHapi,
|
||
|
options: {
|
||
|
path: '/graphql',
|
||
|
graphqlOptions: {
|
||
|
schema: schema,
|
||
|
},
|
||
|
route: {
|
||
|
cors: true
|
||
|
}
|
||
|
},
|
||
|
});
|
||
|
|
||
|
server.register({
|
||
|
register: graphiqlHapi,
|
||
|
options: {
|
||
|
path: '/graphiql',
|
||
|
graphiqlOptions: {
|
||
|
endpointURL: '/graphql',
|
||
|
},
|
||
|
},
|
||
|
});
|
||
|
|
||
|
server.start((err) => {
|
||
|
if (err) {
|
||
|
throw err;
|
||
|
}
|
||
|
console.log(`Server running at: ${server.info.uri}`);
|
||
|
});
|