- I wrote pretty much the entire backend routes in /bossMachine/server
- Location of my code: bossMachine/server
- Lines of my code: 437 lines
- Time this project took to complete: 30 hours
- Lots of that time was spent conferring with classmates and looking things up
- The front end (not by me!) is all in React.js
Description of the routes and methods:
- 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.
- 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.
- 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.
Description of the methods in Node.js
- Takes only the single argument for model name. Returns the array of elements in the database or
nullif an invalid argument is supplied
- Takes the model name argument and a second string argument representing the unique ID of the element. Returns the instance with valid inputs and
-1with an invalid id.
- Takes the model name argument and a second argument which is an object with the key-value pairs of the new instance.
.idproperties to the instances. It does not check to make sure that valid inputs are supplied, so you will have to add those checks to your routes if necessary.
addToDatabasewill return the newly-created instance from the database. This function will validate the schema of the instance to create and throw an error if it is invalid.
- Takes the model name argument and a second argument which is an object representing an updated instance. The instance provided must have a valid
.idproperty which will be used to match.
updateInstanceInDatabasewill return the updated instance in the database or
nullwith invalid inputs. This function will validate the schema of the updated instance and throw an error if it is invalid.
- Takes the model name argument and a second string argument representing the unique ID of the element to delete. Returns
trueif the delete occurs properly and
falseif the element is not found.
- Takes only the single argument for model name. Deletes all elements from the proper model and returns a new, empty array. You will only need to use this function for a /api/meetings route.
- id: string
- name: string
- title: string
- salary: number
- id: string
- name: string
- description: string
- numWeeks: number
- weeklyRevenue: number
- time: string
- date: JS
- day: string
- note: string
Notes for me in the future in case I forget the syntax for invoking the Mocha Chai:
To run these tests, first open the root project directory in your terminal. Then run
npm installto install all necessary testing dependencies (you will only need to do this step once). Finally, run
npm run test. You will see a list of tests that ran with information about whether or not each test passed. After this list, you will see more specific output about why each failing test failed. While they are open in a terminal window, these tests will re-run every time you save server files. If you want to quit the testing loop, use
Ctrl + C. If you only want to run the tests once, you can run the
mochacommand in the terminal from your project root directory. `