- You need to have Node runtime version 20.x or higher. Please navigate to https://nodejs.org and download an appropriate version.
- Create a MySQL server instance to serve as the database. In the .env file, assign the variables listed in .env.dist with your credentials.
To install the API, follow these steps:
-
Clone the repository:
git clone [email protected]:vagison/erp.aero-restapi-task.git
-
Navigate to the project directory:
cd erp.aero-restapi-task
-
Install the dependencies:
npm i
To run the API, follow these steps:
-
To start the compiled application located in the dist directory using Node you have to run the following commands:
npm run build
andnpm start
-
Alternatively to run the app in development mode with nodemon you have to run the following command:
npm run dev
-
To clean the dist directory, you can use the following command:
npm run clean
Create a .env file in the root of the project and configure the environment variables listed in .env.dist:
app.js is the entry point of the app. It starts the server, initiates the the database connection and more:
- Config: Contains all configurations required for database connection, CORS, JWT and other settings.
- Constants: Contains predefined values for error and success messages, as well as other constants.
- Controllers: Houses the actual implementations of server-side functions.
- Middlewares: Includes functions meant to be executed when Routes attempt to access Controllers. This also contains error-handling logic, cookie parser, Express validators and more.
- Models: Defines the schemas for server-side entities.
- Queries: Provides functions to retrieve and manipulate data within the database, utilized by models to perform data operations.
- Routes: Represents server-side endpoints that expect calls from the client-side. Routes redirect these calls to Controllers through Middlewares.
- Utils: Serves as a folder to store helper functions, validator schemas, database initializing logic and more.
- .babelrc.json - contains configuration settings for Babel, a JavaScript compiler that converts ES6+ code into a backward-compatible version of JavaScript that can run in older environments.
- .env.dist - serves as a template for environment variables, providing a sample configuration for the .env file.
- .eslintrc.json - contains configuration settings for ESLint, which is used to identify and fix problems in JavaScript code.
- .gitignore - used to exclude files from being pushed to the repository.
- package-lock.json - records the exact versions of packages and their dependencies that were installed, ensuring consistent installs across different environments.
- package.json - includes a list of the packages and their versions used for this project.
- User
- RefreshToken
- BearerToken
- File
To use the endpoints, you can visit the Postman URL below and then either fork or download the collection:
The request names are self-explanatory, and any additional information can be found within the requests themselves.
Note that the local variable "baseURL" should be manually set in your Postman client according to your usage (default is http://localhost:3000) other variables are set during API calls.