-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (25 loc) · 698 Bytes
/
app.js
File metadata and controls
29 lines (25 loc) · 698 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
28
29
const express = require("express");
const { graphqlHTTP } = require("express-graphql");
const schema = require("./schema/schema");
const { sequelize, books, authors } = require("./models");
const cors = require("cors");
const app = express();
// allow cross-origin requests
app.use(cors());
// setting up middlewear
app.use(
"/graphql",
graphqlHTTP({
// schema: schema,
schema,
graphiql: true,
})
);
app.listen({ port: 5000 }, async () => {
console.log("Postgres server up and running on port 5000");
await sequelize.sync();
console.log("Database connected!");
});
app.listen({ port: 4000 }, () => {
console.log("Now listening for graphql requests on port 4000");
});