- Getting Started
- Pnpm Command Reference
- Project Structure
- Generating Authentication Token
- Testing Guidelines
- Using Firebase Emulator Locally
- Pull request guidelines
Instructions for initial setup can be found in the README.
Installs all dependencies listed in the root package.json.
Compiles TypeScript + allowJs sources to dist/ via tsc
(tsconfig.json: outDir: dist). typescript is a devDependency, so run
this before any pnpm prune --prod. Required before pnpm start
(start runs node ./dist/server.js and does not rebuild).
Starts the server in dev mode with ts-node-dev (no dist/ build needed).
The script associated with pnpm test will run all tests that ensures that your commit does not break anything in the
repository. This will run the lint, integration and unit tests.
Run only unit or only integration tests (see scripts/tests/testUnit.sh /
testIntegration.sh).
Run TDD in watch mode for files listed in scripts/tests/tdd-files-list.txt.
Runs the lint checks in the project.
Runs lint checks and auto-fixes what can be fixed.
Runs the test for checking local development setup is working properly or not.
The following project structure should be followed:
|-- website-backend
|-- config
| |-- custom-environment-variables.js
| |-- default.js
| |-- development.js
| |-- production.js
| |-- staging.js
| |-- test.js
|-- controllers
| |-- health.js
| |-- // Controller files concerning function on a similar entity
|-- logs
| |-- // log files
|-- middlewares
| |-- // individual middleware files to be required on server start or in the route middleware
|-- models
| |-- // Files consisting of the individual table/collection config and wrapper interaction functions
|-- routes
| |-- index.js // routes files separated by their first path string
| |-- auth.js // the individual routes files should contain the OPEN API JSDOC reference
|-- services
| |-- authService.js // Files using any 3rd party library/service or providing any secific service in the project
|-- scripts // Standalone scripts
|-- test
| |-- fixtures
| | |-- auth
| | |-- githubUserInfo.js
| |-- integration // Integration tests
| | |-- auth.test.js
| |-- unit // Unit tests
| | |-- middlewares
| | |-- services
| |-- utils // Utility functions to be used while testing
|-- utils // Files containing utility functions
| |-- logger.js
|-- .github
| |-- workflows
| |-- // Github actions files
|-- .husky // git hooks (pre-commit runs `pnpm lint`)
|-- .gitignore
|-- .*rc, .*js, .*json, .*yml // config files for dependencies
|-- CONTRIBUTING.md
|-- README.md
|-- CHANGELOG.md
|-- app.js
|-- pnpm-workspace.yaml
|-- pnpm-lock.yaml
|-- package.json
|-- server.js // Contains server start logic
- Run the project locally, make sure the server is listening to requests
- Navigate to
https://github.com/login/oauth/authorize?client_id=<GITHUB_CLIENT_ID> - Authorize the application
- Once authorized, check browser's cookies section. Copy the value of the cookie named
rds-session(rds-session-developmentfor development mode). - Use the cookie for authenticated routes in the API.
- For non-production environments, authentication is also supported with the
Authorizationheader. - Authorization header:
Authorization: Bearer <token>
https://api.realdevsquad.com/auth/github/login
rds-session
https://staging-api.realdevsquad.com/auth/github/login
rds-session-staging
- Libraries used in testing in the project:
- The test suite uses Firebase Local Emulator Suite for running firestore for tests(documentation).
- Pre-requisites:
- Node.js 26.8.1 (installed automatically by pnpm, see README).
- Java version 21 or higher (required by firebase-tools 15+).
- Firebase Local Emulator Suite can be used locally as the DB for the project
- Pre-requisites:
- Node.js 26.8.1 (installed automatically by pnpm, see README).
- Java version 21 or higher (required by firebase-tools 15+).
- Run:
npx firebase emulators:start - The emulator will run and display the url you can access it on.
- You can view the emulator UI at:
http://localhost:4000 - To run the application with using firebase emulator, run the following command(docs):
export FIRESTORE_EMULATOR_HOST="localhost:<Firebase emulator PORT>"- Git Bash is recommended for running test scripts on Windows.
- Run
pnpm test-integrationfor running integration tests. - Run
pnpm test-unitfor running unit tests. - Make sure the server is not running.
- Make sure to close the emulator window after running the tests in order to avoid the blocking of the port for the next tests to run.
- For e.g - After running the integration tests, close the emulator window and then run the command for unit tests.
This project uses husky to run a pre-commit hook that automatically lints your changes before each commit. The hook runs pnpm lint.
Husky is set up automatically when you run pnpm install (via the prepare script in package.json). No manual configuration is needed.
If you want to bypass the hook for a specific commit (not recommended), you can use:
git commit --no-verify- Ensure that the tests pass locally before raising a PR.
- All pull requests should have base as the develop branch.
- Every pull request should have associated issue(s) on our issue tracker.
- For any non-trivial fixes and features, unit and integration tests must be added. The PR reviewer should not approve/merge PR(s) that lack these.
- The PR(s) should be merged only after the CI passes.
- Java version is below 21 (
firebase-tools no longer supports Java version before 21) - When we run pnpm test, it runs both the unit and integration tests (in this order). So after the unit tests are done, the java process is not killed automatically and when our integration test run it gives error.
- Error: connect ECONNREFUSED ::1:8081
- Java version 21 or above is needed for firebase-tools version >= 15
- Either manually kill the java process after unit tests are done or run both the tests separately by running the test commands.
- Add 'host : 0.0.0.0' to both firestore and ui object in firebase.json file if it is not added. for more info refer this : #918