This project is meant to explore and learn REST API architecture and good patterns to follow.
This project requires Node.js version >=20.12.1 and npm version >=10.5.0. Ensure you have the correct versions installed before proceeding.
-
Navigate to the root directory of the project and run the following command to install the required dependencies:
npm install
-
Navigate to the
tests/loadTestsfolder and install the dependencies for load testing:cd tests/loadTests npm install
To run load tests, you need to install k6 on your local machine. Follow the instructions below based on your operating system:
-
Linux:
sudo apt update sudo apt install -y k6
-
MacOS:
brew install k6
-
Windows:
Download the latest release from the k6 GitHub releases page and follow the installation instructions.
Once installed, you can run the load tests using the provided scripts.
The following scripts are available in the package.json file:
-
build: Compiles the TypeScript code into JavaScript.npm run build
-
dev: Starts the development server with hot-reloading enabled.npm run dev
-
start: Starts the production server.npm run start
-
k6:build: Compiles the TypeScript code for load tests.npm run k6:build
-
test:load: Runs load tests usingk6. This script starts the development server, waits for it to be ready, builds the load test files, and then executes the specified k6 test file (default isindex.js). You can specify a different file by setting theFILEenvironment variable.# Run the default load test (index.js) npm run test:load # Run a specific load test file (e.g., tasks.js) FILE=tasks.js npm run test:load
-
test: Runs both unit and integration tests, as well as generates a coverage report using Vitest.npm run test -
test:unit: Runs unit tests using Vitest for files in thesrcdirectory.npm run test:unit
-
test:integration: Runs integration tests using Vitest for files in thetests/integrationdirectory.npm run test:integration
-
test:coverage: Runs tests and generates a coverage report using Vitest.npm run test:coverage
-
test:ui: Runs both unit and integration tests with a UI interface using Vitest.npm run test:ui