An attempt at building a Backend for Stackoverflow clone using type-graphql, mongoose, and others.
You can choose either one of the below setup procedures:
-
Step 1:
Wait for VM bootup process....
-
Step 2: Create a local branch on your codesandbox account.
-
Step 3:
Runyarn server start:dev
Please Note: I have already loaded .env.dev
file with required variables, But be sure to check packages/server/env.example and add required .env.dev or .env.test
files in packages/server directory if something goes wrong. Run the commands in below order from project root directory.
# Install Dependencies
yarn install
# Check Environment variables
# Start MongoDB
yarn server start:mongo # check `packages/server/docker-compose.yml` for more information
# Build App
yarn server build
# Start Development Server
yarn server start:dev # development server runs with `.env.dev` variables
# or
yarn server start:test # test server runs with `.env.test` variables
# Cleanup: Kill MongoDB Process
yarn server kill:mongo
- Node.js - Runtime environment for JS
- Apollo Server - To build a self-documenting GraphQL API server
- Type-graphql - For defining the Graphql schema using classes and decorators and additional features like dependency injection, validation and auth guards to embrace code reusability
- MongoDB - Database to store document-based data
- Mongoose - MongoDB object modeling for Node.js
- Typegoose - Define Mongoose models using TypeScript classes
- JSON Web Token - A standard to secure/authenticate HTTP requests
- Bcrypt.js - For hashing passwords
- Mongoose Unique Validator - Plugin for better error handling of unique fields within Mongoose schema.
- Dotenv - To load environment variables from a .env file
- Docker
Update 1: Migrated Server codebase to Typescript using type-graphql
, typegoose
.
Update 2: (27/10/2021) Automated Graphql Testing using jest
, ts-jest
, isomorphic-fetch
.
Update 3: (29/10/2021) Replaced constant growing arrays with mongoose virtuals.
Update 4: (4/05/2022) Moved to Hybrid(poly repo + mono repo) structure to reduce code,build management issues, also I am not using tools like Nx,turborepo,bazel which would mitigate those issues.
Update 5: Improve code and data models.
- Use transactions in mutation resolvers that involve multiple mutating database requests.