Boilerplate project for NodeJS, React based projects in TypeScript. This README documents whatever steps are necessary to get your application up and running.
Quickstart:
- This project supports running the application with all the required dependencies using
docker compose
- Install docker
- Run
docker compose -f docker-compose.dev.yml up
(Add--build
to force rebuild when new dependencies have been added) - Application should open up automatically. In case it doesn't, go to -
http://localhost:3000
- Make required changes for development. Both backend and frontend should hot reload and server restart is not required.
Bonus:
- On running
serve
, frontend server is at -http://localhost:3000
- On running
serve
, backend server is at -http://localhost:8080
- To connect to MongoDb server using a client, can use -
mongodb://localhost:27017
Pre Requirements:
Scripts:
- Install dependencies -
npm install
- Build Project -
npm build
- Start Application (without HotReload) -
npm start
- Start Application (with HotReload enabled) -
npm run serve
- To disable opening up browser automatically, set
WEBPACK_DEV_DISABLE_OPEN
totrue
.
- To disable opening up browser automatically, set
- Run Lint (JavaScript and TypeScript) -
npm run lint
- Run Lint (Markdown) -
npm run lint:md
- Run E2E tests -
npm run e2e
- Open Cypress -
npm run cy:open
- Format files using Prettier -
npm run fmt
The module uses config for loading configuration entries.
In the config
directory:
- Consult/update
custom-environment-variables.yml
for loading values via environment. This overrides any value set in files defined below. - Create
local.yml
for local config. - Consult/update
development.yml
for values at development. (The default env) - Consult/update
testing.yml
for values at testing.NODE_CONFIG_ENV
must be set totesting
for this. - Consult/update
staging.yml
for values at staging.NODE_CONFIG_ENV
must be set tostaging
for this. - Consult/update
production.yml
for values at production.NODE_CONFIG_ENV
must be set toproduction
for this. - Consult/update
default.yml
for constant values only. Define entries here which will remain same across deployments.
INFO: default.yml
config file lists the all available entries which the system uses. For creating a new config entry:
- If the config value tends to change across deployments, provide
undefined
for the same indefault.yml
and value should be provided in respective deployment file. - If the config value is supposed to be same across deployments, provide the same in
default.yml
.
INFO: local*
files allows you to manually provide config during development and are set to be ignored by VCS. Any environment can be overridden locally via:
local.yml
- Overrides everything.local-{env}.yml
- Overrides only specificenv
environment.
INFO: Read more about in what order the config entries are loaded here.
INFO: For injecting environment variables, can add .env
file in the application root directory.
UI Config:
Config module can be also used to inject configuration values into frontend build. public
accepts key value pairs which will all get injected
into frontend builds.
- Define the config entry in appropriate config file under
public
, example -public.myServiceKey
. Note that deployment does not supports injecting config values using environment variables so avoid usingcustom-environment-variables.yml
here. - Use the config value via
Config.getConfigValue('myServiceKey')
- For scripts directly using the config from
window
, can use the config directly viawindow.Config.myServiceKey
. For type safety for the same, can add the entry insrc/apps/frontend/types/globals.d.ts
.
This project support following integrations TODO: Need to add documentation for all integrations
Name | Type | Documentation | Configuration |
---|---|---|---|
DataDog | Logger | -Create a dedicated public channel named "Error Alerts" within your MS Teams workspace. This centralized space will serve as a hub for all error-related communications. -Streamline the error alert process by integrating the "Error Alerts" channel with DataDog. This integration enhances communication and incident response. -Guidance on Integration https://jalantechnologies.com/uncategorized/push-notifications-from-datadog-to-microsoft-teams/ -For implementation, refer the following links -PR: #88 -docs: https://docs.datadoghq.com/logs/log_collection/nodejs/?tab=winston30 |
- logger.transports = ['datadog'] - datadog.api_key - <DATADOG_CLIENT_TOKEN> - datadog.app_name - <DATADOG_CLIENT_TOKEN_NAME> in this implementation these are not the datadog's api key and name, to generate these, create a client token under Organisational settings > Client token refer docs under logs > getting started > client for more info |
Inspectlet | Analytics | https://docs.inspectlet.com/hc/en-us/articles/206355438-Installing-Inspectlet | - inspectlet.wid = Unique Inspectlet key provided by inspectlet |
This project deploys on Kubernetes via GitHub actions using workflows defined in GitHub CI.
Pre Requirements:
Get the application up and running via following steps in Getting Started
Troubleshooting:
If you're running into npm ERR! code ELIFECYCLE npm ERR! err no1
error, follow these steps to fix it:
sudo npm cache clean -f (force) clear you npm cache
sudo npm install -g n install n
sudo n stable upgrade to the current stable version)
For more detailed info, check out this official guide on troubleshooting.
Running specs from the command line:
# run the entire suite
cypress run
# run headless chrome
cypress run --headless --browser chrome
# run an individual spec file
cypress run --spec "cypress/e2e/login.spec.cy.ts"
# run all specs within the folder matching the glob (Note: Using double quotes is strongly recommended.
cypress run --spec "cypress/e2e/**/*"
Running specs from the GUI:
- Open the Cypress Test Runner and click on any types of testing E2E Testing & Component Testing.
cypress run
- The Cypress Test Runner will open a new window with browser option, select respective browser.
- The Cypress Test Runner will open a new window with specs, clicking on any spec will execute the test in browser.