Created
December 31, 2021 10:06
-
-
Save kkratos/0a97521bc95dfb5dcb986f0f40df9b8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express, {Application} from "express"; | |
import { ApolloServer } from "apollo-server-express"; | |
import { typeDefs, resolvers } from "./graphql/index"; | |
import { connectDatabase } from "./database"; | |
const port = 3000; | |
const mount = async (app: Application) => { | |
const db = await connectDatabase(); | |
const server = new ApolloServer({ | |
typeDefs, | |
resolvers, | |
context:() => ({ db }) | |
}); | |
server.applyMiddleware({app, path:'/api'}) | |
app.listen(port); | |
console.log(`[app]: http://localhost:${port}`); | |
const listings = await db.listings.find({}).toArray(); | |
console.log(listings); | |
} | |
mount(express()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment