Boss Machine Errors

Ok, I give up…
When running ‘’‘npm run test’’’. I am still getting 4 errors -

PUT api/ideas/:ideaId

  1. updates the correct idea and returns it
  2. updates the correct idea and persists to the database

POST api/ideas
3. should add a new idea if all supplied information is correct

checkMillionDollarIdea middleware
4. calls next for ideas that will yield at least one million dollars

My code for ideas.js -

const ideasRouter = require('express').Router();

const {
} = require('./db');

const checkMillionDollarIdea = require('./checkMillionDollarIdea');

ideasRouter.param('id', (req, res, next, id) => {
    const idea = getFromDatabaseById('ideas', id);
    if (idea) {
        req.idea = idea;
    } else {

ideasRouter.get('/', (req, res, next) => {

ideasRouter.get('/:id', (req, res, next) => {
});'/', checkMillionDollarIdea, (req, res, next) => {
    const newIdea = addToDatabase('ideas', req.body);

ideasRouter.put('/:id', checkMillionDollarIdea, (req, res, next) => {
    let updatedIdea = updateInstanceInDatabase('ideas', req.body);

ideasRouter.delete('/:id', (req, res, next) => {
    const deleteIdea = deleteFromDatabasebyId('ideas',;
    if(deleteIdea) {
    } else {

module.exports = ideasRouter;

And for checkMillionDollarIdea.js -

const checkMillionDollarIdea = (req, res, next) => {
    const { numOfWeeks, weeklyRevenue } = req.body;
    const total = Number(numOfWeeks) * Number(weeklyRevenue);

    if (!numOfWeeks || !weeklyRevenue || isNaN(total) || total < 1000000) {
    } else {

// Leave this exports assignment so that the function can be used elsewhere
module.exports = checkMillionDollarIdea;

I would really appreciate it if someone who has completed this project and passed all the tests could see what is missing here. I’ll copy my api.js and server.js files respectively below too.

api.js -

const express = require('express');
const apiRouter = express.Router();

const minionsRouter = require('./minions');
const ideasRouter = require('./ideas');
const meetingsRouter = require('./meetings');

apiRouter.use('/minions', minionsRouter);
apiRouter.use('/ideas', ideasRouter);
apiRouter.use('/meetings', meetingsRouter);

module.exports = apiRouter;

server.js -

const express = require('express');
const app = express();

module.exports = app;

/* Do not change the following line! It is required for testing and allowing
*  the frontend application to interact as planned with the api server
const PORT = process.env.PORT || 4001;

// Add middleware for handling CORS requests from index.html
const cors = require('cors');

// Add middware for parsing request bodies here:
const bodyParser = require('body-parser');

// Mount your existing apiRouter below at the '/api' path.
const apiRouter = require('./server/api');
app.use('/api', apiRouter);

// This conditional is here for testing purposes:
if (!module.parent) { 
  // Add your code to start the server listening at PORT below:
  app.listen(PORT, () => {
    console.log(`Server is listening on port ${PORT}`);

Thank you.


  • 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.

I’m not sure if this is it, but try using the nomenclature :ideaId ?? The test uses that route to test. Check the others?

How is it that you guys aren’t getting all the errors for not checking if the id numbers are not numerical or valid? I had to do many more checks in order to get no errors.

Same issue here for the PUT and POST routes - my code works fine in the app and Postman, the correct instances are created or updated and persist in the database as long as the server’s running, but the tests for persistence don’t pass. No idea why or what to change, as the code itself already works exactly as intended and within the specifications of the project.