Skip to content

Commit e3634d7

Browse files
committed
add run.sh file and readme documentation improvement
1 parent 8feb5f6 commit e3634d7

File tree

4 files changed

+38
-53
lines changed

4 files changed

+38
-53
lines changed

README.md

Lines changed: 24 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This is a full-fledged User Authentication app created using Express, TypeORM, P
22

33
Here is the list of APIs this app contains:"
44

5-
<img src="images/docs.png">
5+
<img src="images/api-docs.png">
66

77
# Project Setup and Local Run Guide
88

@@ -18,11 +18,12 @@ Below is a summary of key features and instructions for running the project:
1818
2. TypeORM for database interactions.
1919
3. Passport for authentication strategies.
2020
4. Swagger for API documentation.
21+
5. Docker desktop
2122

2223
### Development Tools:
2324

2425
1. Nodemon for automatic server restart during development.
25-
2. ts-node for running TypeScript files directly.
26+
2. `ts-node` for running `TypeScript` files directly.
2627
3. Concurrently for running multiple npm scripts concurrently.
2728
4. Database Migrations:
2829

@@ -35,6 +36,7 @@ Before getting started, ensure that you have the following installed on your mac
3536

3637
- Node.js: [Download and Install Node.js](https://nodejs.org/)
3738
- npm (Node Package Manager): Included with Node.js installation
39+
- Docker Desktop
3840

3941
## Project Setup
4042

@@ -52,59 +54,30 @@ Before getting started, ensure that you have the following installed on your mac
5254
cd mysql-express-node-auth-app
5355
```
5456

55-
3. **Install Dependencies:**
56-
Install project dependencies by running:
57-
58-
```bash
59-
npm install
60-
```
61-
6257
## Running the Project Locally
6358

64-
### Development Mode
65-
66-
To run the project in development mode with automatic restart on file changes, execute the following command:
67-
59+
### 1. Change the file permissions `run.sh` to make it executable
6860
```bash
69-
npm run dev
61+
chmod +x run.sh
7062
```
7163

72-
This command uses `nodemon` to watch for changes in the `src` directory and automatically restarts the server.
73-
74-
### Production Mode
75-
76-
To start the project in production mode, use:
77-
64+
### 2. copy the `.env.example` file and make new `.env` file
7865
```bash
79-
npm start
66+
./run.sh env
8067
```
8168

82-
### Swagger Documentation
83-
84-
To generate Swagger documentation, use the following command:
85-
69+
### 3. Start the project. Below command will pull the MySQL, Node images, install the dependencies.
8670
```bash
87-
npm run swagger
71+
./run.sh start
8872
```
73+
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.
8974

90-
This command generates Swagger specs based on your TypeScript code.
91-
92-
## Database Migrations
93-
94-
The project includes commands for managing database migrations using TypeORM.
95-
96-
- **Create a Migration:**
97-
98-
```bash
99-
npm run migration:create
100-
```
101-
102-
- **Generate a Migration:**
103-
104-
```bash
105-
npm run migration:generate
106-
```
75+
### 4. Go inside app container.
76+
```bash
77+
./run.sh bash
78+
```
10779

80+
Once you are inside the docker container you can run the below commands. These commands are for managing database migrations using TypeORM.
10881
- **Run Migrations:**
10982

11083
```bash
@@ -116,19 +89,17 @@ The project includes commands for managing database migrations using TypeORM.
11689
```bash
11790
npm run migration:down
11891
```
92+
- **Create a Migration:**
11993

120-
## Additional Notes
121-
122-
- **Environment Variables:**
123-
Create a `.env` file in the project root with the necessary environment variables. You can refer to the provided `.env.example` file for guidance.
124-
125-
- **Swagger UI:**
126-
Access the Swagger UI at `http://localhost:8000/docs` to interact with the API documentation.
94+
```bash
95+
npm run migration:create
96+
```
12797

128-
- **Concurrent Commands:**
129-
The `concurrently` package allows you to run multiple npm scripts concurrently. This is utilized in the `npm run dev` command.
98+
- **Generate a Migration:**
13099

131-
---
100+
```bash
101+
npm run migration:generate
102+
```
132103

133104
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.
134105

images/api-docs.png

263 KB
Loading

images/docs.png

-261 KB
Binary file not shown.

run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
if [ "$1" == "start" ]; then
4+
docker compose up -d
5+
elif [ "$1" == "bash" ]; then
6+
docker exec -it mysql-express-node-auth-app-app-1 bash
7+
elif [ "$1" == "stop" ]; then
8+
docker compose down
9+
elif [ "$1" == "env" ]; then
10+
cp .env.example .env
11+
else
12+
echo "Invalid input. Use 'start' to run docker compose up or 'bash' to exec into the container."
13+
exit 1
14+
fi

0 commit comments

Comments
 (0)