Beginner friendly guide to nodejs express-server with mongodb,graphql and typescript

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • apollo-studio-community

    🎡  GraphQL developer portal featuring an IDE (Apollo Explorer), auto-documentation, metrics reporting, and more. This repo is for issues, feature requests, and preview docs. 📬

  • import express from "express"; import cors from 'cors' import { ApolloServer } from 'apollo-server-express'; import mongoose from 'mongoose'; import { resolvers } from './resolvers/TestResolver'; import { typeDefs } from './typeDefs/typedefs'; const PORT=4000; const startServer=async()=> { const app = express(); const allowedOrigins = [ 'http://localhost:3000', 'http://localhost:3001', 'https://studio.apollographql.com' ]; const corsOptions = { credentials: true, origin: function(origin, callback){ if(!origin) return callback(null, true); if(allowedOrigins.indexOf(origin) === -1){ var msg = 'The CORS policy for this site does not ' + 'allow access from the specified Origin.'; return callback(new Error(msg), false); } return callback(null, true); } } app.use(cors(corsOptions)) var uri = "mongodb://localhost:27017/testmongo"; //@ts-ignore mongoose.connect(uri, { useUnifiedTopology: true, useNewUrlParser: true }) .then(()=>console.log("connected to newmango db")) //rest routes app.get("/", (req, res) => { res.json({ data: "API is working...", }); }); const server = new ApolloServer({ typeDefs, resolvers, }); await server.start(); server.applyMiddleware({ app }); app.listen(PORT, () => { console.log(` Server is running at http://localhost:${PORT}`); }); } startServer().catch(e=>console.log("error strting server======== ",e))

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts