This instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Download this repository or clone it using git
git clone https://github.com/vedsingh-fullstack/slot-booking.git
Navigate into the repository
cd slot-booking
Configure a postgres database before running the backend
brew install postgresql@14
Your Postgres server should ideally run as a service on your machine, in order to have it running after system start:
brew services start postgresql@14
After cloning application repository and installing app you will have two additional databases: optisure_test and optisure_development For these databases you will need to create new user so connection will be possible:
psql postgres
CREATE ROLE testuser WITH SUPERUSER;
ALTER ROLE testuser WITH LOGIN;
ALTER ROLE testuser WITH PASSWORD 'admin@123';
rails db:create
rails db:migrate
rails db:seeds
You can start the rails server using the command given below.
bundle exec rails s
And now you can test the api with the following URL
List of available Slots
GET http://localhost:3000/api/v1/available-slots?date=2022-02-02T20:00:00.000Z&interval=15
Create Appointment with selected slots
POST http://localhost:3000/api/v1/appointments
{
start: "2022-02-02T20:00:00.000Z",
end: "2022-02-02T22:30:00.000Z"
}
cd client
npm start
Allow cors for react server in config/initializers/cors.rb
origins 'http://localhost:3001'