This repo contains code examples and files I used while learning backend development.
The app.js
file contains a basic Express app with the following:
- Routes for
/api/v1/tours
and/api/v1/users
- Connecting to a MongoDB database
- Controllers for handling user requests
The models/tourModel.js
file contains a MongoDB Schema definition for a "Tour" model with the following fields:
name
rating
price
The config.env
file contains environment variables for:
- Database URL
- Database password
This is loaded using the dotenv
package.
The API has the following routes:
GET
- Get all toursPOST
- Create a new tour
GET
- Get all usersGET /:id
- Get single userPATCH /:id
- Update userDELETE /:id
- Delete user
The controllers define functions for handling each of these routes.
The public
folder contains basic HTML/CSS templates for a travel app frontend using:
- Mapbox GL
- CSS Grid
- SVG Icons
This provides an example of how the API could be integrated with a frontend application.