diff --git a/README.md b/README.md index e158ae5..d7fff97 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ This is a full-fledged User Authentication app created using Express, TypeORM, P Here is the list of APIs this app contains:" - + # Project Setup and Local Run Guide -This guide provides step-by-step guide on setting up and running the "mysql-expense-node-auth-app" project locally on your machine. Please follow the steps outlined below. +This guide provides step-by-step guide on setting up and running the "mysql-express-node-auth-app" project locally on your machine. Please follow the steps outlined below. Below is a summary of key features and instructions for running the project: @@ -18,11 +18,12 @@ Below is a summary of key features and instructions for running the project: 2. TypeORM for database interactions. 3. Passport for authentication strategies. 4. Swagger for API documentation. +5. Docker desktop ### Development Tools: 1. Nodemon for automatic server restart during development. -2. ts-node for running TypeScript files directly. +2. `ts-node` for running `TypeScript` files directly. 3. Concurrently for running multiple npm scripts concurrently. 4. Database Migrations: @@ -35,6 +36,7 @@ Before getting started, ensure that you have the following installed on your mac - Node.js: [Download and Install Node.js](https://nodejs.org/) - npm (Node Package Manager): Included with Node.js installation +- Docker Desktop ## Project Setup @@ -42,69 +44,40 @@ Before getting started, ensure that you have the following installed on your mac Open a terminal and run the following command to clone the project repository: ```bash - git clone https://github.com/dev-scripts/mysql-expense-node-auth-app.git + git clone https://github.com/dev-scripts/mysql-express-node-auth-app.git ``` 2. **Navigate to the Project Directory:** Change into the project directory using the following command: ```bash - cd mysql-expense-node-auth-app - ``` - -3. **Install Dependencies:** - Install project dependencies by running: - - ```bash - npm install + cd mysql-express-node-auth-app ``` ## Running the Project Locally -### Development Mode - -To run the project in development mode with automatic restart on file changes, execute the following command: - + ### 1. Change the file permissions `run.sh` to make it executable ```bash -npm run dev + chmod +x run.sh ``` -This command uses `nodemon` to watch for changes in the `src` directory and automatically restarts the server. - -### Production Mode - -To start the project in production mode, use: - + ### 2. copy the `.env.example` file and make new `.env` file ```bash -npm start + ./run.sh env ``` -### Swagger Documentation - -To generate Swagger documentation, use the following command: - + ### 3. Start the project. Below command will pull the MySQL, Node images, install the dependencies. ```bash -npm run swagger + ./run.sh start ``` +once docker containers are up and running project is accessable `http://localhost:8000/docs`. This is the Swagger UI which will list all the API endpoints. -This command generates Swagger specs based on your TypeScript code. - -## Database Migrations - -The project includes commands for managing database migrations using TypeORM. - -- **Create a Migration:** - - ```bash - npm run migration:create - ``` - -- **Generate a Migration:** - - ```bash - npm run migration:generate - ``` + ### 4. Go inside app container. +```bash + ./run.sh bash +``` +Once you are inside the docker container you can run the below commands. These commands are for managing database migrations using TypeORM. - **Run Migrations:** ```bash @@ -116,20 +89,18 @@ The project includes commands for managing database migrations using TypeORM. ```bash npm run migration:down ``` +- **Create a Migration:** -## Additional Notes - -- **Environment Variables:** - Create a `.env` file in the project root with the necessary environment variables. You can refer to the provided `.env.example` file for guidance. - -- **Swagger UI:** - Access the Swagger UI at `http://localhost:3000/docs` to interact with the API documentation. + ```bash + npm run migration:create + ``` -- **Concurrent Commands:** - The `concurrently` package allows you to run multiple npm scripts concurrently. This is utilized in the `npm run dev` command. +- **Generate a Migration:** ---- + ```bash + npm run migration:generate + ``` -Now you should have the "mysql-expense-node-auth-app" project up and running locally. If you encounter any issues, please refer to the project documentation or seek assistance from the project's maintainers. +Now you should have the "mysql-express-node-auth-app" project up and running locally. If you encounter any issues, please refer to the project documentation or seek assistance from the project's maintainers. Feel free to customize the content as needed for your specific project. diff --git a/images/api-docs.png b/images/api-docs.png new file mode 100644 index 0000000..376eb4e Binary files /dev/null and b/images/api-docs.png differ diff --git a/images/docs.png b/images/docs.png deleted file mode 100644 index 2d72183..0000000 Binary files a/images/docs.png and /dev/null differ diff --git a/package.json b/package.json index bdeaab3..2ae085e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "mysql-expense-node-auth-app", + "name": "mysql-express-node-auth-app", "version": "1.0.0", "description": "", "main": "index.js", diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..8b52669 --- /dev/null +++ b/run.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ "$1" == "start" ]; then + docker compose up -d +elif [ "$1" == "bash" ]; then +docker exec -it mysql-express-node-auth-app-app-1 bash +elif [ "$1" == "stop" ]; then + docker compose down +elif [ "$1" == "env" ]; then + cp .env.example .env +else + echo "Invalid input. Use 'start' to run docker compose up or 'bash' to exec into the container." + exit 1 +fi