Giter Club home page Giter Club logo

mern_stack_course's Issues

Autoincrement models/note.js

End of the controller lesson 4, I noticed that a POST to create a new note to a valid user:
It is leading to an unending request into postman.
I commented the autoincrement plugin, the issue is not there any more :
// noteSchema.plugin(AutoIncrement, {
// inc_field: 'ticket',
// id: 'ticketNums',
// start_seq: 500
// })
is this plugin still supported ?

Active: Boolean

The code block below that is inside the file usersController is missing the active parameter.

I added a sample code below it to be compared to the original code, if you have the time, thanks.

I realized that when I used the first code blocked below this line, I got back the following error after trying to POST a user. ("message": "User validation failed: active: Path active is required.")

But after trying the second code block everything went smoothly including the duplicate validation.
This is my first time of raising an issue, please pardon my crudeness.

const userObject = { username, password: hashedPwd, roles};
const userObject = { username, password: hashedPwd, roles, active: true };

"user" field validation fails in mongoose while typecasting to ObjectId

Error is in lesson_04

I encountered this error and can't get a hold of it.
This happens when trying to call a CREATE operation using POST, and it happens in the createNewNote function in notesController.js .
Full error log in powershell's node server instance:
ValidationError: Note validation failed: user: Cast to ObjectId failed for value <string_value> (type string) at path "user" because of "BSONTypeError" at model.Document.invalidate (<path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\document.js:3050:32) at model.$set (<path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\document.js:1406:12) at model.$set (<path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\document.js:1089:16) at model.Document (<path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\document.js:166:12) at model.Model (<path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\model.js:119:12) at new model (<path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\model.js:4900:15) at <path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\model.js:3107:22 at <path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\model.js:3143:7 at Array.forEach (<anonymous>) at <path>\technotes\Sources\mern_stack_course\lesson_04\node_modules\mongoose\lib\model.js:3142:15

I hid my personal directories under <path>, and the user i was trying to create the new note for under <string_value>.

I first encountered the error in my code, then to troubleshoot i git cloned the repo and tried again using my .env file for the DATABASE_URI variable, and got the same error.

I also triple checked that the user i was trying to assign the note to existed in the DB.

DB connectivity

Usually the DB connect was not working please update the code.

Response Awaited

In the createNewPost codes stop running after line "const note = await Note.create({ user, title, text })" when sending post request using Postman.

CSS not available on every route

Hi Dave, thanks for this wonderful epic course. Just wanted to point out that the following CSS code for 404 page doesn't work on every route such as /users/xyz
<link rel="stylesheet" href="css/style.css" />

This should also include a forward slash as follows:
<link rel="stylesheet" href="/css/style.css" />

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.