-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathindex.ts
23 lines (19 loc) · 882 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import http from 'http';
import express, { Express } from 'express';
import cors from 'cors';
import { ApolloServer } from 'apollo-server-express';
import { GraphQLServerOptions } from '@backend/graphql';
import { logger } from '@backend/utils';
import Config from '@backend/config';
const app: Express = express();
app.use(cors());
const PORT: string | number = process.env.PORT || Config.defaultPort;
const server: ApolloServer = new ApolloServer(GraphQLServerOptions);
server.applyMiddleware({ app });
const httpServer: http.Server = http.createServer(app);
server.installSubscriptionHandlers(httpServer);
httpServer.listen(PORT, () => {
const { graphqlPath, subscriptionsPath } = server;
logger.info(`🚀 GraphQL Server is running at http://localhost:${PORT}${graphqlPath}`);
logger.info(`🚀 Subscriptions ready at ws://localhost:${PORT}${subscriptionsPath}`);
});