Simple REST API using Express with TypeScript, PostgreSQL, and MySQL to practice the Clean Architecture by Uncle Bob.
This REST API application implements the Clean Architecture in such a way that you can easily migrate between two RDBMS (PostgreSQL and MySQL) smoothly using a single environment variable DB_TYPE which can be toggled between pg and mysql in either .env file or docker-compose.yml depending on how are you running the application.
1. Clone the repo:
git clone https://github.com/abdullahalshawafi/Clean-Architecture.git2. Move the project's directory:
cd Clean-Architecture/3. Copy .env.example file into .env file and fill it with your environment variables:
cp .env.example .envMake sure you have Node.js, PostgreSQL, and MySQL installed
node -v
npm -v
psql -V
mysql -V4. Install the needed npm packages:
npm install5. Build the application:
npm run build6. Start the application:
npm startMake sure you have docker and docker-compose installed on your UNIX based machine:
docker -v
docker-compose -v4. Build the API's docker image:
docker build . -t employees5. Run the application:
docker-compose up6. Don't forget the stop the containers after you close the application:
docker-compose downIn either ways, the application should start and be running on http://localhost:8080
To generate the documentation use npm run docs. Then go to http://localhost:8080/api/v1 to view the generated documentation.