From 5d33d6c25fb3083ecafd82d6a95cc6b579453c7e Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 03:42:22 -0700 Subject: [PATCH 01/25] initial --- .eslintrc.js | 22 + .gitignore | 118 +++ .history/README_20211029032535.md | 153 +++ .history/README_20211029032650.md | 153 +++ .history/README_20211029032651.md | 153 +++ .history/README_20211029032906.md | 153 +++ .history/README_20211029032908.md | 153 +++ .history/README_20211029032909.md | 153 +++ .history/README_20211029032913.md | 153 +++ .history/README_20211029032915.md | 153 +++ README.md | 12 +- api/server.js | 7 +- index.js | 8 + package-lock.json | 1570 ++++++++++++++++++++++++++++- package.json | 7 +- 15 files changed, 2958 insertions(+), 10 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .history/README_20211029032535.md create mode 100644 .history/README_20211029032650.md create mode 100644 .history/README_20211029032651.md create mode 100644 .history/README_20211029032906.md create mode 100644 .history/README_20211029032908.md create mode 100644 .history/README_20211029032909.md create mode 100644 .history/README_20211029032913.md create mode 100644 .history/README_20211029032915.md diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000..74e62fd59f --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,22 @@ +module.exports = { + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended" + ], + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 13, + "sourceType": "module" + }, + "plugins": [ + "react" + ], + "rules": { + } +}; diff --git a/.gitignore b/.gitignore index 09b3c36e30..01210427c5 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,121 @@ typings/ # databases *.db3 +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test +.env.production + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/.history/README_20211029032535.md b/.history/README_20211029032535.md new file mode 100644 index 0000000000..6881baf133 --- /dev/null +++ b/.history/README_20211029032535.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [ ] Run `npm install` to install your dependencies. +- [ ] Run tests locally executing `npm test`. +- [ ] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [ ] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [ ] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [ ] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [ ] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029032650.md b/.history/README_20211029032650.md new file mode 100644 index 0000000000..9996347461 --- /dev/null +++ b/.history/README_20211029032650.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x ] Run tests locally executing `npm test`. +- [ ] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [ ] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [ ] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [ ] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [ ] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029032651.md b/.history/README_20211029032651.md new file mode 100644 index 0000000000..b791694408 --- /dev/null +++ b/.history/README_20211029032651.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [ ] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [ ] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [ ] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [ ] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029032906.md b/.history/README_20211029032906.md new file mode 100644 index 0000000000..ddb2ba9021 --- /dev/null +++ b/.history/README_20211029032906.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x ] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [ ] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [ ] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [ ] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029032908.md b/.history/README_20211029032908.md new file mode 100644 index 0000000000..369ad1f875 --- /dev/null +++ b/.history/README_20211029032908.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x ] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x ] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [ ] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [ ] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029032909.md b/.history/README_20211029032909.md new file mode 100644 index 0000000000..23f09b8283 --- /dev/null +++ b/.history/README_20211029032909.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x ] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x ] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x ] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [ ] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029032913.md b/.history/README_20211029032913.md new file mode 100644 index 0000000000..0d9a58c1c9 --- /dev/null +++ b/.history/README_20211029032913.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x ] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x ] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [ ] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029032915.md b/.history/README_20211029032915.md new file mode 100644 index 0000000000..13a73418e8 --- /dev/null +++ b/.history/README_20211029032915.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [ ] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/README.md b/README.md index 6881baf133..13a73418e8 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ In meeting the minimum viable product (MVP) specifications listed below, your pr ### Task 1: Project Set Up -- [ ] Run `npm install` to install your dependencies. -- [ ] Run tests locally executing `npm test`. -- [ ] Reset the database to its original state executing `npm run resetdb`. +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. ### Task 2: Project Requirements (MVP) @@ -31,9 +31,9 @@ Your finished project must include all of the following requirements: A _"test"_ script already exists you can use to run tests against your code. A _"resetdb"_ script exists that allows you to reset the database to its original state. -- [ ] Write an _npm script_ named _"start"_ that uses `node` to run the API server. -- [ ] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. -- [ ] Install _nodemon_ as a development dependency that would not be used in production. +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. #### Environment Variables diff --git a/api/server.js b/api/server.js index bbee0934a2..c83c736fdb 100644 --- a/api/server.js +++ b/api/server.js @@ -1,5 +1,10 @@ -const express = require('express'); +const express = require("express"); const server = express(); +server.use(express.json()); + +server.get("/", (req, res) => { + res.status(200).json({ message: "Hello world" }); +}); // Configure your server here // Build your actions router in /api/actions/actions-router.js diff --git a/index.js b/index.js index 4cf807118d..834af0722a 100644 --- a/index.js +++ b/index.js @@ -12,3 +12,11 @@ I need this code, but don't know where, perhaps should make some middleware, don Pull your server into this file and start it! */ +require("dotenv").config(); +const server = require("./api/server"); +const PORT = process.env.PORT || 5000; + +server.listen(PORT, () => { + console.log("======================================"); + console.log(`listening on port ${PORT}`); +}); diff --git a/package-lock.json b/package-lock.json index 855865eefd..c229f055cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,9 @@ "version": "0.0.1", "license": "ISC", "dependencies": { - "express": "4.17.1", + "cors": "^2.8.5", + "dotenv": "^10.0.0", + "express": "^4.17.1", "helmet": "4.6.0", "knex": "0.95.11", "sqlite3": "5.0.2" @@ -19,6 +21,7 @@ "eslint": "8.0.1", "jest": "27.3.1", "knex-cleaner": "1.3.1", + "nodemon": "^2.0.14", "supertest": "6.1.6" } }, @@ -993,6 +996,15 @@ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" } }, + "node_modules/@sindresorhus/is": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", + "integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@sinonjs/commons": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", @@ -1011,6 +1023,18 @@ "@sinonjs/commons": "^1.7.0" } }, + "node_modules/@szmarczak/http-timer": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz", + "integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==", + "dev": true, + "dependencies": { + "defer-to-connect": "^1.0.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -1230,6 +1254,38 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ansi-align": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", + "integrity": "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==", + "dev": true, + "dependencies": { + "string-width": "^4.1.0" + } + }, + "node_modules/ansi-align/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-align/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -1498,6 +1554,15 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/block-stream": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", @@ -1549,6 +1614,63 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "node_modules/boxen": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-5.1.2.tgz", + "integrity": "sha512-9gYgQKXx+1nP8mP7CzFyaUARhg7D3n1dF/FnErWmu9l6JvGpNUN278h0aSb+QjoiKSWG+iZ3uHrcqk0qrY9RQQ==", + "dev": true, + "dependencies": { + "ansi-align": "^3.0.0", + "camelcase": "^6.2.0", + "chalk": "^4.1.0", + "cli-boxes": "^2.2.1", + "string-width": "^4.2.2", + "type-fest": "^0.20.2", + "widest-line": "^3.1.0", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/boxen/node_modules/camelcase": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/boxen/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/boxen/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1622,6 +1744,48 @@ "node": ">= 0.8" } }, + "node_modules/cacheable-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", + "integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==", + "dev": true, + "dependencies": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^3.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^4.1.0", + "responselike": "^1.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cacheable-request/node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cacheable-request/node_modules/lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -1694,6 +1858,39 @@ "node": ">=10" } }, + "node_modules/chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", @@ -1711,6 +1908,18 @@ "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "dev": true }, + "node_modules/cli-boxes": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz", + "integrity": "sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -1745,6 +1954,15 @@ "node": ">=8" } }, + "node_modules/clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "dev": true, + "dependencies": { + "mimic-response": "^1.0.0" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -1818,6 +2036,23 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "node_modules/configstore": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-5.0.1.tgz", + "integrity": "sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==", + "dev": true, + "dependencies": { + "dot-prop": "^5.2.0", + "graceful-fs": "^4.1.2", + "make-dir": "^3.0.0", + "unique-string": "^2.0.0", + "write-file-atomic": "^3.0.0", + "xdg-basedir": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", @@ -1875,6 +2110,18 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -1907,6 +2154,15 @@ "node": ">= 8" } }, + "node_modules/crypto-random-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", + "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/cssom": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", @@ -1979,6 +2235,18 @@ "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==", "dev": true }, + "node_modules/decompress-response": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", + "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", + "dev": true, + "dependencies": { + "mimic-response": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -2008,6 +2276,12 @@ "node": ">=0.10.0" } }, + "node_modules/defer-to-connect": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.3.tgz", + "integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==", + "dev": true + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -2097,6 +2371,32 @@ "node": ">=8" } }, + "node_modules/dot-prop": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", + "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", + "dev": true, + "dependencies": { + "is-obj": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, + "node_modules/duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", + "dev": true + }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -2144,6 +2444,15 @@ "node": ">= 0.8" } }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/enquirer": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", @@ -2164,6 +2473,15 @@ "node": ">=6" } }, + "node_modules/escape-goat": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/escape-goat/-/escape-goat-2.1.1.tgz", + "integrity": "sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -2936,6 +3254,30 @@ "node": ">=10.13.0" } }, + "node_modules/global-dirs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-3.0.0.tgz", + "integrity": "sha512-v8ho2DS5RiCjftj1nD9NmnfaOzTdud7RRnVd9kFNOjqZbISlx5DQ+OrTkywgd0dIt7oFCvKetZSHoHcP3sDdiA==", + "dev": true, + "dependencies": { + "ini": "2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/global-dirs/node_modules/ini": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ini/-/ini-2.0.0.tgz", + "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/globals": { "version": "13.11.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", @@ -2951,6 +3293,40 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/got": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", + "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", + "dev": true, + "dependencies": { + "@sindresorhus/is": "^0.14.0", + "@szmarczak/http-timer": "^1.1.2", + "cacheable-request": "^6.0.0", + "decompress-response": "^3.3.0", + "duplexer3": "^0.1.4", + "get-stream": "^4.1.0", + "lowercase-keys": "^1.0.1", + "mimic-response": "^1.0.1", + "p-cancelable": "^1.0.0", + "to-readable-stream": "^1.0.0", + "url-parse-lax": "^3.0.0" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/got/node_modules/get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/graceful-fs": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", @@ -3017,6 +3393,15 @@ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, + "node_modules/has-yarn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/has-yarn/-/has-yarn-2.1.0.tgz", + "integrity": "sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/helmet": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/helmet/-/helmet-4.6.0.tgz", @@ -3043,6 +3428,12 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "node_modules/http-cache-semantics": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "dev": true + }, "node_modules/http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -3129,6 +3520,12 @@ "node": ">= 4" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=", + "dev": true + }, "node_modules/ignore-walk": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.4.tgz", @@ -3153,6 +3550,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/import-lazy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", + "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/import-local": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.3.tgz", @@ -3213,6 +3619,36 @@ "node": ">= 0.10" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-ci": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "dev": true, + "dependencies": { + "ci-info": "^2.0.0" + }, + "bin": { + "is-ci": "bin.js" + } + }, + "node_modules/is-ci/node_modules/ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", + "dev": true + }, "node_modules/is-core-module": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.5.0.tgz", @@ -3265,6 +3701,34 @@ "node": ">=0.10.0" } }, + "node_modules/is-installed-globally": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.4.0.tgz", + "integrity": "sha512-iwGqO3J21aaSkC7jWnHP/difazwS7SFeIqxv6wEtLU8Y5KlzFTjyqcSIT0d8s4+dDhKytsk9PJZ2BkS5eZwQRQ==", + "dev": true, + "dependencies": { + "global-dirs": "^3.0.0", + "is-path-inside": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-npm": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-5.0.0.tgz", + "integrity": "sha512-WW/rQLOazUq+ST/bCAVBp/2oMERWLsR7OrKyt052dNDk4DHcDE0/7QSXITlmi+VBcV13DfIbysG3tZJm5RfdBA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -3274,6 +3738,24 @@ "node": ">=0.12.0" } }, + "node_modules/is-obj": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", + "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", @@ -3298,6 +3780,12 @@ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "devOptional": true }, + "node_modules/is-yarn-global": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz", + "integrity": "sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==", + "dev": true + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -4089,6 +4577,12 @@ "node": ">=4" } }, + "node_modules/json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=", + "dev": true + }, "node_modules/json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -4143,6 +4637,15 @@ "verror": "1.10.0" } }, + "node_modules/keyv": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", + "integrity": "sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.0" + } + }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -4218,6 +4721,18 @@ "node": ">=8" } }, + "node_modules/latest-version": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", + "integrity": "sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA==", + "dev": true, + "dependencies": { + "package-json": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -4263,6 +4778,15 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "node_modules/lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -4387,6 +4911,15 @@ "node": ">=6" } }, + "node_modules/mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -4638,6 +5171,74 @@ "integrity": "sha512-aA87l0flFYMzCHpTM3DERFSYxc6lv/BltdbRTOMZuxZ0cwZCD3mejE5n9vLhSJCN++/eOqr77G1IO5uXxlQYWA==", "dev": true }, + "node_modules/nodemon": { + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.14.tgz", + "integrity": "sha512-frcpDx+PviKEQRSYzwhckuO2zoHcBYLHI754RE9z5h1RGtrngerc04mLpQQCPWBkH/2ObrX7We9YiwVSYZpFJQ==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "chokidar": "^3.2.2", + "debug": "^3.2.6", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.0.4", + "pstree.remy": "^1.1.7", + "semver": "^5.7.1", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.3", + "update-notifier": "^5.1.0" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=8.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/nodemon/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/nodemon/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -4659,6 +5260,15 @@ "node": ">=0.10.0" } }, + "node_modules/normalize-url": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", + "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/npm-bundled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.2.tgz", @@ -4821,6 +5431,15 @@ "os-tmpdir": "^1.0.0" } }, + "node_modules/p-cancelable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", + "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -4857,6 +5476,30 @@ "node": ">=6" } }, + "node_modules/package-json": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.5.0.tgz", + "integrity": "sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==", + "dev": true, + "dependencies": { + "got": "^9.6.0", + "registry-auth-token": "^4.0.0", + "registry-url": "^5.0.0", + "semver": "^6.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/package-json/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -4981,6 +5624,15 @@ "node": ">= 0.8.0" } }, + "node_modules/prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/pretty-format": { "version": "27.3.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.3.1.tgz", @@ -5053,13 +5705,41 @@ "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", "devOptional": true }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "node_modules/punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "devOptional": true, "engines": { - "node": ">=6" + "node": ">=6" + } + }, + "node_modules/pupa": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/pupa/-/pupa-2.1.1.tgz", + "integrity": "sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==", + "dev": true, + "dependencies": { + "escape-goat": "^2.0.0" + }, + "engines": { + "node": ">=8" } }, "node_modules/qs": { @@ -5134,6 +5814,18 @@ "util-deprecate": "~1.0.1" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/rechoir": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.0.tgz", @@ -5157,6 +5849,30 @@ "url": "https://github.com/sponsors/mysticatea" } }, + "node_modules/registry-auth-token": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.1.tgz", + "integrity": "sha512-6gkSb4U6aWJB4SF2ZvLb76yCBjcvufXBqvvEx1HbmKPkutswjW1xNVRY0+daljIYRbogN7O0etYSlbiaEQyMyw==", + "dev": true, + "dependencies": { + "rc": "^1.2.8" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/registry-url": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-5.1.0.tgz", + "integrity": "sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==", + "dev": true, + "dependencies": { + "rc": "^1.2.8" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -5295,6 +6011,15 @@ "node": ">=10" } }, + "node_modules/responselike": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", + "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", + "dev": true, + "dependencies": { + "lowercase-keys": "^1.0.0" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -5352,6 +6077,27 @@ "node": ">=10" } }, + "node_modules/semver-diff": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-3.1.1.tgz", + "integrity": "sha512-GX0Ix/CJcHyB8c4ykpHGIAvLyOwOobtM/8d+TQkAd81/bEjgPHrfba41Vpesr7jX/t8Uh+R3EX9eAS5be+jQYg==", + "dev": true, + "dependencies": { + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/semver-diff/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", @@ -5858,6 +6604,15 @@ "node": ">=4" } }, + "node_modules/to-readable-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", + "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -5878,6 +6633,33 @@ "node": ">=0.6" } }, + "node_modules/touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dev": true, + "dependencies": { + "nopt": "~1.0.10" + }, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/touch/node_modules/nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/tough-cookie": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", @@ -5976,6 +6758,24 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, + "node_modules/unique-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", + "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", + "dev": true, + "dependencies": { + "crypto-random-string": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -5993,6 +6793,34 @@ "node": ">= 0.8" } }, + "node_modules/update-notifier": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-5.1.0.tgz", + "integrity": "sha512-ItnICHbeMh9GqUy31hFPrD1kcuZ3rpxDZbf4KUDavXwS0bW5m7SLbDQpGX3UYr072cbrF5hFUs3r5tUsPwjfHw==", + "dev": true, + "dependencies": { + "boxen": "^5.0.0", + "chalk": "^4.1.0", + "configstore": "^5.0.1", + "has-yarn": "^2.1.0", + "import-lazy": "^2.1.0", + "is-ci": "^2.0.0", + "is-installed-globally": "^0.4.0", + "is-npm": "^5.0.0", + "is-yarn-global": "^0.3.0", + "latest-version": "^5.1.0", + "pupa": "^2.1.1", + "semver": "^7.3.4", + "semver-diff": "^3.1.1", + "xdg-basedir": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/yeoman/update-notifier?sponsor=1" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -6002,6 +6830,18 @@ "punycode": "^2.1.0" } }, + "node_modules/url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", + "dev": true, + "dependencies": { + "prepend-http": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -6157,6 +6997,41 @@ "string-width": "^1.0.2 || 2" } }, + "node_modules/widest-line": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz", + "integrity": "sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==", + "dev": true, + "dependencies": { + "string-width": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/widest-line/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/widest-line/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -6244,6 +7119,15 @@ } } }, + "node_modules/xdg-basedir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", + "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/xml-name-validator": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", @@ -7081,6 +7965,12 @@ "chalk": "^4.0.0" } }, + "@sindresorhus/is": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", + "integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==", + "dev": true + }, "@sinonjs/commons": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", @@ -7099,6 +7989,15 @@ "@sinonjs/commons": "^1.7.0" } }, + "@szmarczak/http-timer": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz", + "integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==", + "dev": true, + "requires": { + "defer-to-connect": "^1.0.1" + } + }, "@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -7290,6 +8189,34 @@ "uri-js": "^4.2.2" } }, + "ansi-align": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", + "integrity": "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==", + "dev": true, + "requires": { + "string-width": "^4.1.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + } + } + }, "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -7502,6 +8429,12 @@ "tweetnacl": "^0.14.3" } }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true + }, "block-stream": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", @@ -7549,6 +8482,47 @@ } } }, + "boxen": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-5.1.2.tgz", + "integrity": "sha512-9gYgQKXx+1nP8mP7CzFyaUARhg7D3n1dF/FnErWmu9l6JvGpNUN278h0aSb+QjoiKSWG+iZ3uHrcqk0qrY9RQQ==", + "dev": true, + "requires": { + "ansi-align": "^3.0.0", + "camelcase": "^6.2.0", + "chalk": "^4.1.0", + "cli-boxes": "^2.2.1", + "string-width": "^4.2.2", + "type-fest": "^0.20.2", + "widest-line": "^3.1.0", + "wrap-ansi": "^7.0.0" + }, + "dependencies": { + "camelcase": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + } + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -7606,6 +8580,38 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, + "cacheable-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", + "integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==", + "dev": true, + "requires": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^3.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^4.1.0", + "responselike": "^1.0.2" + }, + "dependencies": { + "get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true + } + } + }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -7656,6 +8662,33 @@ "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", "dev": true }, + "chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, "chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", @@ -7673,6 +8706,12 @@ "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "dev": true }, + "cli-boxes": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz", + "integrity": "sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw==", + "dev": true + }, "cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -7703,6 +8742,15 @@ } } }, + "clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "dev": true, + "requires": { + "mimic-response": "^1.0.0" + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -7760,6 +8808,20 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "configstore": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-5.0.1.tgz", + "integrity": "sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==", + "dev": true, + "requires": { + "dot-prop": "^5.2.0", + "graceful-fs": "^4.1.2", + "make-dir": "^3.0.0", + "unique-string": "^2.0.0", + "write-file-atomic": "^3.0.0", + "xdg-basedir": "^4.0.0" + } + }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", @@ -7808,6 +8870,15 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, "cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -7828,6 +8899,12 @@ "which": "^2.0.1" } }, + "crypto-random-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", + "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", + "dev": true + }, "cssom": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", @@ -7885,6 +8962,15 @@ "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==", "dev": true }, + "decompress-response": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", + "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", + "dev": true, + "requires": { + "mimic-response": "^1.0.0" + } + }, "dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -7908,6 +8994,12 @@ "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", "dev": true }, + "defer-to-connect": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.3.tgz", + "integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==", + "dev": true + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -7972,6 +9064,26 @@ } } }, + "dot-prop": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", + "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", + "dev": true, + "requires": { + "is-obj": "^2.0.0" + } + }, + "dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" + }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", + "dev": true + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -8010,6 +9122,15 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, "enquirer": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", @@ -8024,6 +9145,12 @@ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" }, + "escape-goat": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/escape-goat/-/escape-goat-2.1.1.tgz", + "integrity": "sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==", + "dev": true + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -8628,6 +9755,23 @@ "is-glob": "^4.0.3" } }, + "global-dirs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-3.0.0.tgz", + "integrity": "sha512-v8ho2DS5RiCjftj1nD9NmnfaOzTdud7RRnVd9kFNOjqZbISlx5DQ+OrTkywgd0dIt7oFCvKetZSHoHcP3sDdiA==", + "dev": true, + "requires": { + "ini": "2.0.0" + }, + "dependencies": { + "ini": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ini/-/ini-2.0.0.tgz", + "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==", + "dev": true + } + } + }, "globals": { "version": "13.11.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", @@ -8637,6 +9781,36 @@ "type-fest": "^0.20.2" } }, + "got": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", + "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", + "dev": true, + "requires": { + "@sindresorhus/is": "^0.14.0", + "@szmarczak/http-timer": "^1.1.2", + "cacheable-request": "^6.0.0", + "decompress-response": "^3.3.0", + "duplexer3": "^0.1.4", + "get-stream": "^4.1.0", + "lowercase-keys": "^1.0.1", + "mimic-response": "^1.0.1", + "p-cancelable": "^1.0.0", + "to-readable-stream": "^1.0.0", + "url-parse-lax": "^3.0.0" + }, + "dependencies": { + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + } + } + }, "graceful-fs": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", @@ -8684,6 +9858,12 @@ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, + "has-yarn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/has-yarn/-/has-yarn-2.1.0.tgz", + "integrity": "sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw==", + "dev": true + }, "helmet": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/helmet/-/helmet-4.6.0.tgz", @@ -8704,6 +9884,12 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "http-cache-semantics": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "dev": true + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -8768,6 +9954,12 @@ "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true }, + "ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=", + "dev": true + }, "ignore-walk": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.4.tgz", @@ -8786,6 +9978,12 @@ "resolve-from": "^4.0.0" } }, + "import-lazy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", + "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", + "dev": true + }, "import-local": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.3.tgz", @@ -8831,6 +10029,32 @@ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-ci": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "dev": true, + "requires": { + "ci-info": "^2.0.0" + }, + "dependencies": { + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", + "dev": true + } + } + }, "is-core-module": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.5.0.tgz", @@ -8868,12 +10092,40 @@ "is-extglob": "^2.1.1" } }, + "is-installed-globally": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.4.0.tgz", + "integrity": "sha512-iwGqO3J21aaSkC7jWnHP/difazwS7SFeIqxv6wEtLU8Y5KlzFTjyqcSIT0d8s4+dDhKytsk9PJZ2BkS5eZwQRQ==", + "dev": true, + "requires": { + "global-dirs": "^3.0.0", + "is-path-inside": "^3.0.2" + } + }, + "is-npm": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-5.0.0.tgz", + "integrity": "sha512-WW/rQLOazUq+ST/bCAVBp/2oMERWLsR7OrKyt052dNDk4DHcDE0/7QSXITlmi+VBcV13DfIbysG3tZJm5RfdBA==", + "dev": true + }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "is-obj": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", + "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", + "dev": true + }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true + }, "is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", @@ -8892,6 +10144,12 @@ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "devOptional": true }, + "is-yarn-global": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz", + "integrity": "sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==", + "dev": true + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -9513,6 +10771,12 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true }, + "json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=", + "dev": true + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -9558,6 +10822,15 @@ "verror": "1.10.0" } }, + "keyv": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", + "integrity": "sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==", + "dev": true, + "requires": { + "json-buffer": "3.0.0" + } + }, "kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -9606,6 +10879,15 @@ "lodash": "^4.17.13" } }, + "latest-version": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", + "integrity": "sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA==", + "dev": true, + "requires": { + "package-json": "^6.3.0" + } + }, "leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -9642,6 +10924,12 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", + "dev": true + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -9732,6 +11020,12 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, + "mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -9942,6 +11236,56 @@ "integrity": "sha512-aA87l0flFYMzCHpTM3DERFSYxc6lv/BltdbRTOMZuxZ0cwZCD3mejE5n9vLhSJCN++/eOqr77G1IO5uXxlQYWA==", "dev": true }, + "nodemon": { + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.14.tgz", + "integrity": "sha512-frcpDx+PviKEQRSYzwhckuO2zoHcBYLHI754RE9z5h1RGtrngerc04mLpQQCPWBkH/2ObrX7We9YiwVSYZpFJQ==", + "dev": true, + "requires": { + "chokidar": "^3.2.2", + "debug": "^3.2.6", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.0.4", + "pstree.remy": "^1.1.7", + "semver": "^5.7.1", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.3", + "update-notifier": "^5.1.0" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -9957,6 +11301,12 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true }, + "normalize-url": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", + "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==", + "dev": true + }, "npm-bundled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.2.tgz", @@ -10086,6 +11436,12 @@ "os-tmpdir": "^1.0.0" } }, + "p-cancelable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", + "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==", + "dev": true + }, "p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -10110,6 +11466,26 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "package-json": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.5.0.tgz", + "integrity": "sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==", + "dev": true, + "requires": { + "got": "^9.6.0", + "registry-auth-token": "^4.0.0", + "registry-url": "^5.0.0", + "semver": "^6.2.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -10204,6 +11580,12 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", + "dev": true + }, "pretty-format": { "version": "27.3.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.3.1.tgz", @@ -10260,12 +11642,37 @@ "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", "devOptional": true }, + "pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "devOptional": true }, + "pupa": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/pupa/-/pupa-2.1.1.tgz", + "integrity": "sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==", + "dev": true, + "requires": { + "escape-goat": "^2.0.0" + } + }, "qs": { "version": "6.7.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", @@ -10325,6 +11732,15 @@ "util-deprecate": "~1.0.1" } }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, "rechoir": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.0.tgz", @@ -10339,6 +11755,24 @@ "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, + "registry-auth-token": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.1.tgz", + "integrity": "sha512-6gkSb4U6aWJB4SF2ZvLb76yCBjcvufXBqvvEx1HbmKPkutswjW1xNVRY0+daljIYRbogN7O0etYSlbiaEQyMyw==", + "dev": true, + "requires": { + "rc": "^1.2.8" + } + }, + "registry-url": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-5.1.0.tgz", + "integrity": "sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==", + "dev": true, + "requires": { + "rc": "^1.2.8" + } + }, "request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -10446,6 +11880,15 @@ "integrity": "sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ==", "dev": true }, + "responselike": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", + "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", + "dev": true, + "requires": { + "lowercase-keys": "^1.0.0" + } + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -10488,6 +11931,23 @@ "lru-cache": "^6.0.0" } }, + "semver-diff": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-3.1.1.tgz", + "integrity": "sha512-GX0Ix/CJcHyB8c4ykpHGIAvLyOwOobtM/8d+TQkAd81/bEjgPHrfba41Vpesr7jX/t8Uh+R3EX9eAS5be+jQYg==", + "dev": true, + "requires": { + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", @@ -10883,6 +12343,12 @@ "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", "dev": true }, + "to-readable-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", + "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==", + "dev": true + }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -10897,6 +12363,26 @@ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" }, + "touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dev": true, + "requires": { + "nopt": "~1.0.10" + }, + "dependencies": { + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "dev": true, + "requires": { + "abbrev": "1" + } + } + } + }, "tough-cookie": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", @@ -10971,6 +12457,21 @@ "is-typedarray": "^1.0.0" } }, + "undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, + "unique-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", + "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", + "dev": true, + "requires": { + "crypto-random-string": "^2.0.0" + } + }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -10982,6 +12483,28 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, + "update-notifier": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-5.1.0.tgz", + "integrity": "sha512-ItnICHbeMh9GqUy31hFPrD1kcuZ3rpxDZbf4KUDavXwS0bW5m7SLbDQpGX3UYr072cbrF5hFUs3r5tUsPwjfHw==", + "dev": true, + "requires": { + "boxen": "^5.0.0", + "chalk": "^4.1.0", + "configstore": "^5.0.1", + "has-yarn": "^2.1.0", + "import-lazy": "^2.1.0", + "is-ci": "^2.0.0", + "is-installed-globally": "^0.4.0", + "is-npm": "^5.0.0", + "is-yarn-global": "^0.3.0", + "latest-version": "^5.1.0", + "pupa": "^2.1.1", + "semver": "^7.3.4", + "semver-diff": "^3.1.1", + "xdg-basedir": "^4.0.0" + } + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -10991,6 +12514,15 @@ "punycode": "^2.1.0" } }, + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", + "dev": true, + "requires": { + "prepend-http": "^2.0.0" + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -11118,6 +12650,34 @@ "string-width": "^1.0.2 || 2" } }, + "widest-line": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz", + "integrity": "sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==", + "dev": true, + "requires": { + "string-width": "^4.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + } + } + }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -11178,6 +12738,12 @@ "dev": true, "requires": {} }, + "xdg-basedir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", + "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", + "dev": true + }, "xml-name-validator": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", diff --git a/package.json b/package.json index 5d7ebecc16..5deaf6f23f 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "0.0.1", "main": "index.js", "scripts": { + "start": "node index.js", + "server": "nodemon index.js", "test": "cross-env NODE_ENV=testing jest --watchAll --verbose --runInBand --silent", "resetdb": "knex migrate:rollback && knex migrate:latest && knex seed:run" }, @@ -11,7 +13,9 @@ "url": "git+https://github.com/LambdaSchool/web-sprint-challenge-build-a-web-api" }, "dependencies": { - "express": "4.17.1", + "cors": "^2.8.5", + "dotenv": "^10.0.0", + "express": "^4.17.1", "helmet": "4.6.0", "knex": "0.95.11", "sqlite3": "5.0.2" @@ -21,6 +25,7 @@ "eslint": "8.0.1", "jest": "27.3.1", "knex-cleaner": "1.3.1", + "nodemon": "^2.0.14", "supertest": "6.1.6" }, "license": "ISC" From 0953e43f69be2d02fd19c6e7dc742165c18f9a72 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 04:10:16 -0700 Subject: [PATCH 02/25] ...progress --- api/actions/actions-router.js | 48 ++++++++++++++++++++++++++++++++ api/projects/projects-router.js | 49 +++++++++++++++++++++++++++++++++ api/server.js | 4 +++ 3 files changed, 101 insertions(+) diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index 84cca1b38f..f80f6ad801 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -1 +1,49 @@ // Write your "actions" router here! +const express = require("express"); +const Action = require("./actions-model"); +// const {} = require("./actions-middlware"); +const router = express.Router(); + +// - [ ] `[GET] /api/actions` +// - Returns an array of actions (or an empty array) as the body of the response. +router.get("/", async (req, res) => { + res.status(100).json({ message: `[GET] /api/actions` }); +}); + +// - [ ] `[GET] /api/actions/:id` +// - Returns an action with the given `id` as the body of the response. +// - If there is no action with the given `id` it responds with a status code 404. +router.get("/:id", async (req, res) => { + res.status(100).json({ message: `[GET] /api/actions/:id` }); +}); + +// - [ ] `[POST] /api/actions` +// - Returns the newly created action as the body of the response. +// - If the request body is missing any of the required fields it responds with a status code 400. +// - When adding an action make sure the `project_id` provided belongs to an existing `project`. +router.post("/", async (req, res) => { + res.status(100).json({ message: `[POST] /api/actions` }); +}); + +// - [ ] `[PUT] /api/actions/:id` +// - Returns the updated action as the body of the response. +// - If there is no action with the given `id` it responds with a status code 404. +// - If the request body is missing any of the required fields it responds with a status code 400. +router.put("/:id", async (req, res) => { + res.status(100).json({ message: `[PUT] /api/actions/:id` }); +}); + +// - [ ] `[DELETE] /api/actions/:id` +// - Returns no response body. +// - If there is no action with the given `id` it responds with a status code 404. +router.delete("/:id", async (req, res) => { + res.status(100).json({ message: `[DELETE] /api/actions/:id` }); +}); + +/* +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + + +*/ + +module.exports = router; diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index b83038115d..fc4ed51594 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -1 +1,50 @@ // Write your "projects" router here! +const express = require("express"); +const Projects = require("./projects-model"); +// const {} = require("./projects-middleware"); +const router = express.Router(); + +// - [ ] `[GET] /api/projects` +// - Returns an array of projects as the body of the response. +// - If there are no projects it responds with an empty array. +router.get("/", async (req, res) => { + res.status(100).json({ message: `[GET] /api/projects` }); +}); + +// - [ ] `[GET] /api/projects/:id` +// - Returns a project with the given `id` as the body of the response. +// - If there is no project with the given `id` it responds with a status code 404. +router.get("/:id", async (req, res) => { + res.status(100).json({ message: `[GET] /api/projects/:id` }); +}); + +// - [ ] `[POST] /api/projects` +// - Returns the newly created project as the body of the response. +// - If the request body is missing any of the required fields it responds with a status code 400. +router.post("/", async (req, res) => { + res.status(100).json({ message: `[POST] /api/projects` }); +}); + +// - [ ] `[PUT] /api/projects/:id` +// - Returns the updated project as the body of the response. +// - If there is no project with the given `id` it responds with a status code 404. +// - If the request body is missing any of the required fields it responds with a status code 400. +router.put("/:id", async (req, res) => { + res.status(100).json({ message: `[PUT] /api/projects/:id` }); +}); + +// - [ ] `[DELETE] /api/projects/:id` +// - Returns no response body. +// - If there is no project with the given `id` it responds with a status code 404. +router.delete("/:id", async (req, res) => { + res.status(100).json({ message: `[DELETE] /api/projects/:id` }); +}); + +// - [ ] `[GET] /api/projects/:id/actions` +// - Returns an array of actions (could be empty) belonging to a project with the given `id`. +// - If there is no project with the given `id` it responds with a status code 404. +router.get("/:id/actions", async (req, res) => { + res.status(100).json({ message: `[GET] /api/projects/:id/actions` }); +}); + +module.exports = router; diff --git a/api/server.js b/api/server.js index c83c736fdb..976b447f56 100644 --- a/api/server.js +++ b/api/server.js @@ -1,10 +1,14 @@ const express = require("express"); +const routerAction = require("./actions/actions-router"); +const routerProject = require("./projects/projects-router"); const server = express(); server.use(express.json()); server.get("/", (req, res) => { res.status(200).json({ message: "Hello world" }); }); +server.use("/api/actions", routerAction); +server.use("/api/projects", routerProject); // Configure your server here // Build your actions router in /api/actions/actions-router.js From 6cd84d562efc2fe7afbbe28563ed70adb04cb358 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 04:14:53 -0700 Subject: [PATCH 03/25] ...progress --- api/actions/actions-router.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index f80f6ad801..6b4ddd9463 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -7,14 +7,14 @@ const router = express.Router(); // - [ ] `[GET] /api/actions` // - Returns an array of actions (or an empty array) as the body of the response. router.get("/", async (req, res) => { - res.status(100).json({ message: `[GET] /api/actions` }); + res.status(200).json({ message: `[GET] /api/actions` }); }); // - [ ] `[GET] /api/actions/:id` // - Returns an action with the given `id` as the body of the response. // - If there is no action with the given `id` it responds with a status code 404. router.get("/:id", async (req, res) => { - res.status(100).json({ message: `[GET] /api/actions/:id` }); + res.status(200).json({ message: `[GET] /api/actions/:id` }); }); // - [ ] `[POST] /api/actions` @@ -22,7 +22,7 @@ router.get("/:id", async (req, res) => { // - If the request body is missing any of the required fields it responds with a status code 400. // - When adding an action make sure the `project_id` provided belongs to an existing `project`. router.post("/", async (req, res) => { - res.status(100).json({ message: `[POST] /api/actions` }); + res.status(201).json({ message: `[POST] /api/actions/` }); }); // - [ ] `[PUT] /api/actions/:id` @@ -30,14 +30,14 @@ router.post("/", async (req, res) => { // - If there is no action with the given `id` it responds with a status code 404. // - If the request body is missing any of the required fields it responds with a status code 400. router.put("/:id", async (req, res) => { - res.status(100).json({ message: `[PUT] /api/actions/:id` }); + res.status(201).json({ message: `[PUT] /api/actions/:id` }); }); // - [ ] `[DELETE] /api/actions/:id` // - Returns no response body. // - If there is no action with the given `id` it responds with a status code 404. router.delete("/:id", async (req, res) => { - res.status(100).json({ message: `[DELETE] /api/actions/:id` }); + res.status(201).json({ message: `[DELETE] /api/actions/:id` }); }); /* From e4f2683579e96f19a2ac10dc5009020f098becd5 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 04:18:51 -0700 Subject: [PATCH 04/25] ...progress --- api/projects/projects-router.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index fc4ed51594..419e337714 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -8,21 +8,21 @@ const router = express.Router(); // - Returns an array of projects as the body of the response. // - If there are no projects it responds with an empty array. router.get("/", async (req, res) => { - res.status(100).json({ message: `[GET] /api/projects` }); + res.status(200).json({ message: `[GET] /api/projects/` }); }); // - [ ] `[GET] /api/projects/:id` // - Returns a project with the given `id` as the body of the response. // - If there is no project with the given `id` it responds with a status code 404. router.get("/:id", async (req, res) => { - res.status(100).json({ message: `[GET] /api/projects/:id` }); + res.status(200).json({ message: `[GET] /api/projects/${req.params.id}` }); }); // - [ ] `[POST] /api/projects` // - Returns the newly created project as the body of the response. // - If the request body is missing any of the required fields it responds with a status code 400. router.post("/", async (req, res) => { - res.status(100).json({ message: `[POST] /api/projects` }); + res.status(201).json({ message: `[POST] /api/projects/` }); }); // - [ ] `[PUT] /api/projects/:id` @@ -30,21 +30,23 @@ router.post("/", async (req, res) => { // - If there is no project with the given `id` it responds with a status code 404. // - If the request body is missing any of the required fields it responds with a status code 400. router.put("/:id", async (req, res) => { - res.status(100).json({ message: `[PUT] /api/projects/:id` }); + res.status(201).json({ message: `[PUT] /api/projects/${req.params.id}` }); }); // - [ ] `[DELETE] /api/projects/:id` // - Returns no response body. // - If there is no project with the given `id` it responds with a status code 404. router.delete("/:id", async (req, res) => { - res.status(100).json({ message: `[DELETE] /api/projects/:id` }); + res.status(201).json({ message: `[DELETE] /api/projects/${req.params.id}` }); }); // - [ ] `[GET] /api/projects/:id/actions` // - Returns an array of actions (could be empty) belonging to a project with the given `id`. // - If there is no project with the given `id` it responds with a status code 404. router.get("/:id/actions", async (req, res) => { - res.status(100).json({ message: `[GET] /api/projects/:id/actions` }); + res + .status(200) + .json({ message: `[GET] /api/projects/${req.params.id}/actions` }); }); module.exports = router; From b4a53b259c2d3960b5785b47fe66cdbd467d605a Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 12:13:28 -0700 Subject: [PATCH 05/25] ...progress --- api/actions/actions-middlware.js | 42 ++++++++++++++++++++++++++++++++ api/actions/actions-model.js | 17 ++++++------- api/actions/actions-router.js | 14 ++++++----- api/projects/projects-router.js | 3 ++- api/server.js | 1 + 5 files changed, 61 insertions(+), 16 deletions(-) diff --git a/api/actions/actions-middlware.js b/api/actions/actions-middlware.js index 83749a06eb..e7da42755d 100644 --- a/api/actions/actions-middlware.js +++ b/api/actions/actions-middlware.js @@ -1 +1,43 @@ +const Action = require("./actions-model"); +const Project = require("../projects/projects-model"); // add middlewares here related to actions +async function validateId(req, res, next) { + console.log("---------validateId middleware"); + const { id } = req.params; + const action = await Action.get(id); + if (!action) { + res.status(404).json({ + message: `${id} not found`, + }); + } else { + req.action = action; + next(); + } +} + +async function validateAction(req, res, next) { + console.log("---------validateAction middleware"); + const { project_id, description, notes } = req.body; + + if ( + !project_id || + typeof project_id === "number" || + !description || + description.trim() === "" || + !notes || + notes.trim() === "" + ) { + res.status(400).json({ + message: "missing required field, project_id, description, or notes", + }); + } else if ((await Project.get(project_id)) !== null) { + res.status(404).json({ + message: "project_id not found", + }); + } else { + req.action = { project_id, description, notes }; + next(); + } +} + +module.exports = { validateId, validateAction }; diff --git a/api/actions/actions-model.js b/api/actions/actions-model.js index dcddde3d10..36000c3cf4 100644 --- a/api/actions/actions-model.js +++ b/api/actions/actions-model.js @@ -1,7 +1,6 @@ // DO NOT MAKE CHANGES TO THIS FILE -const db = require('../../data/dbConfig.js'); -const mappers = require('../../data/helpers/mappers'); - +const db = require("../../data/dbConfig.js"); +const mappers = require("../../data/helpers/mappers"); module.exports = { get, insert, @@ -10,11 +9,11 @@ module.exports = { }; function get(id) { - let query = db('actions'); + let query = db("actions"); if (id) { return query - .where('id', id) + .where("id", id) .first() .then((action) => { if (action) { @@ -31,18 +30,18 @@ function get(id) { } function insert(action) { - return db('actions') + return db("actions") .insert(action) .then(([id]) => get(id)); } function update(id, changes) { - return db('actions') - .where('id', id) + return db("actions") + .where("id", id) .update(changes) .then((count) => (count > 0 ? get(id) : null)); } function remove(id) { - return db('actions').where('id', id).del(); + return db("actions").where("id", id).del(); } diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index 6b4ddd9463..6f1aa70aae 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -1,28 +1,30 @@ // Write your "actions" router here! const express = require("express"); const Action = require("./actions-model"); -// const {} = require("./actions-middlware"); +const { validateId, validateAction } = require("./actions-middlware"); const router = express.Router(); // - [ ] `[GET] /api/actions` // - Returns an array of actions (or an empty array) as the body of the response. router.get("/", async (req, res) => { - res.status(200).json({ message: `[GET] /api/actions` }); + const actions = await Action.get(); + res.status(200).json({ message: "successfully retrieve actions", actions }); }); // - [ ] `[GET] /api/actions/:id` // - Returns an action with the given `id` as the body of the response. // - If there is no action with the given `id` it responds with a status code 404. -router.get("/:id", async (req, res) => { - res.status(200).json({ message: `[GET] /api/actions/:id` }); +router.get("/:id", validateId, async (req, res) => { + res.status(200).json({ action: req.action }); }); // - [ ] `[POST] /api/actions` // - Returns the newly created action as the body of the response. // - If the request body is missing any of the required fields it responds with a status code 400. // - When adding an action make sure the `project_id` provided belongs to an existing `project`. -router.post("/", async (req, res) => { - res.status(201).json({ message: `[POST] /api/actions/` }); +router.post("/", validateId, validateAction, async (req, res) => { + const newAction = await Action.insert(req.action); + res.status(201).json({ newAction }); }); // - [ ] `[PUT] /api/actions/:id` diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index 419e337714..cee6bc8dbf 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -8,7 +8,8 @@ const router = express.Router(); // - Returns an array of projects as the body of the response. // - If there are no projects it responds with an empty array. router.get("/", async (req, res) => { - res.status(200).json({ message: `[GET] /api/projects/` }); + const projects = await Projects.get(); + res.status(200).json({ projects }); }); // - [ ] `[GET] /api/projects/:id` diff --git a/api/server.js b/api/server.js index 976b447f56..26cb946ff4 100644 --- a/api/server.js +++ b/api/server.js @@ -10,6 +10,7 @@ server.get("/", (req, res) => { server.use("/api/actions", routerAction); server.use("/api/projects", routerProject); + // Configure your server here // Build your actions router in /api/actions/actions-router.js // Build your projects router in /api/projects/projects-router.js From 5e4343dc0e2cc11d1efad32de182127c7cd687b5 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 12:16:10 -0700 Subject: [PATCH 06/25] ...progress --- api/actions/actions-middlware.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/actions/actions-middlware.js b/api/actions/actions-middlware.js index e7da42755d..6461933172 100644 --- a/api/actions/actions-middlware.js +++ b/api/actions/actions-middlware.js @@ -30,12 +30,19 @@ async function validateAction(req, res, next) { res.status(400).json({ message: "missing required field, project_id, description, or notes", }); - } else if ((await Project.get(project_id)) !== null) { + } else { + req.action = { project_id, description, notes }; + next(); + } +} + +async function validateProject(req, res, next) { + const { project_id } = req.body; + if ((await Project.get(project_id)) !== null) { res.status(404).json({ message: "project_id not found", }); } else { - req.action = { project_id, description, notes }; next(); } } From 71ec8b1dd8d7e4b05237376b12f60ab6e553463a Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 12:30:03 -0700 Subject: [PATCH 07/25] ...progress --- api/actions/actions-middlware.js | 7 +++-- api/actions/actions-router.js | 50 +++++++++++++++++++------------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/api/actions/actions-middlware.js b/api/actions/actions-middlware.js index 6461933172..9cbe1b5a0e 100644 --- a/api/actions/actions-middlware.js +++ b/api/actions/actions-middlware.js @@ -21,7 +21,7 @@ async function validateAction(req, res, next) { if ( !project_id || - typeof project_id === "number" || + typeof project_id !== "number" || !description || description.trim() === "" || !notes || @@ -38,7 +38,8 @@ async function validateAction(req, res, next) { async function validateProject(req, res, next) { const { project_id } = req.body; - if ((await Project.get(project_id)) !== null) { + const project = await Project.get(project_id); + if (!project) { res.status(404).json({ message: "project_id not found", }); @@ -47,4 +48,4 @@ async function validateProject(req, res, next) { } } -module.exports = { validateId, validateAction }; +module.exports = { validateId, validateAction, validateProject }; diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index 6f1aa70aae..b4982a1ea4 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -1,7 +1,11 @@ // Write your "actions" router here! const express = require("express"); const Action = require("./actions-model"); -const { validateId, validateAction } = require("./actions-middlware"); +const { + validateId, + validateAction, + validateProject, +} = require("./actions-middlware"); const router = express.Router(); // - [ ] `[GET] /api/actions` @@ -22,25 +26,31 @@ router.get("/:id", validateId, async (req, res) => { // - Returns the newly created action as the body of the response. // - If the request body is missing any of the required fields it responds with a status code 400. // - When adding an action make sure the `project_id` provided belongs to an existing `project`. -router.post("/", validateId, validateAction, async (req, res) => { - const newAction = await Action.insert(req.action); - res.status(201).json({ newAction }); -}); - -// - [ ] `[PUT] /api/actions/:id` -// - Returns the updated action as the body of the response. -// - If there is no action with the given `id` it responds with a status code 404. -// - If the request body is missing any of the required fields it responds with a status code 400. -router.put("/:id", async (req, res) => { - res.status(201).json({ message: `[PUT] /api/actions/:id` }); -}); - -// - [ ] `[DELETE] /api/actions/:id` -// - Returns no response body. -// - If there is no action with the given `id` it responds with a status code 404. -router.delete("/:id", async (req, res) => { - res.status(201).json({ message: `[DELETE] /api/actions/:id` }); -}); +router.post( + "/", + validateId, + validateAction, + validateProject, + async (req, res) => { + const newAction = await Action.insert(req.action); + res.status(201).json({ newAction }); + } +); + +// // - [ ] `[PUT] /api/actions/:id` +// // - Returns the updated action as the body of the response. +// // - If there is no action with the given `id` it responds with a status code 404. +// // - If the request body is missing any of the required fields it responds with a status code 400. +// router.put("/:id", async (req, res) => { +// res.status(201).json({ message: `[PUT] /api/actions/:id` }); +// }); + +// // - [ ] `[DELETE] /api/actions/:id` +// // - Returns no response body. +// // - If there is no action with the given `id` it responds with a status code 404. +// router.delete("/:id", async (req, res) => { +// res.status(201).json({ message: `[DELETE] /api/actions/:id` }); +// }); /* Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: From 47673a349a2ccd464c1a4822c4eb3d338fac45b6 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 12:48:03 -0700 Subject: [PATCH 08/25] ...progress --- api/actions/actions-middlware.js | 10 +++++++--- api/actions/actions-router.js | 27 +++++++++++++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/api/actions/actions-middlware.js b/api/actions/actions-middlware.js index 9cbe1b5a0e..4f39d9e35d 100644 --- a/api/actions/actions-middlware.js +++ b/api/actions/actions-middlware.js @@ -15,7 +15,7 @@ async function validateId(req, res, next) { } } -async function validateAction(req, res, next) { +async function validateNewAction(req, res, next) { console.log("---------validateAction middleware"); const { project_id, description, notes } = req.body; @@ -31,7 +31,7 @@ async function validateAction(req, res, next) { message: "missing required field, project_id, description, or notes", }); } else { - req.action = { project_id, description, notes }; + req.newAction = { project_id, description, notes }; next(); } } @@ -48,4 +48,8 @@ async function validateProject(req, res, next) { } } -module.exports = { validateId, validateAction, validateProject }; +module.exports = { + validateId, + validateAction: validateNewAction, + validateProject, +}; diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index b4982a1ea4..ec81e33a33 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -3,7 +3,7 @@ const express = require("express"); const Action = require("./actions-model"); const { validateId, - validateAction, + validateAction: validateNewAction, validateProject, } = require("./actions-middlware"); const router = express.Router(); @@ -29,21 +29,28 @@ router.get("/:id", validateId, async (req, res) => { router.post( "/", validateId, - validateAction, + validateNewAction, validateProject, async (req, res) => { - const newAction = await Action.insert(req.action); + const newAction = await Action.insert(req.newAction); res.status(201).json({ newAction }); } ); -// // - [ ] `[PUT] /api/actions/:id` -// // - Returns the updated action as the body of the response. -// // - If there is no action with the given `id` it responds with a status code 404. -// // - If the request body is missing any of the required fields it responds with a status code 400. -// router.put("/:id", async (req, res) => { -// res.status(201).json({ message: `[PUT] /api/actions/:id` }); -// }); +// - [ ] `[PUT] /api/actions/:id` +// - Returns the updated action as the body of the response. +// - If there is no action with the given `id` it responds with a status code 404. +// - If the request body is missing any of the required fields it responds with a status code 400. +router.put( + "/:id", + validateId, + validateNewAction, + validateProject, + async (req, res) => { + const newAction = await Action.update(req.params.id, req.newAction); + res.status(201).json(newAction); + } +); // // - [ ] `[DELETE] /api/actions/:id` // // - Returns no response body. From 7b19863f916bf00eae474efc6824253cf1a5d55e Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 13:01:00 -0700 Subject: [PATCH 09/25] ...progress --- api/actions/actions-middlware.js | 2 +- api/actions/actions-router.js | 69 +++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/api/actions/actions-middlware.js b/api/actions/actions-middlware.js index 4f39d9e35d..306879486f 100644 --- a/api/actions/actions-middlware.js +++ b/api/actions/actions-middlware.js @@ -50,6 +50,6 @@ async function validateProject(req, res, next) { module.exports = { validateId, - validateAction: validateNewAction, + validateNewAction, validateProject, }; diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index ec81e33a33..126938f07d 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -3,23 +3,31 @@ const express = require("express"); const Action = require("./actions-model"); const { validateId, - validateAction: validateNewAction, + validateNewAction, validateProject, } = require("./actions-middlware"); const router = express.Router(); // - [ ] `[GET] /api/actions` // - Returns an array of actions (or an empty array) as the body of the response. -router.get("/", async (req, res) => { - const actions = await Action.get(); - res.status(200).json({ message: "successfully retrieve actions", actions }); +router.get("/", async (req, res, next) => { + try { + const actions = await Action.get(); + res.status(200).json({ message: "successfully retrieve actions", actions }); + } catch (err) { + next(err); + } }); // - [ ] `[GET] /api/actions/:id` // - Returns an action with the given `id` as the body of the response. // - If there is no action with the given `id` it responds with a status code 404. -router.get("/:id", validateId, async (req, res) => { - res.status(200).json({ action: req.action }); +router.get("/:id", validateId, async (req, res, next) => { + try { + res.status(200).json({ action: req.action }); + } catch (err) { + next(err); + } }); // - [ ] `[POST] /api/actions` @@ -31,9 +39,13 @@ router.post( validateId, validateNewAction, validateProject, - async (req, res) => { - const newAction = await Action.insert(req.newAction); - res.status(201).json({ newAction }); + async (req, res, next) => { + try { + const newAction = await Action.insert(req.newAction); + res.status(201).json({ newAction }); + } catch (err) { + next(err); + } } ); @@ -46,23 +58,34 @@ router.put( validateId, validateNewAction, validateProject, - async (req, res) => { - const newAction = await Action.update(req.params.id, req.newAction); - res.status(201).json(newAction); + async (req, res, next) => { + try { + const newAction = await Action.update(req.params.id, req.newAction); + res.status(201).json(newAction); + } catch (err) { + next(err); + } } ); -// // - [ ] `[DELETE] /api/actions/:id` -// // - Returns no response body. -// // - If there is no action with the given `id` it responds with a status code 404. -// router.delete("/:id", async (req, res) => { -// res.status(201).json({ message: `[DELETE] /api/actions/:id` }); -// }); - -/* -Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: - +// - [ ] `[DELETE] /api/actions/:id` +// - Returns no response body. +// - If there is no action with the given `id` it responds with a status code 404. +router.delete("/:id", validateId, async (req, res, next) => { + try { + throw new Error("error"); + const numberOfDeletedItem = await Action.remove(req.params.id); + res.status(201).json(`deleted ${numberOfDeletedItem} action`); + } catch (err) { + next(err); + } +}); -*/ +router.use((err, req, res, next) => { + res.status(err.status || 500).json({ + custMessage: "Error Occured retrieving /api/actions path", + message: err.message, + }); +}); module.exports = router; From ec94bd1431c814c0e90e2ff32fc98a3d4199b6a5 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 13:04:00 -0700 Subject: [PATCH 10/25] ...progress --- api/actions/actions-router.js | 1 - 1 file changed, 1 deletion(-) diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index 126938f07d..f297c36a43 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -73,7 +73,6 @@ router.put( // - If there is no action with the given `id` it responds with a status code 404. router.delete("/:id", validateId, async (req, res, next) => { try { - throw new Error("error"); const numberOfDeletedItem = await Action.remove(req.params.id); res.status(201).json(`deleted ${numberOfDeletedItem} action`); } catch (err) { From b85643dbe908302e3c820cc79741e6ac6b00bf87 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 13:14:20 -0700 Subject: [PATCH 11/25] ...progress --- api/actions/actions-router.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index f297c36a43..518460e78c 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -24,7 +24,7 @@ router.get("/", async (req, res, next) => { // - If there is no action with the given `id` it responds with a status code 404. router.get("/:id", validateId, async (req, res, next) => { try { - res.status(200).json({ action: req.action }); + res.status(200).json({ ...req.action }); } catch (err) { next(err); } @@ -42,7 +42,7 @@ router.post( async (req, res, next) => { try { const newAction = await Action.insert(req.newAction); - res.status(201).json({ newAction }); + res.status(201).json({ ...newAction }); } catch (err) { next(err); } From 1ae661aec47df5eb017865c3b4880ff53debc58b Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 13:23:09 -0700 Subject: [PATCH 12/25] ...progress --- api/actions/actions-middlware.js | 4 ++-- api/actions/actions-router.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/actions/actions-middlware.js b/api/actions/actions-middlware.js index 306879486f..a3aeec9840 100644 --- a/api/actions/actions-middlware.js +++ b/api/actions/actions-middlware.js @@ -17,7 +17,7 @@ async function validateId(req, res, next) { async function validateNewAction(req, res, next) { console.log("---------validateAction middleware"); - const { project_id, description, notes } = req.body; + const { project_id, description, notes, completed } = req.body; if ( !project_id || @@ -31,7 +31,7 @@ async function validateNewAction(req, res, next) { message: "missing required field, project_id, description, or notes", }); } else { - req.newAction = { project_id, description, notes }; + req.newAction = { project_id, description, notes, completed }; next(); } } diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index 518460e78c..3434ab35de 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -13,7 +13,7 @@ const router = express.Router(); router.get("/", async (req, res, next) => { try { const actions = await Action.get(); - res.status(200).json({ message: "successfully retrieve actions", actions }); + res.status(200).json([...actions]); } catch (err) { next(err); } @@ -61,7 +61,7 @@ router.put( async (req, res, next) => { try { const newAction = await Action.update(req.params.id, req.newAction); - res.status(201).json(newAction); + res.status(201).json(...newAction); } catch (err) { next(err); } From fe28728960c15a64d75a6f1aef71e8d7f933a601 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 13:29:02 -0700 Subject: [PATCH 13/25] ...progress --- api/actions/actions-router.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index 3434ab35de..b6b998ca38 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -81,7 +81,8 @@ router.delete("/:id", validateId, async (req, res, next) => { }); router.use((err, req, res, next) => { - res.status(err.status || 500).json({ + res.status(500).json({ + // res.status(err.status || 500).json({ custMessage: "Error Occured retrieving /api/actions path", message: err.message, }); From 2bfca45dcf9e7e9c00e4f275a32f7f3a559a3d66 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 13:31:06 -0700 Subject: [PATCH 14/25] ...completed action api --- api/actions/actions-router.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index b6b998ca38..4f84a9e124 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -61,7 +61,7 @@ router.put( async (req, res, next) => { try { const newAction = await Action.update(req.params.id, req.newAction); - res.status(201).json(...newAction); + res.status(201).json({ ...newAction }); } catch (err) { next(err); } @@ -81,8 +81,7 @@ router.delete("/:id", validateId, async (req, res, next) => { }); router.use((err, req, res, next) => { - res.status(500).json({ - // res.status(err.status || 500).json({ + res.status(err.status || 500).json({ custMessage: "Error Occured retrieving /api/actions path", message: err.message, }); From beccae87546497113b9860d2cb5a6690d45cd573 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 13:34:55 -0700 Subject: [PATCH 15/25] ...progress --- api/actions/actions-middlware.js | 2 +- api/actions/actions-router.js | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/api/actions/actions-middlware.js b/api/actions/actions-middlware.js index a3aeec9840..09c4e1d0e1 100644 --- a/api/actions/actions-middlware.js +++ b/api/actions/actions-middlware.js @@ -1,6 +1,6 @@ const Action = require("./actions-model"); const Project = require("../projects/projects-model"); -// add middlewares here related to actions + async function validateId(req, res, next) { console.log("---------validateId middleware"); const { id } = req.params; diff --git a/api/actions/actions-router.js b/api/actions/actions-router.js index 4f84a9e124..ef9cc7e98b 100644 --- a/api/actions/actions-router.js +++ b/api/actions/actions-router.js @@ -1,4 +1,3 @@ -// Write your "actions" router here! const express = require("express"); const Action = require("./actions-model"); const { @@ -8,8 +7,6 @@ const { } = require("./actions-middlware"); const router = express.Router(); -// - [ ] `[GET] /api/actions` -// - Returns an array of actions (or an empty array) as the body of the response. router.get("/", async (req, res, next) => { try { const actions = await Action.get(); @@ -19,9 +16,6 @@ router.get("/", async (req, res, next) => { } }); -// - [ ] `[GET] /api/actions/:id` -// - Returns an action with the given `id` as the body of the response. -// - If there is no action with the given `id` it responds with a status code 404. router.get("/:id", validateId, async (req, res, next) => { try { res.status(200).json({ ...req.action }); @@ -30,10 +24,6 @@ router.get("/:id", validateId, async (req, res, next) => { } }); -// - [ ] `[POST] /api/actions` -// - Returns the newly created action as the body of the response. -// - If the request body is missing any of the required fields it responds with a status code 400. -// - When adding an action make sure the `project_id` provided belongs to an existing `project`. router.post( "/", validateId, @@ -49,10 +39,6 @@ router.post( } ); -// - [ ] `[PUT] /api/actions/:id` -// - Returns the updated action as the body of the response. -// - If there is no action with the given `id` it responds with a status code 404. -// - If the request body is missing any of the required fields it responds with a status code 400. router.put( "/:id", validateId, @@ -68,9 +54,6 @@ router.put( } ); -// - [ ] `[DELETE] /api/actions/:id` -// - Returns no response body. -// - If there is no action with the given `id` it responds with a status code 404. router.delete("/:id", validateId, async (req, res, next) => { try { const numberOfDeletedItem = await Action.remove(req.params.id); From 4f32cee6c6132d64f2a75ab858a4b3a3e1b982e5 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 14:11:13 -0700 Subject: [PATCH 16/25] ...progress --- api/projects/projects-middleware.js | 16 +++++++++ api/projects/projects-model.js | 12 +++---- api/projects/projects-router.js | 54 +++++++++++++++++++++++------ 3 files changed, 65 insertions(+), 17 deletions(-) diff --git a/api/projects/projects-middleware.js b/api/projects/projects-middleware.js index 71cac557e5..3a8aa786ba 100644 --- a/api/projects/projects-middleware.js +++ b/api/projects/projects-middleware.js @@ -1 +1,17 @@ // add middlewares here related to projects +const Project = require("./projects-model"); + +async function validateId(req, res, next) { + const { id } = req.params; + const project = await Project.get(id); + if (!project) { + res.status(404).json({ + message: `project ${id} not found`, + }); + } else { + req.project = project; + next(); + } +} + +module.exports = { validateId }; diff --git a/api/projects/projects-model.js b/api/projects/projects-model.js index e641c92ec3..0ac03b6c77 100644 --- a/api/projects/projects-model.js +++ b/api/projects/projects-model.js @@ -1,5 +1,5 @@ // DO NOT MAKE CHANGES TO THIS FILE -const db = require("../../data/dbConfig.js"); +const Project = require("../../data/dbConfig.js"); const mappers = require('../../data/helpers/mappers'); module.exports = { @@ -11,7 +11,7 @@ module.exports = { }; function get(id) { - let query = db("projects as p"); + let query = Project("projects as p"); if (id) { query.where("p.id", id).first(); @@ -37,26 +37,26 @@ function get(id) { } function insert(project) { - return db("projects") + return Project("projects") .insert(project) .then(([id]) => get(id)); } function update(id, changes) { - return db("projects") + return Project("projects") .where("id", id) .update(changes) .then(count => (count > 0 ? get(id) : null)); } function remove(id) { - return db("projects") + return Project("projects") .where("id", id) .del(); } function getProjectActions(projectId) { - return db("actions") + return Project("actions") .where("project_id", projectId) .then(actions => actions.map(action => mappers.actionToBody(action))); } diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index cee6bc8dbf..97eb75ba39 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -1,28 +1,41 @@ // Write your "projects" router here! const express = require("express"); -const Projects = require("./projects-model"); -// const {} = require("./projects-middleware"); +const Project = require("./projects-model"); +const { validateId } = require("./projects-middleware"); const router = express.Router(); +//{name:___, description:____, completed:____} // - [ ] `[GET] /api/projects` // - Returns an array of projects as the body of the response. // - If there are no projects it responds with an empty array. -router.get("/", async (req, res) => { - const projects = await Projects.get(); - res.status(200).json({ projects }); +router.get("/", async (req, res, next) => { + try { + const projects = await Project.get(); + res.status(200).json(projects ? [...projects] : []); + } catch (err) { + next(err); + } }); // - [ ] `[GET] /api/projects/:id` // - Returns a project with the given `id` as the body of the response. // - If there is no project with the given `id` it responds with a status code 404. -router.get("/:id", async (req, res) => { - res.status(200).json({ message: `[GET] /api/projects/${req.params.id}` }); +router.get("/:id", validateId, async (req, res, next) => { + try { + res.status(200).json({ ...req.project }); + } catch (err) { + next(err); + } }); // - [ ] `[POST] /api/projects` // - Returns the newly created project as the body of the response. // - If the request body is missing any of the required fields it responds with a status code 400. -router.post("/", async (req, res) => { +router.post("/", async (req, res, next) => { + try { + } catch (err) { + next(err); + } res.status(201).json({ message: `[POST] /api/projects/` }); }); @@ -30,24 +43,43 @@ router.post("/", async (req, res) => { // - Returns the updated project as the body of the response. // - If there is no project with the given `id` it responds with a status code 404. // - If the request body is missing any of the required fields it responds with a status code 400. -router.put("/:id", async (req, res) => { +router.put("/:id", async (req, res, next) => { + try { + } catch (err) { + next(err); + } res.status(201).json({ message: `[PUT] /api/projects/${req.params.id}` }); }); // - [ ] `[DELETE] /api/projects/:id` // - Returns no response body. // - If there is no project with the given `id` it responds with a status code 404. -router.delete("/:id", async (req, res) => { +router.delete("/:id", async (req, res, next) => { + try { + } catch (err) { + next(err); + } res.status(201).json({ message: `[DELETE] /api/projects/${req.params.id}` }); }); // - [ ] `[GET] /api/projects/:id/actions` // - Returns an array of actions (could be empty) belonging to a project with the given `id`. // - If there is no project with the given `id` it responds with a status code 404. -router.get("/:id/actions", async (req, res) => { +router.get("/:id/actions", async (req, res, next) => { + try { + } catch (err) { + next(err); + } res .status(200) .json({ message: `[GET] /api/projects/${req.params.id}/actions` }); }); +router.use((err, req, res, next) => { + res.status(err.status || 500).json({ + custMessage: "Error Occured retrieving /api/actions path", + message: err.message, + }); +}); + module.exports = router; From a62176819d5c8ecd35e6b657e89992de1daf56d1 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 14:11:56 -0700 Subject: [PATCH 17/25] ...progress --- api/projects/projects-router.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index 97eb75ba39..7c2bf8cb97 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -5,9 +5,7 @@ const { validateId } = require("./projects-middleware"); const router = express.Router(); //{name:___, description:____, completed:____} -// - [ ] `[GET] /api/projects` -// - Returns an array of projects as the body of the response. -// - If there are no projects it responds with an empty array. + router.get("/", async (req, res, next) => { try { const projects = await Project.get(); @@ -17,9 +15,6 @@ router.get("/", async (req, res, next) => { } }); -// - [ ] `[GET] /api/projects/:id` -// - Returns a project with the given `id` as the body of the response. -// - If there is no project with the given `id` it responds with a status code 404. router.get("/:id", validateId, async (req, res, next) => { try { res.status(200).json({ ...req.project }); From b20dd694da1b9bff7163a84ae0dbd6802a251da7 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 14:19:05 -0700 Subject: [PATCH 18/25] ...progress --- api/projects/projects-middleware.js | 15 ++++++++++++++- api/projects/projects-router.js | 10 ++++------ data/test.db3-journal | Bin 0 -> 8720 bytes 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 data/test.db3-journal diff --git a/api/projects/projects-middleware.js b/api/projects/projects-middleware.js index 3a8aa786ba..a0678c896f 100644 --- a/api/projects/projects-middleware.js +++ b/api/projects/projects-middleware.js @@ -14,4 +14,17 @@ async function validateId(req, res, next) { } } -module.exports = { validateId }; +function validateNewProject(req, res, next) { + //{name:___, description:____, completed:____} + const { name, description, completed } = req.body; + if (!name || name === "" || !description || description === "") { + res + .status(400) + .json({ message: "missing required fileds : name, description" }); + } else { + req.newProject = { name, description, completed }; + next(); + } +} + +module.exports = { validateId, validateNewProject }; diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index 7c2bf8cb97..3e65479a46 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -1,7 +1,7 @@ // Write your "projects" router here! const express = require("express"); const Project = require("./projects-model"); -const { validateId } = require("./projects-middleware"); +const { validateId, validateNewProject } = require("./projects-middleware"); const router = express.Router(); //{name:___, description:____, completed:____} @@ -23,15 +23,13 @@ router.get("/:id", validateId, async (req, res, next) => { } }); -// - [ ] `[POST] /api/projects` -// - Returns the newly created project as the body of the response. -// - If the request body is missing any of the required fields it responds with a status code 400. -router.post("/", async (req, res, next) => { +router.post("/", validateNewProject, async (req, res, next) => { try { + const newProject = await Project.insert(req.newProject); + res.status(201).json({ ...newProject }); } catch (err) { next(err); } - res.status(201).json({ message: `[POST] /api/projects/` }); }); // - [ ] `[PUT] /api/projects/:id` diff --git a/data/test.db3-journal b/data/test.db3-journal new file mode 100644 index 0000000000000000000000000000000000000000..4bbec52dbc509b33917b27d06980c7595542bc00 GIT binary patch literal 8720 zcmeI0&2G~`5XWsdUzKRhEr+UN#U-&C@lg~Bp&pusNQmY@X(hxd-Z+zFiM>wO>nb@W zf;+FkOYkNLapYc!8xl8mEhpe8Jrr?)&Pvvf$LpE-|8_3BUq0o3kPqHx!!WEi3@U0a zC{s(5GZUZk(PaF*x&6-`|Ax*j1rLm5XN|R}N?_-{xw3!6b4@E#Fd8BTDOw%|d#4zZI!lLelmLsPu z{VayLFs`0ejC;rL^<6{$)-%IyY=7H+zV%L-IFJAmKmter2_OL^fCP{L68MJ+%%9|o z<((b#?Xjd?AE+l;$fI;BG+(wFXDxEpIBK_un|fVRby?3Pj7u1RAUu?W$G%U-f(2Ae z$q1%|#xi8w6A%EGHR6s%_y#=LS@)y*+=IvyY^;;J ziAtCzRceH#0cR321n`iul@z;#*G-|KLQfIbM|9z@FmBR3J} zkWfd_VM()b+H5>+X-_=v(O({Cc9biYcX!SCs{~%EF Date: Fri, 29 Oct 2021 14:27:10 -0700 Subject: [PATCH 19/25] ...progress --- api/projects/projects-middleware.js | 23 +++++++++++++++++++-- api/projects/projects-router.js | 31 ++++++++++++++++++---------- data/test.db3-journal | Bin 8720 -> 8720 bytes 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/api/projects/projects-middleware.js b/api/projects/projects-middleware.js index a0678c896f..768f308b30 100644 --- a/api/projects/projects-middleware.js +++ b/api/projects/projects-middleware.js @@ -20,11 +20,30 @@ function validateNewProject(req, res, next) { if (!name || name === "" || !description || description === "") { res .status(400) - .json({ message: "missing required fileds : name, description" }); + .json({ message: "missing required fields : name, description" }); } else { req.newProject = { name, description, completed }; next(); } } -module.exports = { validateId, validateNewProject }; +function validateExistingProject(req, res, next) { + //{name:___, description:____, completed:____} + const { name, description, completed } = req.body; + if ( + !name || + name === "" || + !description || + description === "" || + !completed + ) { + res.status(400).json({ + message: "missing required fields : name, description, completed", + }); + } else { + req.existingProject = { name, description, completed }; + next(); + } +} + +module.exports = { validateId, validateNewProject, validateExistingProject }; diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index 3e65479a46..a1b2ce01c2 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -1,7 +1,11 @@ // Write your "projects" router here! const express = require("express"); const Project = require("./projects-model"); -const { validateId, validateNewProject } = require("./projects-middleware"); +const { + validateId, + validateNewProject, + validateExistingProject, +} = require("./projects-middleware"); const router = express.Router(); //{name:___, description:____, completed:____} @@ -32,17 +36,22 @@ router.post("/", validateNewProject, async (req, res, next) => { } }); -// - [ ] `[PUT] /api/projects/:id` -// - Returns the updated project as the body of the response. -// - If there is no project with the given `id` it responds with a status code 404. -// - If the request body is missing any of the required fields it responds with a status code 400. -router.put("/:id", async (req, res, next) => { - try { - } catch (err) { - next(err); +router.put( + "/:id", + validateId, + validateExistingProject, + async (req, res, next) => { + try { + const updatedProject = await Project.update( + req.params.id, + req.existingProject + ); + res.status(201).json({ ...updatedProject }); + } catch (err) { + next(err); + } } - res.status(201).json({ message: `[PUT] /api/projects/${req.params.id}` }); -}); +); // - [ ] `[DELETE] /api/projects/:id` // - Returns no response body. diff --git a/data/test.db3-journal b/data/test.db3-journal index 4bbec52dbc509b33917b27d06980c7595542bc00..cd9ceb870b3df0037279a8d1cdb0ec984c04b01b 100644 GIT binary patch delta 150 zcmbQ>GQmaQ=2h083Ja63GcYhP&6c}0X`{erMnPs?AeV)II|Ki7{!9Ev__uFXWLnPe z%gw?p&6t>6l9``Z%*4aYEX!C>l%JKFTvE&=%*3qCn4One5uclxUX%z?BF@Nc%84cz ipOc@Q4YFu5hmagovG`;SAtxZUIY(##Kg(>nJBk455HBeJ delta 106 zcmbQ>GQmaQ=2h083Ja63GcYhP`J|?+Zxr~<$j` z Date: Fri, 29 Oct 2021 14:46:43 -0700 Subject: [PATCH 20/25] ...progress --- api/projects/projects-middleware.js | 12 ++++++++---- api/projects/projects-router.js | 26 ++++++++++++++------------ data/test.db3-journal | Bin 8720 -> 0 bytes 3 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 data/test.db3-journal diff --git a/api/projects/projects-middleware.js b/api/projects/projects-middleware.js index 768f308b30..3e08f2cd62 100644 --- a/api/projects/projects-middleware.js +++ b/api/projects/projects-middleware.js @@ -1,7 +1,7 @@ // add middlewares here related to projects const Project = require("./projects-model"); -async function validateId(req, res, next) { +async function validateProjectId(req, res, next) { const { id } = req.params; const project = await Project.get(id); if (!project) { @@ -34,8 +34,8 @@ function validateExistingProject(req, res, next) { !name || name === "" || !description || - description === "" || - !completed + description === "" + // || !completed ) { res.status(400).json({ message: "missing required fields : name, description, completed", @@ -46,4 +46,8 @@ function validateExistingProject(req, res, next) { } } -module.exports = { validateId, validateNewProject, validateExistingProject }; +module.exports = { + validateProjectId, + validateNewProject, + validateExistingProject, +}; diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index a1b2ce01c2..8a3a47414f 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -1,8 +1,9 @@ // Write your "projects" router here! const express = require("express"); const Project = require("./projects-model"); +const Action = require("../actions/actions-model"); const { - validateId, + validateProjectId, validateNewProject, validateExistingProject, } = require("./projects-middleware"); @@ -19,7 +20,7 @@ router.get("/", async (req, res, next) => { } }); -router.get("/:id", validateId, async (req, res, next) => { +router.get("/:id", validateProjectId, async (req, res, next) => { try { res.status(200).json({ ...req.project }); } catch (err) { @@ -36,9 +37,13 @@ router.post("/", validateNewProject, async (req, res, next) => { } }); +// - [ ] `[PUT] /api/projects/:id` +// - Returns the updated project as the body of the response. +// - If there is no project with the given `id` it responds with a status code 404. +// - If the request body is missing any of the required fields it responds with a status code 400. router.put( "/:id", - validateId, + validateProjectId, validateExistingProject, async (req, res, next) => { try { @@ -53,28 +58,25 @@ router.put( } ); -// - [ ] `[DELETE] /api/projects/:id` -// - Returns no response body. -// - If there is no project with the given `id` it responds with a status code 404. -router.delete("/:id", async (req, res, next) => { +router.delete("/:id", validateProjectId, async (req, res, next) => { try { + const deletedProject = await Project.remove(req.params.id); + res.status(201).json({ ...deletedProject }); } catch (err) { next(err); } - res.status(201).json({ message: `[DELETE] /api/projects/${req.params.id}` }); }); // - [ ] `[GET] /api/projects/:id/actions` // - Returns an array of actions (could be empty) belonging to a project with the given `id`. // - If there is no project with the given `id` it responds with a status code 404. -router.get("/:id/actions", async (req, res, next) => { +router.get("/:id/actions", validateProjectId, async (req, res, next) => { try { + const actions = await Action.get(); + res.status(200).json(actions ? [...actions] : []); } catch (err) { next(err); } - res - .status(200) - .json({ message: `[GET] /api/projects/${req.params.id}/actions` }); }); router.use((err, req, res, next) => { diff --git a/data/test.db3-journal b/data/test.db3-journal deleted file mode 100644 index cd9ceb870b3df0037279a8d1cdb0ec984c04b01b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8720 zcmeI0y^hmB5P-dQeuTKYAW^u8a$0CERw8~5MM8*zT!@6YD}Xx*QNnJElRo+T94YzgEl>A?(DUx zn_693b^V@8eWCb(ODZBo#W)D)Nctg@$8^Y#DI2TE7oOxH7phL(wB6~f`Vl_&c*_18EYDtVtvE<7GD0*u`xIfq8ti*`#}&HYyMZd+T%qaOQdai%-DqFt$w z+2aJ>yrrA3`7FM<`M3B97V^`{WbmDhk2Ae&741fYOb1C4tD4SLwp=#3Ra=roMUPL; zSSx;wSnU#(1FOM9!DV;%l Date: Fri, 29 Oct 2021 14:50:03 -0700 Subject: [PATCH 21/25] ...progress --- api/projects/projects-router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index 8a3a47414f..a0ac6cf3bf 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -73,7 +73,7 @@ router.delete("/:id", validateProjectId, async (req, res, next) => { router.get("/:id/actions", validateProjectId, async (req, res, next) => { try { const actions = await Action.get(); - res.status(200).json(actions ? [...actions] : []); + res.status(200).json([...actions]); } catch (err) { next(err); } From 3fe061a52795edb2883c673f5be29a98e7f7f666 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 14:59:24 -0700 Subject: [PATCH 22/25] ...progress --- api/projects/projects-router.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index a0ac6cf3bf..7be47bef0c 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -72,8 +72,8 @@ router.delete("/:id", validateProjectId, async (req, res, next) => { // - If there is no project with the given `id` it responds with a status code 404. router.get("/:id/actions", validateProjectId, async (req, res, next) => { try { - const actions = await Action.get(); - res.status(200).json([...actions]); + const actions = await Project.getProjectActions(req.params.id); + res.status(200).json(actions.length === 0 ? [] : [...actions]); } catch (err) { next(err); } From 82e9271d550cab20c8988f566c61527bc0a501b9 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 15:01:35 -0700 Subject: [PATCH 23/25] ...met mvp --- .history/README_20211029145940.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145941.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145943.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145945.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145947.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145949.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145951.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145953.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145954.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029145956.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029150001.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029150007.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029150026.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029150029.md | 153 ++++++++++++++++++++++++++++++ .history/README_20211029150031.md | 153 ++++++++++++++++++++++++++++++ README.md | 32 +++---- interview.md | 9 ++ 17 files changed, 2320 insertions(+), 16 deletions(-) create mode 100644 .history/README_20211029145940.md create mode 100644 .history/README_20211029145941.md create mode 100644 .history/README_20211029145943.md create mode 100644 .history/README_20211029145945.md create mode 100644 .history/README_20211029145947.md create mode 100644 .history/README_20211029145949.md create mode 100644 .history/README_20211029145951.md create mode 100644 .history/README_20211029145953.md create mode 100644 .history/README_20211029145954.md create mode 100644 .history/README_20211029145956.md create mode 100644 .history/README_20211029150001.md create mode 100644 .history/README_20211029150007.md create mode 100644 .history/README_20211029150026.md create mode 100644 .history/README_20211029150029.md create mode 100644 .history/README_20211029150031.md create mode 100644 interview.md diff --git a/.history/README_20211029145940.md b/.history/README_20211029145940.md new file mode 100644 index 0000000000..391a47c7a2 --- /dev/null +++ b/.history/README_20211029145940.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [ ] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145941.md b/.history/README_20211029145941.md new file mode 100644 index 0000000000..138df14f2e --- /dev/null +++ b/.history/README_20211029145941.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145943.md b/.history/README_20211029145943.md new file mode 100644 index 0000000000..1329f4f35e --- /dev/null +++ b/.history/README_20211029145943.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145945.md b/.history/README_20211029145945.md new file mode 100644 index 0000000000..333cc9c113 --- /dev/null +++ b/.history/README_20211029145945.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145947.md b/.history/README_20211029145947.md new file mode 100644 index 0000000000..4bbb0894f9 --- /dev/null +++ b/.history/README_20211029145947.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [ ] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145949.md b/.history/README_20211029145949.md new file mode 100644 index 0000000000..ad0b3102f4 --- /dev/null +++ b/.history/README_20211029145949.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [ ] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145951.md b/.history/README_20211029145951.md new file mode 100644 index 0000000000..fcbbad3d67 --- /dev/null +++ b/.history/README_20211029145951.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [ ] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145953.md b/.history/README_20211029145953.md new file mode 100644 index 0000000000..5ae63773c9 --- /dev/null +++ b/.history/README_20211029145953.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [x] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [ ] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145954.md b/.history/README_20211029145954.md new file mode 100644 index 0000000000..daafc7e7e8 --- /dev/null +++ b/.history/README_20211029145954.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [x] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [x] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [ ] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029145956.md b/.history/README_20211029145956.md new file mode 100644 index 0000000000..28341c1609 --- /dev/null +++ b/.history/README_20211029145956.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [x] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [x] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [x] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [ ] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029150001.md b/.history/README_20211029150001.md new file mode 100644 index 0000000000..59a31b93d0 --- /dev/null +++ b/.history/README_20211029150001.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [x] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [x] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [x] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029150007.md b/.history/README_20211029150007.md new file mode 100644 index 0000000000..35de91623d --- /dev/null +++ b/.history/README_20211029150007.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [x] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [x] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [x] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [x] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029150026.md b/.history/README_20211029150026.md new file mode 100644 index 0000000000..898be417cd --- /dev/null +++ b/.history/README_20211029150026.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [x] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [x] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [x] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [x] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [ ] Submit via Codegrade by pushing commits to your `main` branch. +- [ ] Check Codegrade before the deadline to compare its results against your local tests. +- [x] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029150029.md b/.history/README_20211029150029.md new file mode 100644 index 0000000000..92a88a576e --- /dev/null +++ b/.history/README_20211029150029.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [x] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [x] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [x] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [x] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [x] Submit via Codegrade by pushing commits to your `main` branch. +- [x] Check Codegrade before the deadline to compare its results against your local tests. +- [x] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/.history/README_20211029150031.md b/.history/README_20211029150031.md new file mode 100644 index 0000000000..547ad3dc1c --- /dev/null +++ b/.history/README_20211029150031.md @@ -0,0 +1,153 @@ +# Sprint Challenge Instructions + +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** + +This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **how to build web services based on the REST (REpresentational State Transfer) architectural style**. During this sprint, you studied **Node.js and Express, server side routing, how to write Express middleware and how to deploy an API to Heroku**. + +In your challenge this week, you will demonstrate your mastery of these skills by designing and creating a web API to manage the following resources: `Projects` and `Actions`. + +This is an individual assessment. All work must be your own. All projects will be submitted to Codegrade for automated review. You will also be given feedback by code reviewers the Monday after challenge submissions. For more information on the review process [click here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a). + +You are not allowed to collaborate during the sprint challenge. + +## Introduction + +In meeting the minimum viable product (MVP) specifications listed below, your project should provide an API that has Create, Read, Update and Delete (CRUD) functionality for both `projects` and `actions`. + +## Instructions + +### Task 1: Project Set Up + +- [x] Run `npm install` to install your dependencies. +- [x] Run tests locally executing `npm test`. +- [x] Reset the database to its original state executing `npm run resetdb`. + +### Task 2: Project Requirements (MVP) + +Your finished project must include all of the following requirements: + +#### NPM Scripts + +A _"test"_ script already exists you can use to run tests against your code. +A _"resetdb"_ script exists that allows you to reset the database to its original state. + +- [x] Write an _npm script_ named _"start"_ that uses `node` to run the API server. +- [x] Write an _npm script_ named _"server"_ that uses `nodemon` to run the API server. +- [x] Install _nodemon_ as a development dependency that would not be used in production. + +#### Environment Variables + +- [ ] Bring the port number from the `process.env` variable, falling back to `5000` if `process.env.PORT` is undefined **!!!** + +#### Endpoints + +Inside `api/projects/projects-router.js` build the following endpoints: + +- [x] `[GET] /api/projects` + - Returns an array of projects as the body of the response. + - If there are no projects it responds with an empty array. +- [x] `[GET] /api/projects/:id` + - Returns a project with the given `id` as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[POST] /api/projects` + - Returns the newly created project as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[PUT] /api/projects/:id` + - Returns the updated project as the body of the response. + - If there is no project with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/projects/:id` + - Returns no response body. + - If there is no project with the given `id` it responds with a status code 404. +- [x] `[GET] /api/projects/:id/actions` + - Returns an array of actions (could be empty) belonging to a project with the given `id`. + - If there is no project with the given `id` it responds with a status code 404. + +Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: + +- [x] `[GET] /api/actions` + - Returns an array of actions (or an empty array) as the body of the response. +- [x] `[GET] /api/actions/:id` + - Returns an action with the given `id` as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. +- [x] `[POST] /api/actions` + - Returns the newly created action as the body of the response. + - If the request body is missing any of the required fields it responds with a status code 400. + - When adding an action make sure the `project_id` provided belongs to an existing `project`. +- [x] `[PUT] /api/actions/:id` + - Returns the updated action as the body of the response. + - If there is no action with the given `id` it responds with a status code 404. + - If the request body is missing any of the required fields it responds with a status code 400. +- [x] `[DELETE] /api/actions/:id` + - Returns no response body. + - If there is no action with the given `id` it responds with a status code 404. + +#### Middleware functions + +- [x] Write at least two middleware functions for this API, and consume them in the proper places of your code. + +### Database Schemas + +The description of the structure and extra information about each _resource_ stored in the included database (`./data/database.db3`) is listed below. + +#### Projects + +| Field | Data Type | Metadata | +| ----------- | --------- | --------------------------------------------------------------------------- | +| id | number | do not provide it when creating projects, the database will generate it | +| name | string | required | +| description | string | required | +| completed | boolean | not required, defaults to false when creating projects | + +#### Actions + +| Field | Data Type | Metadata | +| ----------- | --------- | ------------------------------------------------------------------------------------------------ | +| id | number | do not provide it when creating actions, the database will generate it | +| project_id | number | required, must be the id of an existing project | +| description | string | required, up to 128 characters long | +| notes | string | required, no size limit. Used to record additional notes or requirements to complete the action | +| completed | boolean | not required, defaults to false when creating actions | + +### Database Persistence Helpers + +The project includes models you can use to manage the persistence of _project_ and _action_ data. These files are `api/projects/projects-model.js` and `api/actions/actions-model.js`. Both files publish the following api, which you can use to store, modify and retrieve each resource: + +**All these helper methods return a promise. Remember to use .then().catch() or async/await.** + +- `get()`: resolves to an array of all the resources contained in the database. If you pass an `id` to this method it will return the resource with that id if one is found. +- `insert()`: calling insert passing it a resource object will add it to the database and return the newly created resource. +- `update()`: accepts two arguments, the first is the `id` of the resource to update, and the second is an object with the `changes` to apply. It returns the updated resource. If a resource with the provided `id` is not found, the method returns `null`. +- `remove()`: the remove method accepts an `id` as its first parameter and, upon successfully deleting the resource from the database, returns the number of records deleted. + +The `projects-model.js` includes an extra method called `getProjectActions()` that takes a _project id_ as its only argument and returns a list of all the _actions_ for the _project_. + +We have provided test data for all the resources. + +**Important Notes:** + +- Do not make changes to your `package.json` except to add **additional** dependencies and scripts. Do not update existing packages. +- Your app must be able to run in Node v.12. Do not use newer features of Node (e.g.: optional chaining and nullish coalescing NOT supported). +- Use an HTTP client like `HTTPie`, `Postman` or `Insomnia` to manually test the API's endpoints. +- Use Express Routers to organize your endpoints. +- Even though you are only required to write two middleware functions, it is advised that you leverage middlewares as much as possible. +- You are welcome to create additional files, but **do not move or rename existing files** or folders. +- In your solution, it is essential that you follow best practices and produce clean and professional results. +- Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. + +## Submission format + +- [x] Submit via Codegrade by pushing commits to your `main` branch. +- [x] Check Codegrade before the deadline to compare its results against your local tests. +- [x] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [x] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. + +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. diff --git a/README.md b/README.md index 13a73418e8..547ad3dc1c 100644 --- a/README.md +++ b/README.md @@ -43,48 +43,48 @@ A _"resetdb"_ script exists that allows you to reset the database to its origina Inside `api/projects/projects-router.js` build the following endpoints: -- [ ] `[GET] /api/projects` +- [x] `[GET] /api/projects` - Returns an array of projects as the body of the response. - If there are no projects it responds with an empty array. -- [ ] `[GET] /api/projects/:id` +- [x] `[GET] /api/projects/:id` - Returns a project with the given `id` as the body of the response. - If there is no project with the given `id` it responds with a status code 404. -- [ ] `[POST] /api/projects` +- [x] `[POST] /api/projects` - Returns the newly created project as the body of the response. - If the request body is missing any of the required fields it responds with a status code 400. -- [ ] `[PUT] /api/projects/:id` +- [x] `[PUT] /api/projects/:id` - Returns the updated project as the body of the response. - If there is no project with the given `id` it responds with a status code 404. - If the request body is missing any of the required fields it responds with a status code 400. -- [ ] `[DELETE] /api/projects/:id` +- [x] `[DELETE] /api/projects/:id` - Returns no response body. - If there is no project with the given `id` it responds with a status code 404. -- [ ] `[GET] /api/projects/:id/actions` +- [x] `[GET] /api/projects/:id/actions` - Returns an array of actions (could be empty) belonging to a project with the given `id`. - If there is no project with the given `id` it responds with a status code 404. Inside `api/actions/actions-router.js` build endpoints for performing CRUD operations on _actions_: -- [ ] `[GET] /api/actions` +- [x] `[GET] /api/actions` - Returns an array of actions (or an empty array) as the body of the response. -- [ ] `[GET] /api/actions/:id` +- [x] `[GET] /api/actions/:id` - Returns an action with the given `id` as the body of the response. - If there is no action with the given `id` it responds with a status code 404. -- [ ] `[POST] /api/actions` +- [x] `[POST] /api/actions` - Returns the newly created action as the body of the response. - If the request body is missing any of the required fields it responds with a status code 400. - When adding an action make sure the `project_id` provided belongs to an existing `project`. -- [ ] `[PUT] /api/actions/:id` +- [x] `[PUT] /api/actions/:id` - Returns the updated action as the body of the response. - If there is no action with the given `id` it responds with a status code 404. - If the request body is missing any of the required fields it responds with a status code 400. -- [ ] `[DELETE] /api/actions/:id` +- [x] `[DELETE] /api/actions/:id` - Returns no response body. - If there is no action with the given `id` it responds with a status code 404. #### Middleware functions -- [ ] Write at least two middleware functions for this API, and consume them in the proper places of your code. +- [x] Write at least two middleware functions for this API, and consume them in the proper places of your code. ### Database Schemas @@ -137,10 +137,10 @@ We have provided test data for all the resources. ## Submission format -- [ ] Submit via Codegrade by pushing commits to your `main` branch. -- [ ] Check Codegrade before the deadline to compare its results against your local tests. -- [ ] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. -- [ ] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. +- [x] Submit via Codegrade by pushing commits to your `main` branch. +- [x] Check Codegrade before the deadline to compare its results against your local tests. +- [x] Check Codegrade on the days following the Sprint Challenge for reviewer feedback. +- [x] New commits will be evaluated by Codegrade if pushed _before_ the sprint challenge deadline. ## Interview Questions diff --git a/interview.md b/interview.md new file mode 100644 index 0000000000..8cc7b042f1 --- /dev/null +++ b/interview.md @@ -0,0 +1,9 @@ +## Interview Questions + +Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. You might prepare by writing down your own answers before hand. + +1. The core features of Node.js and Express and why they are useful. +1. Understand and explain the use of Middleware. +1. The basic principles of the REST architectural style. +1. Understand and explain the use of Express Routers. +1. Describe tooling used to manually test the correctness of an API. \ No newline at end of file From c6680a1c5f1d28ca3a5ce92b38c615b3998023f4 Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 15:04:15 -0700 Subject: [PATCH 24/25] ...met mvp --- api/actions/actions-middlware.js | 2 -- api/projects/projects-middleware.js | 1 - api/projects/projects-router.js | 10 ---------- api/server.js | 6 ------ 4 files changed, 19 deletions(-) diff --git a/api/actions/actions-middlware.js b/api/actions/actions-middlware.js index 09c4e1d0e1..e75fd40003 100644 --- a/api/actions/actions-middlware.js +++ b/api/actions/actions-middlware.js @@ -2,7 +2,6 @@ const Action = require("./actions-model"); const Project = require("../projects/projects-model"); async function validateId(req, res, next) { - console.log("---------validateId middleware"); const { id } = req.params; const action = await Action.get(id); if (!action) { @@ -16,7 +15,6 @@ async function validateId(req, res, next) { } async function validateNewAction(req, res, next) { - console.log("---------validateAction middleware"); const { project_id, description, notes, completed } = req.body; if ( diff --git a/api/projects/projects-middleware.js b/api/projects/projects-middleware.js index 3e08f2cd62..f3fc5fb692 100644 --- a/api/projects/projects-middleware.js +++ b/api/projects/projects-middleware.js @@ -1,4 +1,3 @@ -// add middlewares here related to projects const Project = require("./projects-model"); async function validateProjectId(req, res, next) { diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index 7be47bef0c..f1dd023bdc 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -1,4 +1,3 @@ -// Write your "projects" router here! const express = require("express"); const Project = require("./projects-model"); const Action = require("../actions/actions-model"); @@ -9,8 +8,6 @@ const { } = require("./projects-middleware"); const router = express.Router(); -//{name:___, description:____, completed:____} - router.get("/", async (req, res, next) => { try { const projects = await Project.get(); @@ -37,10 +34,6 @@ router.post("/", validateNewProject, async (req, res, next) => { } }); -// - [ ] `[PUT] /api/projects/:id` -// - Returns the updated project as the body of the response. -// - If there is no project with the given `id` it responds with a status code 404. -// - If the request body is missing any of the required fields it responds with a status code 400. router.put( "/:id", validateProjectId, @@ -67,9 +60,6 @@ router.delete("/:id", validateProjectId, async (req, res, next) => { } }); -// - [ ] `[GET] /api/projects/:id/actions` -// - Returns an array of actions (could be empty) belonging to a project with the given `id`. -// - If there is no project with the given `id` it responds with a status code 404. router.get("/:id/actions", validateProjectId, async (req, res, next) => { try { const actions = await Project.getProjectActions(req.params.id); diff --git a/api/server.js b/api/server.js index 26cb946ff4..e9c9ac698d 100644 --- a/api/server.js +++ b/api/server.js @@ -10,10 +10,4 @@ server.get("/", (req, res) => { server.use("/api/actions", routerAction); server.use("/api/projects", routerProject); - -// Configure your server here -// Build your actions router in /api/actions/actions-router.js -// Build your projects router in /api/projects/projects-router.js -// Do NOT `server.listen()` inside this file! - module.exports = server; From f7b1bc18aa6b59b2bb6a7ef5a5fecb83d991bcbe Mon Sep 17 00:00:00 2001 From: beefybroccoli Date: Fri, 29 Oct 2021 15:06:09 -0700 Subject: [PATCH 25/25] ...met mvp --- api/projects/projects-middleware.js | 1 - api/projects/projects-router.js | 1 - index.js | 14 -------------- 3 files changed, 16 deletions(-) diff --git a/api/projects/projects-middleware.js b/api/projects/projects-middleware.js index f3fc5fb692..86c21ecc95 100644 --- a/api/projects/projects-middleware.js +++ b/api/projects/projects-middleware.js @@ -14,7 +14,6 @@ async function validateProjectId(req, res, next) { } function validateNewProject(req, res, next) { - //{name:___, description:____, completed:____} const { name, description, completed } = req.body; if (!name || name === "" || !description || description === "") { res diff --git a/api/projects/projects-router.js b/api/projects/projects-router.js index f1dd023bdc..45651f526c 100644 --- a/api/projects/projects-router.js +++ b/api/projects/projects-router.js @@ -1,6 +1,5 @@ const express = require("express"); const Project = require("./projects-model"); -const Action = require("../actions/actions-model"); const { validateProjectId, validateNewProject, diff --git a/index.js b/index.js index 834af0722a..ccdc47a593 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,3 @@ -/* -play this: https://www.youtube.com/watch?v=d-diB65scQU - -Sing along: - -here's a little code I wrote, please read the README word for word, don't worry, you got this -in every task there may be trouble, but if you worry you make it double, don't worry, you got this -ain't got no sense of what is REST? just concentrate on learning Express, don't worry, you got this -your file is getting way too big, bring a Router and make it thin, don't worry, be crafty -there is no data on that route, just write some code, you'll sort it out… don't worry, just hack it… -I need this code, but don't know where, perhaps should make some middleware, don't worry, just hack it - -Pull your server into this file and start it! -*/ require("dotenv").config(); const server = require("./api/server"); const PORT = process.env.PORT || 5000;