Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project-mongo-api -Books - Kathinka #483

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

kathinka
Copy link

Netlify link

view it here

(nb: ignore dist folder)

kathinka added 18 commits May 6, 2024 22:42
…, updated error messages, rewrote the endpoints to use async/await
…ameters function to pagination.js and used it where it seemed to be handy in selected routes.
… the server will restart on its own if an unhandledRejection or uncaughtException shuts down my server
Copy link

@AntonellaMorittu AntonellaMorittu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Kathinka, your code looks well-structured and organised, you pushed yourself creating many endpoints and they all work well. The api meets the requirements and also goes beyond using solutions not even suggested in our course material, impressive! ⭐


// Define the schema for the Book model
const BookSchema = new Schema({
bookID: Number,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove bookId from the Schema: Mongoose automatically assigns a unique _id field to each document, so you don't need to define the field in your schema, you can even remove it from the data object :)

Comment on lines +26 to +40
class ValidationError extends Error {
constructor(message) {
super(message);
this.name = "ValidationError";
this.status = 400;
}
}

class NotFoundError extends Error {
constructor(message) {
super(message);
this.name = "NotFoundError";
this.status = 404;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom error classes is a great way to handle specific error types in your application and keep the code DRY!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants