Bootcamp-aggregator-api is an application to aggregate and review bootcamps. This document describes the technologies its build on, how to configure and run the application, it's database schema, those particularities and it's main functionality by an example API request instructions.
The application is build with Node.js, the Express framework, and uses MongoDB as a Database. It also utilizes Mongoose to verify the database operation.
The database schemas resources are:
- Bootcamps
- Course
- Review
- User
Bootcamps have a slug that is created with the package slugify. This slug can be used to display the Bootcamp's url as a path in a frontend application. It is computed before the creation of the Bootcamp using Middleware.
A function in the ReviewModel enforces the constraint that each user can only create one review per Bootcamp by a compound index of the User and Bootcamp collections. This enforcement is done by using the Unique Index Property.
Rename "config/config.env.env" to "config/config.env" and update the values/settings to your own
npm i
# Run in dev mode
npm run dev
# Run in prod mode
npm start
To seed the database with users, Bootcamps, Courses, and Reviews with exemplary data from the "_data" folder, run
# Destroy all data
node seeder -d
# Import all data
node seeder -i
The documentation for this application's full interface can be found on documenter.getpostman.com.
This API-request is a get request that returns all document-instances of the Bootcamp entity in the database. It offers multiple params that can be used to define Bootcamp's exact types that should be returned. The functionality for the results of this API request is implemented in bootcamp_aggregator_api/middleware/advancedResults.js
.
{{URL}}/api/v1/bootcamps?select=<Bootcamp-property1>&sort=[Bootcamp-property]&page=<page-number>&limit=<limit-number>&<Bootcamp-number-property>[<operator>]='<Bootcamp-number-propert>'
select=[Bootcamp-property-n]
- Select the properties that you want to be shown in the query result.
- ```sort=[Bootcamp-property]``
- Select a property to sort for.
page=[page-number]
- Switch between the pages of the API-request-return.
limit=[page-numbr]
- Specify the of number pages e.g. how many Bootcamps the returns per request.
[Bootcamp-number-property][[operator]]=[operator-target]
- Limit the request results to a certain range using the Comparison Query Operators: gt|gte|lt|lte|in
For all available Bootcamps,
- get the name, and if they offer housing,
- sorted by the name of the city,
- limited the shown results to two per page,
- and only show those with a cost of less than or equal to (<=) 10,000$.
{{URL}}/api/v1/bootcamps?select=housing,name&sort=city&limit=2&averageCost[lte]='10000'