From e7de8328bb4191c1478d88eb410b8b78bebf54e6 Mon Sep 17 00:00:00 2001 From: Nishant Kumar Giri Date: Thu, 21 Oct 2021 05:31:56 +0530 Subject: [PATCH 1/4] changed test file name: /src/resources/item/__tests__/ --- .../{item.controllers.spec..js => item.controllers.spec.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/resources/item/__tests__/{item.controllers.spec..js => item.controllers.spec.js} (100%) diff --git a/src/resources/item/__tests__/item.controllers.spec..js b/src/resources/item/__tests__/item.controllers.spec.js similarity index 100% rename from src/resources/item/__tests__/item.controllers.spec..js rename to src/resources/item/__tests__/item.controllers.spec.js From 579fe55034c7842a75f4c9d947aabb15f4d3500b Mon Sep 17 00:00:00 2001 From: Nishant Kumar Giri Date: Thu, 21 Oct 2021 10:06:37 +0530 Subject: [PATCH 2/4] README.md : fixed typos --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f5562bc7..ceac2e0c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ - [Resources](#resources) - [Course](#course) -- [Exercises](#excercises) +- [Exercises](#exercises) - [Hello world Express](#hello-world-express) - [Routing](#routing) - [Create Schemas](#create-schemas) @@ -18,13 +18,13 @@ * [MongoDB](https://www.mongodb.com/) ## Course -This course has two parts, slides and excercises. The slides describe the excerices in detail. Each excercise has a starting branch and solution branch. Example `lesson-1` and `lesson-1-solution`. +This course has two parts, slides and exercises. The slides describe the exercises in detail. Each exercise has a starting branch and solution branch. Example `lesson-1` and `lesson-1-solution`. ## Exercises ### Hello world Express * branch - `lesson-1` In this lesson you'll be creating a simple Express based API in node, just to get your feet wet. -- [ ] install dependencies with yarn (prefered for version locking) or npm +- [ ] install dependencies with yarn (preferred for version locking) or npm - [ ] create a route that sends back some json - [ ] create a route that accepts json and logs it - [ ] start the server @@ -33,9 +33,9 @@ In this lesson you'll be creating a simple Express based API in node, just to ge * branch - `lesson-2` * test command - `yarn test-routes` or `npm run test-routes` -This exercise will have you creating routes and sub routers for our soon the be DB resources using Express routing and routers +This exercise will have you creating routers and sub routes for our soon to be DB resources using Express routing and routers - [ ] create a router for the Item resource -- [ ] create full crud routes and create placeholder controllers +- [ ] create full CRUD routes and create placeholder controllers - [ ] mount router on the root server - [ ] ensure all tests pass by running test command @@ -43,12 +43,12 @@ This exercise will have you creating routes and sub routers for our soon the be * branch - `lesson-3` * test command - `yarn test-models` or `npm run test-models` -In this exercise, you'll be taking what you learned about Mongoose and MongoDb to create a schema and model for the Item resource. +In this exercise, you'll be taking what you learned about Mongoose and MongoDB to create a schema and model for the Item resource. - [ ] create a schema for the item resource - [ ] add the correct fields (look at test) - [ ] add the correct validations (look at test) -- [ ] *extra* add compund index to ensure all tasks in a list have unique names +- [ ] *extra* add compound index to ensure all tasks in a list have unique names - [ ] ensure all tests pass by running test command ### Controllers @@ -58,19 +58,19 @@ In this exercise, you'll be taking what you learned about Mongoose and MongoDb t So far we have routes and models. Now we need to hook our routes up to our models so we can perfom CRUD on the models based on the routes + verbs. That's exactly what controllers do. - [ ] create CRUD resolvers in `utils/crud.js` -- [ ] create controllers for the Item resources using the base crud resolvers +- [ ] create controllers for the Item resources using the base CRUD resolvers - [ ] ensure all tests pass by running test command ### Authentication * branch - `lesson-5` * test command - `yarn test-auth` or `npm run test-auth` -In this exercise you'll be locking down our API using JWT's. +In this exercise you'll be locking down our API using JWT(JSON Web Token). - [ ] create a signup controller - [ ] create a signin controller -- [ ] create a protect middlware to lock down API routes +- [ ] create a protect middleware to lock down API routes - [ ] ensure all tests pass by running test command ### Testing -THe other resources don't have any test, go ahead and write some! +The other resources don't have any test, go ahead and write some! From 86b3e5ae517197f898b0030e71473fa8445967b0 Mon Sep 17 00:00:00 2001 From: Nishant Kumar Giri Date: Fri, 22 Oct 2021 00:47:53 +0530 Subject: [PATCH 3/4] CRUD Test: getOne - changed status code from 400 to 404 (if doc not found) --- src/utils/__tests__/crud.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/__tests__/crud.spec.js b/src/utils/__tests__/crud.spec.js index 5e5b79ca..a988e92d 100644 --- a/src/utils/__tests__/crud.spec.js +++ b/src/utils/__tests__/crud.spec.js @@ -49,7 +49,7 @@ describe('crud controllers', () => { const res = { status(status) { - expect(status).toBe(400) + expect(status).toBe(404) return this }, end() { From 616d1d55886d68bd8c5f7cbe9711a66bab94aabd Mon Sep 17 00:00:00 2001 From: Nishant Kumar Giri Date: Fri, 22 Oct 2021 05:38:45 +0530 Subject: [PATCH 4/4] typo inside auth test --- src/utils/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/auth.js b/src/utils/auth.js index e4030c7f..a6c5c507 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -35,7 +35,7 @@ export const signin = async (req, res) => { return res.status(400).send({ message: 'need email and password' }) } - const invalid = { message: 'Invalid email and passoword combination' } + const invalid = { message: 'Invalid email and password combination' } try { const user = await User.findOne({ email: req.body.email })