You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
require("dotenv").config()
|
|
import { ApolloServer } from "apollo-server-express"
|
|
import { createConnection } from "typeorm"
|
|
import { createSchema } from "./schema"
|
|
import { User } from "./User"
|
|
import express = require("express")
|
|
|
|
;(async () => {
|
|
await createConnection({
|
|
type: "postgres",
|
|
host: "localhost",
|
|
port: 5432,
|
|
database: "postgres",
|
|
username: "postgres",
|
|
password: "postgres",
|
|
// dropSchema: true,
|
|
entities: [User],
|
|
synchronize: true,
|
|
logging: false,
|
|
})
|
|
|
|
const server = new ApolloServer({
|
|
schema: await createSchema(),
|
|
playground: true,
|
|
introspection: true,
|
|
debug: true,
|
|
context: ({ req, res }) => ({ req, res }),
|
|
})
|
|
|
|
const app = express()
|
|
server.applyMiddleware({ app })
|
|
|
|
const PORT = process.env.PORT || 4000
|
|
app.listen({ port: PORT }, () =>
|
|
console.log(`🚀 Server ready at http://localhost:${PORT}${server.graphqlPath}. `)
|
|
)
|
|
})()
|
|
|