mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
37 lines
861 B
TypeScript
37 lines
861 B
TypeScript
import { readFileSync } from "fs";
|
|
import { ApolloServer } from "@apollo/server";
|
|
import { startStandaloneServer } from "@apollo/server/standalone";
|
|
import { resolvers } from "./resolvers";
|
|
import { sharedMemory } from "./sharedMemory";
|
|
import { loadTestData } from "./testData";
|
|
import { ServerContext } from "./serverContext";
|
|
import { startDataUpdater } from "./sharedMemoryUpdater";
|
|
|
|
const typeDefs = readFileSync("./schema.graphql", "utf8");
|
|
|
|
async function main() {
|
|
// loadTestData(sharedMemory);
|
|
|
|
const server = new ApolloServer<ServerContext>({
|
|
typeDefs,
|
|
resolvers
|
|
});
|
|
|
|
const { url } = await startStandaloneServer(server, {
|
|
listen: {
|
|
port: 4000,
|
|
},
|
|
context: async ({ req, res }) => {
|
|
return {
|
|
sharedMemory,
|
|
}
|
|
},
|
|
});
|
|
|
|
startDataUpdater();
|
|
|
|
console.log(`Server ready at: ${url}`);
|
|
}
|
|
|
|
main();
|