Restaurant API with a social Twist (Rec.us)
This API is a backend service for managing restaurant reservations.
- Node.js: You need to have node.js installed to run the application. You can download and install the latest version from node's website here: https://nodejs.org/
- Docker: Docker is used to setup the PostgreSQL Database. Please install Docker Desktop from their website if you don't already have it on your machine: https://www.docker.com/products/docker-desktop/
- Prisma CLI: Prisma will be included in the package.json. You will need it to run Prisma commands. Install it globally using the following command before completing the next steps:
npm install -g prisma
git clone https://github.com/shivampatel215/restaurant-api.git
cd restaurant-api
Create a .env
file in the root directory and add the necessary environment variables.
npm install
docker-compose up -d
After running the docker command, open docker desktop (or use terminal) to ensure that the container is up and running
npx prisma init
At this point, open a database client of your choice (I used DBeaver) and connect to the postgresql db using the credentials provided. Test the connection. You should see it connected and at this point there should be no tables in the db.
Run the following command to run the db migrations. After this, you should see tables (no records or data) in your db
npx prisma migrate dev
npx prisma generate
npm run seed
Now you should see data in your database.
npm run start
npm run test
npm run reset-db
Make sure to reset the DB after before running the tests as the test suite affects the actual database. This command can be run at any time if you want to clear your DB. It will repopulate the DB with the initial seed data (clear all existing reservations).