Boss Machine Project tests fail

Hello Codeacademy Community,

I recently started with the Boss Machine project and the provided tests fail. I think at least some of my routes should be okay, but maybe I mounted the router wrong (I used both, the apiRouter and const app). I tried to read through the lessons and visited some documentation websites, but I couldn’t really figure out what’s wrong. Do you have an idea? Thanks!

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

//require and use bodyParser
var bodyParser = require('body-parser')
app.use(bodyParser.json())

//require and use cors package
var cors = require('cors')
app.use(cors())

//define port
const PORT = process.env.PORT || 4001;

//mount router to /api
app.use('/api', apiRouter)

//import db functions
const { 
    createMeeting,
    getAllFromDatabase,
    getFromDatabaseById,
    addToDatabase,
    updateInstanceInDatabase,
    deleteFromDatabasebyId,
    deleteAllFromDatabase,
 } = require('./db');

//define minion routes
//get all minions
apiRouter.get('/minions', (req, res, next) => {
    let minionsarray = getAllFromDatabase('minions')
    res.status(200).send(minionsarray);
});

//get minion by id
apiRouter.get('/minions/:id', (req, res, next, id) => {
    var checkminionsvalidity = isValidMinion(id)
    if(checkminionsvalidity){
        let getMinionById = getFromDatabaseById('minions', id)
        res.status(200).send(getMinionById)
    }
    else{res.status(400).send()}
});

//post new minions
apiRouter.post('/minions', (req, res, next, id) => {
    var checkminionsvalidity = isValidMinion(id)
    if(checkminionsvalidity){
    let newminion = addToDatabase('minions', req.body)
    res.status(200).send(newminion)}
    else{res.status(400).send()}
});


//update minions by id
apiRouter.put('/minions/:id', (req, res, next, id) => {
    var checkminionsvalidity = isValidMinion(id)
    if (checkminionsvalidity){
        let updateMinionById = updateInstanceInDatabase('minions', req.body)
        res.status(200).send(updateMinionById);}
    else {res.status(400).send()}
    });

//delete minions by id
apiRouter.delete('/minions/:id', (req, res, next, id) => {
    var checkminionsvalidity = isValidMinion(id)
    if (checkminionsvalidity){
        let reducedminions = deleteFromDatabasebyId(id)
        res.status(200).send(reducedminions);}
    else {res.status(400).send();}
    })

//define ideas routes
//get all ideas 
apiRouter.get('/ideas', (req, res, next) => {
    let ideasArray = findDataArrayByName('ideas')
    res.status(200).send(ideasArray);
});

//define meeting routes
//get all meetings
apiRouter.get('/meetings', (req, res, next) => {
    let meetingsArray = findDataArrayByName('meetings')
    res.status(200).send(meetingsArray);
});


//active server
app.listen(PORT)
module.exports = apiRouter;

Realized I used some functions I didn’t import yet. Fixed this, but still tests fail.

Today I peaked at the solution and had to admit, that I did several mistakes. I probably didn’t read the assigment correctly and didn’t understand the concept of api/routing well enough to solve this project.
Main mistakes:
Requiring the body-parser and cors package, mounting the router to /api and starting the server had to happen in a different folder and file (server.js).
Further, the sub-routers needed to be set up in different files.

At least I could reuse some of my routes.