Create an API to serve information to a Boss Machine App
- General Info
- Implementation Details
- Testing
- Screenshots
- Technologies Used
- Usage
- Acknowledgements
- Author
In this project, I created an entire API to serve information to a Boss Machine, a unique management application for today's most accomplished (evil) entrepreneurs. I created routes to manage the 'minions', the brilliant 'million dollar ideas', and to handle all the annoying meetings that keep getting added to the busy schedule.
You can view a video demonstration of the final app here: ▶
To complete the project, I needed to complete code on getting the API server up and running:
-
Server Boilerplate
Added key functionality to allow it to run:
- Set up body-parsing middleware
- Set up CORS middleware
- Mount the existing
apiRouterat/api. - Start the server listening on the provided
PORT.
✔ issue #2
-
API Routes
Routes Required
-
/api/minions- GET /api/minions to get an array of all minions.
- POST /api/minions to create a new minion and save it to the database.
- GET /api/minions/:minionId to get a single minion by id.
- PUT /api/minions/:minionId to update a single minion by id.
- DELETE /api/minions/:minionId to delete a single minion by id.
-
/api/ideas- GET /api/ideas to get an array of all ideas.
- POST /api/ideas to create a new idea and save it to the database.
- GET /api/ideas/:ideaId to get a single idea by id.
- PUT /api/ideas/:ideaId to update a single idea by id.
- DELETE /api/ideas/:ideaId to delete a single idea by id.
-
/api/meetings- GET /api/meetings to get an array of all meetings.
- POST /api/meetings to create a new meeting and save it to the database.
- DELETE /api/meetings to delete all meetings from the database.
✔ issue #3
-
-
Working with the 'Database'
Import and use helper functions for working with the database arrays on all routers:
- getAllFromDatabase
- getFromDatabaseById
- addToDatabase
- updateInstanceInDatabase
- deleteFromDatabasebyId
- deleteAllFromDatabase ✔ issue #4
-
Minion:
- id: string
- name: string
- title: string
- salary: number
-
Idea
- id: string
- name: string
- description: string
- numWeeks: number
- weeklyRevenue: number
-
Meeting
- time: string
- date: JS
Dateobject - day: string
- note: string
-
Custom Middleware
I created a custom middleware function
checkMillionDollarIdeathat will come in handy in some /api/ideas routes. This function makes sure that any new or updated ideas are still worth at least one million dollars! The total value of an idea is the product of itsnumWeeksandweeklyRevenueproperties.✔ issue #7
-
Bonus
As a bonus, you may implement routes to allow bosses to add and remove work from their minions' backlogs.
Schema:
- Work:
- id: string
- title: string
- description: string
- hours: number
- minionId: string
- GET /api/minions/:minionId/work to get an array of all work for the specified minon.
- POST /api/minions/:minionId/work to create a new work object and save it to the database.
- PUT /api/minions/:minionId/work/:workId to update a single work by id.
- DELETE /api/minions/:minionId/work/:workId to delete a single work by id.
✔ issue #8
Run
$ npm run test
to test:
- API Routes
- checkMillionDollarIdea middleware
- Bonus
✔ issue #5
- Open the root project directory in your terminal. Run
$ npm install
to install the dependencies of this project and build the front-end application. 2. Once it has finished installing, you can run
$ npm run start
to begin your server. You'll see
Server listening on port 4001
in the terminal.
- To see the application in its initial, non-working state, simply open index.html in a web browser.
- React 18
- React router dom 6
- React Redux 8
- @reduxjs/toolkit
- mocha 10
- chai 4
- @faker-js/faker 8
- express 4
This project comes from the Codecademy's Create a Back-End with JavaScript course.




