This project provides a simple RESTful API for managing books using NodeJS, Express, and PostgreSQL.
Make sure you have the following installed on your machine:
Environment Variables
The following environment variables are required to set up and run the application: Create an .env file
PORT=3000
POSTGRES_USER=admin
POSTGRES_PASSWORD=7gvl3A0
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=books
POSTGRES_HOST_LOCAL=localhost
-
Installation: Install all the dependencies:
npm install
-
Docker: Run the PostgreSQL database using Docker Compose:
docker-compose up
-
Database Migrations: Apply database migrations:
npm run migration:up
-
Testing: Run the test suite:
npm run test
-
To stop the containers and remove them:
docker-compose down
-
Rollback the last batch of migrations:
npm run migration:down
-
Building: Compile the TypeScript code:
npm run build
-
Running the API: Start the Express server:
npm run start
The main endpoint for managing books is /books
. You can use methods like GET
, POST
, PUT
, and DELETE
to interact with the database.
Note: Always ensure the PostgreSQL and API container is up and running before running migrations.