This is a NestJS-based RESTful API for managing hotel bookings and rooming lists, using a PostgreSQL database.
Follow these simple steps to set up and run the API.
- Configure Environment Variables Navigate into the api directory:
cd api
Create a .env file if it doesn't exist:
touch .env
Open .env and add your database and application configuration:
PORT=3001
FE_PORT=5173
DB_HOST=db
DB_PORT=5432
DB_USER=your_db_username
DB_PASSWORD=your_db_password
DB_NAME=hotel_bookings
JWT_SECRET=your_jwt_secret_key_very_secret_and_long
- Build the Application Navigate back to the project root directory (where docker-compose.yml is located):
cd ..
To build the Docker images, run database migrations, and start all services, execute:
docker-compose up --build
The app will be running on http://localhost:5173/ (or change the port to FE_PORT set on .env)
To request the backend API correctly, you need to create a /frontend/.env file with the configurations:
VITE_API_BASE_URL=http://localhost:3001 (the same port you set to backedn api on root .env)
Once the API is running, you can test and explore the endpoints using the interactive Scalar documentation:
Open your browser and go to: http://localhost:3001/docs (or whatever the PORT you've set on environment)
To run the authenticated endpoint you must set some env variables on ./api/.env:
SEED_USERNAME=user
SEED_USERPASSWORD=password
SEED_USEREMAIL=email
And run the Users Seeds on the API Docs
You can run the Unit Tests just running the script below, inside api folder:
yarn test