This is the development repo for the API used by 42KLs Booking System. It is written with the following frameworks:
- Nodejs
- Expressjs
- Mongoosejs
And it communicates with a MongoDB database.
Before cloning the repo, make sure you have installed the following on your machine.
- Nodejs
- MongoDB community edition (Remember to launch)
- Git CLI
- Postman (For testing the API)
- MongoDB compass (Database GUI)
The installation process for the Programs above are quite straightforward for all OSes, the default settings for all of them will do.
To test your MongoDB is correctly installed, launch your MongoDB Compass and you should see something like this :
And what you are going to do now is to connect to the MongoDB database that you just launched after installing. It is hosted on localhost and the port is 27017 by default.
- To connect, Click on new connection.
- Paste
mongodb://localhost:27017/42klbooking
into the prompt - If no error occurs, viola! You've connected to your own MongoDB database.
- To test Nodejs, run
node -v
in any terminal. It should show the version - To test Git, run
git --version
in any terminal. It should show the version.
The following steps are important, as the set up the environment for you to run and test the API. Run the following commands in your working directory
git clone https://github.com/neosizzle/42KL-booking-API.git
npm install
(Downloads and installs the frameworks / packages needed for the API)touch .env
- Copy all contents from
.env.example
to.env
. Those are our environment variables. It would be different for every machine. - In the second line, replace it with
MONGODB_URL=mongodb://localhost:27017/42klbooking
. If you are using another mongoDB provider, paste your own connection string instead. npm run start
to start the program.
If you want to populte your data with dummy values beforehand, run npm run seed
- Launch Postman.
- Click the Import button beside the big orange New at the top left.
- Click on the Link tab and paste the following:
https://www.getpostman.com/collections/272a46b1d4ccbc7b390b
- You should see a bunch of requests in the collection, feel free to tinker around and discover what they do when you send those requests.
GET /
Returns a very generic welcome messageGET /bookings
Returns all the bookings that are created in the systemGET /bookings/:id
Returns the booking detail which has obejctID:id
GET /seats
Returns all the seats that are created in the systemGET /users
Returns all the users that are created in the systemGET /users/:name
Returns the user which has intra username:name
POST /users
Adds a user to the system. Request body required.POST /bookings
Adds a booking to the system. Request body required.POST /seats
Adds a seat to the system. Request body required.
Some elements might still be unstable, please to tell me if something goes wrong!
Explanation on how stuff works coming soon!