-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (32 loc) · 984 Bytes
/
index.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
const express = require("express");
const cors = require("cors");
const { graphqlHTTP } = require("express-graphql");
const { graphql } = require("graphql-compose");
const { elasticApiFieldConfig } = require("graphql-compose-elasticsearch");
const { GraphQLSchema, GraphQLObjectType } = graphql;
const expressPort = process.env.port || process.env.PORT || 9201;
const generatedSchema = new GraphQLSchema({
query: new GraphQLObjectType({
name: "Query",
fields: {
elastic77: elasticApiFieldConfig({
host: "https://0f448043059d:a4264120-cd7a-4574-a449-2c5df0523cb1@appbase-demo-ansible-abxiydt-arc.searchbase.io",
index: "gitxplore-app",
apiVersion: "7.7",
log: "debug",
}),
},
}),
});
const server = express();
server.use(
"/",
cors(),
graphqlHTTP({
schema: generatedSchema,
graphiql: true,
})
);
server.listen(expressPort, () => {
console.log(`🚀 The server is running on port ${expressPort}`);
});