Skip to content

Instantly share code, notes, and snippets.

@azharali
Created January 23, 2022 10:47
Show Gist options
  • Save azharali/f07620ab58b0dea41700f71511b8dfcd to your computer and use it in GitHub Desktop.
Save azharali/f07620ab58b0dea41700f71511b8dfcd to your computer and use it in GitHub Desktop.
Starter project using fastify backend, react frontend and rush to manage monorepo

Setup webapp

Setup repository

Setup backend project

Run the following commands to create backend package:

mkdir -p pkgs/api
cd pkgs/api

Follow instructions from Heft guide to setup backend project: https://rushstack.io/pages/heft_tutorials/getting_started/

E.g. copy package.json, start.ts, tsconfig.json as shown to api directory. Run the following commands:

pnpm install --save-dev @rushstack/heft
pnpm install --save-dev typescript
pnpm install --save-dev --save-exact @types/node
pnpm install --global @rushstack/heft

Add following lines to the "scripts" section in package.json

"build": "heft build --clean",
"start": "node lib/start.js"

Now you can build and run the project using following commands:

pnpm run build
pnpm run start

Setup rush

Install Rush: https://rushjs.io/pages/maintainer/setup_new_repo/

npm install -g @microsoft/rush
rush init

Edit rush.json and add an entry like this under the "projects" section:

  "projects": [
    {
      "packageName": "pkgs",
      "projectFolder": "pkgs/api"
    }
  ]

Change name field in package.json

"name": "pkgs"

Run the following commands to build and run the project using rush

cd <repo-root>
rush update

cd pkgs/api
rushx build
rushx start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment