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.git
2. 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 .env
Make sure you have Node.js, PostgreSQL, and MySQL installed
node -v
npm -v
psql -V
mysql -V
4. Install the needed npm packages:
npm install
5. Build the application:
npm run build
6. Start the application:
npm start
Make sure you have docker and docker-compose installed on your UNIX based machine:
docker -v
docker-compose -v
4. Build the API's docker image:
docker build . -t employees
5. Run the application:
docker-compose up
6. Don't forget the stop the containers after you close the application:
docker-compose down
In 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.