-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (29 loc) · 898 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
import { ApolloServer, PubSub } from "apollo-server-express";
const http = require("http");
import express from "express";
import conexion from "./db/dbconexion";
import resolvers from "./graphql/resolvers";
import typeDefs from "./graphql/typedesfs";
const pubsub = new PubSub();
const PORT = 3000;
const startServer = async () => {
const app = express();
const server = new ApolloServer({
typeDefs,
resolvers,
context: ({ req }) => ({ req, pubsub }),
});
server.applyMiddleware({ app });
const httpServer = http.createServer(app);
server.installSubscriptionHandlers(httpServer);
conexion;
httpServer.listen(PORT, () => {
console.log(
`🚀 Server ready at http://localhost:${PORT}${server.graphqlPath}`
),
console.log(
`🚀 Subscriptions ready at ws://localhost:${PORT}${server.subscriptionsPath}`
);
});
};
startServer();