This is a NestJS application that monitors air quality using data from the IQAir API. The application stores the air quality data in a MariaDB database.
- Node.js (>= 18)
- MariaDB
- TypeORM
src/
: Source code for the NestJS application.src/air-quality/
: Contains the air quality feature module.datasource.ts
: TypeORM datasource configuration file..env
: Environment configuration file..env.test
: Environment configuration file for testing .
-
Clone the repository:
git clone https://github.com/your-username/air-quality-monitoring.git cd air-quality-monitoring
-
Install dependencies:
npm install
-
Create environment configuration:
Create a
.env
file in the root directory with the following content:DATABASE_HOST=localhost DATABASE_PORT=3306 DATABASE_USERNAME=user DATABASE_PASSWORD=password DATABASE_NAME=air_quality
Compile the TypeScript code and run the migrations to set up the database schema:
npm run migration:run
-
Start MariaDB: Ensure your MariaDB server is running and accessible.
-
Start the Application:
npm run start:dev
This will start the application in development mode with hot reloading. The application should be accessible at http://localhost:3000.
Swagger is used to document and test the API. To access the Swagger UI, open your browser and navigate to:
http://localhost:3000/api
This will provide an interactive documentation page for the API endpoints.
- Unit Tests:
Unit tests are used to test individual components of the application. To run the unit tests, use the following command:
npm run test
- Integration Tests
Integration tests are used to test the application's components together, including interactions with the database. To run the integration tests, use the following command:
npm run test:e2e
npm start
: Starts the application.npm run start:dev
: Starts the application in development mode with hot reloading.npm run start:prod
: Starts the application in production mode.npm run build
: Builds the application.npm run lint
: Lints the code.npm run migration:run
: Runs the TypeORM migrations.npm run test:e2e
: Runs the end-to-end tests.
This project is licensed under the MIT License. See the LICENSE file for details.