Back-end weirdness with Boss Machine Cumulative Project

Hey all, I’m coding in server/server.js on this Boss Machine project and it’s not letting me import the necessary functions from server/db.js.

In my server.js file I have:

import { getAllFromDatabase } from './server/db';
import { createMeeting } from './server/db';
import { getFromDatabaseById } from './server/db';
import { addToDatabase } from './server/db';
import { updateInstanceInDatabase } from './server/db';
import { deleteFromDatabasebyId } from './server/db';
import { deleteAllFromDatabase } from './server/db';

and in my db.js file I have:

module.exports = {
  createMeeting,
  getAllFromDatabase,
  getFromDatabaseById,
  addToDatabase,
  updateInstanceInDatabase,
  deleteFromDatabasebyId,
  deleteAllFromDatabase,
};

So… all of that looks to be lining up to me, and those functions do indeed exist in db.js. When I run my server though, I get this error:

13%20AM

It’s recognizing the import syntax as an error? Why would it do that? This exact syntax is used everywhere in the pre-written code of the project. Thoughts?

Also, as another little not-a-huge-deal-but-still-annoying problem, my testing suite is running extremely slow for some reason. Usually when i run npm run test in bash to get the suite going, it evaluats the edge cases almost instantly. This time around, it runs at a crawl. Any idea why this would be happening or how to fix? I’ve restarted multiple times.

Thanks!

1 Like

Shouldn’t you import the same thing you export? You export an object with multiple elements and proceed to import single elements.

export {sayHi, sayBye}; // a list of exported variables
import {sayHi, sayBye} from './say.js';

Doesn’t matter. I just changed my respective code to:

import { createMeeting, getAllFromDatabase, getFromDatabaseById, addToDatabase, updateInstanceInDatabase, deleteFromDatabasebyId, deleteAllFromDatabase } from './server/db';

and

export { createMeeting, getAllFromDatabase, getFromDatabaseById, addToDatabase,
  updateInstanceInDatabase, deleteFromDatabasebyId, deleteAllFromDatabase };

but still was served the error:
13%20AM

Curiously, it does look like const database = require('./server/db') is working, but I have to lead off every function call with database.functionCall()

1 Like