jocoso / Book-Club

A website for books enthusiast
0 stars 0 forks source link

Initialize Express and Apollo Server: #46

Closed AhmedGarcia closed 12 hours ago

AhmedGarcia commented 15 hours ago

Initialize Express and Apollo Server:

Import necessary modules: express, apollo-server-express, path, typeDefs, resolvers, db, and authMiddleware. Initialize an Express app instance. Create an Apollo Server instance with typeDefs and resolvers, and include the authMiddleware for handling user authentication. Configure Middleware:

Set up middleware to parse JSON and URL-encoded data for incoming requests. If in production, serve static files from the client/build directory. Apply Apollo Middleware:

Start the Apollo Server and apply its middleware to the Express app to handle GraphQL requests. Set Up Fallback Route:

Configure a fallback route to serve the index.html file from the client/build directory for any undefined routes. Start the Server:

Listen on the specified port and connect to the MongoDB database. Log a message indicating that the server and GraphQL endpoint are running. Test Server Functionality:

Verify that the server starts successfully, connects to the database, and serves GraphQL requests.

AhmedGarcia commented 13 hours ago

completed. server is up and running