├── .eslintrc.json ├── .github └── lockdown.yml ├── .gitignore ├── README.md ├── api ├── server.js └── users │ └── model.js ├── codegrade_mvp.test.js ├── index.js ├── jest.config.js ├── package-lock.json └── package.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "commonjs": true, 4 | "es2021": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "extends": "eslint:recommended", 9 | "parserOptions": { 10 | "ecmaVersion": "latest" 11 | }, 12 | "rules": { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.github/lockdown.yml: -------------------------------------------------------------------------------- 1 | # PLEASE DO NOT REMOVE THIS FILE 2 | 3 | # Configuration for Repo Lockdown - https://github.com/dessant/repo-lockdown 4 | 5 | # Skip issues and pull requests created before a given timestamp. Timestamp must 6 | # follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable 7 | skipCreatedBefore: false 8 | 9 | # Issues and pull requests with these labels will be ignored. Set to `[]` to disable 10 | exemptLabels: [] 11 | 12 | # Comment to post before closing or locking. Set to `false` to disable 13 | comment: false 14 | 15 | # Label to add before closing or locking. Set to `false` to disable 16 | label: false 17 | 18 | # Close issues and pull requests 19 | close: true 20 | 21 | # Lock issues and pull requests 22 | lock: true 23 | 24 | # Limit to only `issues` or `pulls` 25 | only: pulls 26 | # Optionally, specify configuration settings just for `issues` or `pulls` 27 | # issues: 28 | # label: wontfix 29 | 30 | # pulls: 31 | # comment: > 32 | # This repository does not accept pull requests, see the README for details. 33 | # lock: false 34 | 35 | # Repository to extend settings from 36 | # _extends: repo 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # Mac files 61 | .DS_Store 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Node API 1 Project Starter Code 2 | 3 | ## Introduction 4 | 5 | - Building a RESTful API. 6 | - Performing CRUD operations. 7 | - Writing API endpoints. 8 | 9 | ## Instructions 10 | 11 | ### Task 1: Project Setup and Submission 12 | 13 | Your assignment page on Canvas should contain instructions for submitting this project. If you are still unsure, reach out to School Staff. 14 | 15 | ### Task 2: Minimum Viable Product 16 | 17 | Use Node.js and Express to build an API that performs CRUD operations on users. 18 | 19 | - Add a `server` script to the `package.json` that runs the API using `nodemon`. 20 | 21 | ### Write endpoints 22 | 23 | Add the code necessary in `index.js` and `api/server.js` to create a Web API and implement the following _endpoints_: 24 | 25 | | Method | URL | Description | 26 | | ------ | -------------- | ------------------------------------------------------------------------------------------------------ | 27 | | POST | /api/users | Creates a user using the information sent inside the `request body`. | 28 | | GET | /api/users | Returns an array users. | 29 | | GET | /api/users/:id | Returns the user object with the specified `id`. | 30 | | DELETE | /api/users/:id | Removes the user with the specified `id` and returns the deleted user. | 31 | | PUT | /api/users/:id | Updates the user with the specified `id` using data from the `request body`. Returns the modified user | 32 | 33 | #### User Schema 34 | 35 | Each User _resource_ should conform to the following structure (AKA schema): 36 | 37 | ```js 38 | { 39 | id: "a_unique_id", // String, required 40 | name: "Jane Doe", // String, required 41 | bio: "Having fun", // String, required 42 | } 43 | ``` 44 | 45 | #### Database Access Functions 46 | 47 | You can find them inside `api/users/model.js`. All of these functions return Promises. 48 | 49 | - `find` Resolves to the list of users (or empty array). 50 | - `findById` Takes an `id` and resolves to the user with that id (or null if the id does not exist). 51 | - `insert` Takes a new user `{ name, bio }` and resolves to the the newly created user `{ id, name, bio }`. 52 | - `update` Takes an `id` and an existing user `{ name, bio }` and resolves the updated user `{ id, name, bio}` (or null if the id does not exist). 53 | - `remove` Takes an `id` and resolves to the deleted user `{ id, name, bio }`. 54 | 55 | #### Endpoint Specifications 56 | 57 | When the client makes a `POST` request to `/api/users`: 58 | 59 | - If the request body is missing the `name` or `bio` property: 60 | 61 | - respond with HTTP status code `400` (Bad Request). 62 | - return the following JSON response: `{ message: "Please provide name and bio for the user" }`. 63 | 64 | - If the information about the _user_ is valid: 65 | 66 | - save the new _user_ the the database. 67 | - respond with HTTP status code `201` (Created). 68 | - return the newly created _user document_ including its id. 69 | 70 | - If there's an error while saving the _user_: 71 | - respond with HTTP status code `500` (Server Error). 72 | - return the following JSON object: `{ message: "There was an error while saving the user to the database" }`. 73 | 74 | When the client makes a `GET` request to `/api/users`: 75 | 76 | - If there's an error in retrieving the _users_ from the database: 77 | - respond with HTTP status code `500`. 78 | - return the following JSON object: `{ message: "The users information could not be retrieved" }`. 79 | 80 | When the client makes a `GET` request to `/api/users/:id`: 81 | 82 | - If the _user_ with the specified `id` is not found: 83 | 84 | - respond with HTTP status code `404` (Not Found). 85 | - return the following JSON object: `{ message: "The user with the specified ID does not exist" }`. 86 | 87 | - If there's an error in retrieving the _user_ from the database: 88 | - respond with HTTP status code `500`. 89 | - return the following JSON object: `{ message: "The user information could not be retrieved" }`. 90 | 91 | When the client makes a `DELETE` request to `/api/users/:id`: 92 | 93 | - If the _user_ with the specified `id` is not found: 94 | 95 | - respond with HTTP status code `404` (Not Found). 96 | - return the following JSON object: `{ message: "The user with the specified ID does not exist" }`. 97 | 98 | - If there's an error in removing the _user_ from the database: 99 | - respond with HTTP status code `500`. 100 | - return the following JSON object: `{ message: "The user could not be removed" }`. 101 | 102 | When the client makes a `PUT` request to `/api/users/:id`: 103 | 104 | - If the _user_ with the specified `id` is not found: 105 | 106 | - respond with HTTP status code `404` (Not Found). 107 | - return the following JSON object: `{ message: "The user with the specified ID does not exist" }`. 108 | 109 | - If the request body is missing the `name` or `bio` property: 110 | 111 | - respond with HTTP status code `400` (Bad Request). 112 | - return the following JSON response: `{ message: "Please provide name and bio for the user" }`. 113 | 114 | - If there's an error when updating the _user_: 115 | 116 | - respond with HTTP status code `500`. 117 | - return the following JSON object: `{ message: "The user information could not be modified" }`. 118 | 119 | - If the user is found and the new information is valid: 120 | 121 | - update the user document in the database using the new information sent in the `request body`. 122 | - respond with HTTP status code `200` (OK). 123 | - return the newly updated _user document_. 124 | 125 | #### Important Notes 126 | 127 | - Test your work manually using Postman or HTTPie. Run automatic tests by executing `npm test`. 128 | - You are welcome to create additional files but **do not move or rename existing files** or folders. 129 | - Do not alter your `package.json` file except to install additional libraries or add additional scripts. **Do not update existing libs**. 130 | - In your solution, it is essential that you follow best practices and produce clean and professional results. 131 | 132 | ### Task 3: Stretch Problems 133 | 134 | Be careful not to _break MVP_ while working on these Stretch goals! If in doubt create a new branch. 135 | 136 | You'll need to enable the `cors` middleware: 137 | 138 | - add the `cors` npm module: `npm i cors`. 139 | - add `server.use(cors())` after `server.use(express.json())`. 140 | 141 | Create a new React application and connect it to your server: 142 | 143 | - the React application can be anywhere, but, for this project create it inside the folder for the solution. 144 | - connect to the `/api/users` endpoint in the API and show the list of users. 145 | - add a delete button to each displayed user that will remove it from the server. 146 | - add forms to add and update data. 147 | - Style the list of users however you see fit. 148 | -------------------------------------------------------------------------------- /api/server.js: -------------------------------------------------------------------------------- 1 | // BUILD YOUR SERVER HERE 2 | 3 | module.exports = {}; // EXPORT YOUR SERVER instead of {} 4 | -------------------------------------------------------------------------------- /api/users/model.js: -------------------------------------------------------------------------------- 1 | // DO NOT MAKE CHANGES TO THIS FILE 2 | // DO NOT MAKE CHANGES TO THIS FILE 3 | // DO NOT MAKE CHANGES TO THIS FILE 4 | const { nanoid } = require('nanoid') 5 | 6 | function getId() { 7 | return nanoid().slice(0, 5) 8 | } 9 | 10 | const initializeUsers = () => ([ 11 | { id: getId(), name: 'Ed Carter', bio: 'hero' }, 12 | { id: getId(), name: 'Mary Edwards', bio: 'super hero' }, 13 | ]) 14 | 15 | // FAKE IN-MEMORY USERS "TABLE" 16 | let users = initializeUsers() 17 | 18 | // DATABASE ACCESS FUNCTIONS 19 | // DATABASE ACCESS FUNCTIONS 20 | // DATABASE ACCESS FUNCTIONS 21 | const find = () => { 22 | // SELECT * FROM users; 23 | return Promise.resolve(users) 24 | } 25 | 26 | const findById = id => { 27 | // SELECT * FROM users WHERE id = 1; 28 | const user = users.find(d => d.id === id) 29 | return Promise.resolve(user) 30 | } 31 | 32 | const insert = ({ name, bio }) => { 33 | // INSERT INTO users (name, bio) VALUES ('foo', 'bar'); 34 | const newUser = { id: getId(), name, bio } 35 | users.push(newUser) 36 | return Promise.resolve(newUser) 37 | } 38 | 39 | const update = (id, changes) => { 40 | // UPDATE users SET name = 'foo', bio = 'bar WHERE id = 1; 41 | const user = users.find(user => user.id === id) 42 | if (!user) return Promise.resolve(null) 43 | 44 | const updatedUser = { ...changes, id } 45 | users = users.map(d => (d.id === id) ? updatedUser : d) 46 | return Promise.resolve(updatedUser) 47 | } 48 | 49 | const remove = id => { 50 | // DELETE FROM users WHERE id = 1; 51 | const user = users.find(user => user.id === id) 52 | if (!user) return Promise.resolve(null) 53 | 54 | users = users.filter(d => d.id !== id) 55 | return Promise.resolve(user) 56 | } 57 | 58 | const resetDB = () => { // ONLY TESTS USE THIS ONE 59 | users = initializeUsers() 60 | } 61 | 62 | module.exports = { 63 | find, 64 | findById, 65 | insert, 66 | update, 67 | remove, 68 | resetDB, // ONLY TESTS USE THIS ONE 69 | } 70 | -------------------------------------------------------------------------------- /codegrade_mvp.test.js: -------------------------------------------------------------------------------- 1 | const request = require('supertest') 2 | const server = require('./api/server') 3 | const User = require('./api/users/model') 4 | 5 | test('[0] sanity check', () => { 6 | expect(true).not.toBe(false) 7 | }) 8 | 9 | const initialUsers = [ 10 | { name: 'Ed Carter', bio: 'hero' }, 11 | { name: 'Mary Edwards', bio: 'super hero' }, 12 | ] 13 | 14 | beforeEach(() => { 15 | User.resetDB() 16 | }) 17 | 18 | describe('server.js', () => { 19 | // 👉 USERS 20 | // 👉 USERS 21 | // 👉 USERS 22 | describe('user endpoints', () => { 23 | describe('[POST] /api/users', () => { 24 | test('[1] responds with a new user', async () => { 25 | const newUser = { name: 'foo', bio: 'bar' } 26 | const res = await request(server).post('/api/users').send(newUser) 27 | expect(res.body).toHaveProperty('id') 28 | expect(res.body).toMatchObject(newUser) 29 | }, 750) 30 | test('[2] adds a new user to the db', async () => { 31 | const newUser = { name: 'fizz', bio: 'buzz' } 32 | await request(server).post('/api/users').send(newUser) 33 | const users = await User.find() 34 | expect(users[0]).toMatchObject(initialUsers[0]) 35 | expect(users[1]).toMatchObject(initialUsers[1]) 36 | expect(users[2]).toMatchObject(newUser) 37 | }, 750) 38 | test('[3] responds with the correct status code on success', async () => { 39 | const newUser = { name: 'fizz', bio: 'buzz' } 40 | const res = await request(server).post('/api/users').send(newUser) 41 | expect(res.status).toBe(201) 42 | }, 750) 43 | test('[4] responds with the correct message & status code on validation problem', async () => { 44 | let newUser = { name: 'only name' } 45 | let res = await request(server).post('/api/users').send(newUser) 46 | expect(res.status).toBe(400) 47 | expect(res.body.message).toMatch(/provide name and bio/) 48 | newUser = { bio: 'only bio' } 49 | res = await request(server).post('/api/users').send(newUser) 50 | expect(res.status).toBe(400) 51 | expect(res.body.message).toMatch(/provide name and bio/) 52 | newUser = {} 53 | res = await request(server).post('/api/users').send(newUser) 54 | expect(res.status).toBe(400) 55 | expect(res.body.message).toMatch(/provide name and bio/) 56 | }, 750) 57 | }) 58 | describe('[GET] /api/users', () => { 59 | test('[5] can get all the users', async () => { 60 | const res = await request(server).get('/api/users') 61 | expect(res.body).toHaveLength(initialUsers.length) 62 | }, 750) 63 | 64 | test('[6] can get the correct users', async () => { 65 | const res = await request(server).get('/api/users') 66 | expect(res.body[0]).toMatchObject(initialUsers[0]) 67 | expect(res.body[1]).toMatchObject(initialUsers[1]) 68 | }, 750) 69 | }) 70 | describe('[GET] /api/users/:id', () => { 71 | test('[7] responds with the correct user', async () => { 72 | let [{ id }] = await User.find() 73 | let res = await request(server).get(`/api/users/${id}`) 74 | expect(res.body).toMatchObject(initialUsers[0]); 75 | 76 | [_, { id }] = await User.find() // eslint-disable-line 77 | res = await request(server).get(`/api/users/${id}`) 78 | expect(res.body).toMatchObject(initialUsers[1]) 79 | }, 750) 80 | test('[8] responds with the correct message & status code on bad id', async () => { 81 | let res = await request(server).get('/api/users/foobar') 82 | expect(res.status).toBe(404) 83 | expect(res.body.message).toMatch(/does not exist/) 84 | }, 750) 85 | }) 86 | describe('[DELETE] /api/users/:id', () => { 87 | test('[9] responds with deleted user', async () => { 88 | let [{ id }] = await User.find() 89 | const choppingBlock = await User.findById(id) 90 | const res = await request(server).delete(`/api/users/${id}`) 91 | expect(res.body).toMatchObject(choppingBlock) 92 | }, 750) 93 | test('[10] deletes the user from the db', async () => { 94 | let [{ id }] = await User.find() 95 | await request(server).delete(`/api/users/${id}`) 96 | const gone = await User.findById(id) 97 | expect(gone).toBeFalsy() 98 | const survivors = await User.find() 99 | expect(survivors).toHaveLength(initialUsers.length - 1) 100 | }, 750) 101 | test('[11] responds with the correct message & status code on bad id', async () => { 102 | const res = await request(server).delete('/api/users/foobar') 103 | expect(res.status).toBe(404) 104 | expect(res.body.message).toMatch(/does not exist/) 105 | }, 750) 106 | }) 107 | describe('[PUT] /api/users/:id', () => { 108 | test('[12] responds with updated user', async () => { 109 | let [{ id }] = await User.find() 110 | const updates = { name: 'xxx', bio: 'yyy' } 111 | const res = await request(server).put(`/api/users/${id}`).send(updates) 112 | expect(res.body).toMatchObject({ id, ...updates }) 113 | }, 750) 114 | test('[13] saves the updated user to the db', async () => { 115 | let [_, { id }] = await User.find() // eslint-disable-line 116 | const updates = { name: 'aaa', bio: 'bbb' } 117 | await request(server).put(`/api/users/${id}`).send(updates) 118 | let user = await User.findById(id) 119 | expect(user).toMatchObject({ id, ...updates }) 120 | }, 750) 121 | test('[14] responds with the correct message & status code on bad id', async () => { 122 | const updates = { name: 'xxx', bio: 'yyy' } 123 | const res = await request(server).put('/api/users/foobar').send(updates) 124 | expect(res.status).toBe(404) 125 | expect(res.body.message).toMatch(/does not exist/) 126 | }, 750) 127 | test('[15] responds with the correct message & status code on validation problem', async () => { 128 | let [user] = await User.find() 129 | let updates = { name: 'xxx' } 130 | let res = await request(server).put(`/api/users/${user.id}`).send(updates) 131 | expect(res.status).toBe(400) 132 | expect(res.body.message).toMatch(/provide name and bio/) 133 | updates = { bio: 'zzz' } 134 | res = await request(server).put(`/api/users/${user.id}`).send(updates) 135 | expect(res.status).toBe(400) 136 | expect(res.body.message).toMatch(/provide name and bio/) 137 | updates = {} 138 | res = await request(server).put(`/api/users/${user.id}`).send(updates) 139 | expect(res.status).toBe(400) 140 | expect(res.body.message).toMatch(/provide name and bio/) 141 | }, 750) 142 | }) 143 | }) 144 | }) 145 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const server = require('./api/server'); 2 | 3 | const port = 9000; 4 | 5 | // START YOUR SERVER HERE 6 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * For a detailed explanation regarding each configuration property, visit: 3 | * https://jestjs.io/docs/configuration 4 | */ 5 | 6 | module.exports = { 7 | // All imported modules in your tests should be mocked automatically 8 | // automock: false, 9 | 10 | // Stop running tests after `n` failures 11 | // bail: 0, 12 | 13 | // The directory where Jest should store its cached dependency information 14 | // cacheDirectory: "/private/var/folders/mq/wc13nlwj4gdgcyshdy5j1hgr0000gn/T/jest_dx", 15 | 16 | // Automatically clear mock calls, instances, contexts and results before every test 17 | // clearMocks: false, 18 | 19 | // Indicates whether the coverage information should be collected while executing the test 20 | // collectCoverage: false, 21 | 22 | // An array of glob patterns indicating a set of files for which coverage information should be collected 23 | // collectCoverageFrom: undefined, 24 | 25 | // The directory where Jest should output its coverage files 26 | // coverageDirectory: undefined, 27 | 28 | // An array of regexp pattern strings used to skip coverage collection 29 | // coveragePathIgnorePatterns: [ 30 | // "/node_modules/" 31 | // ], 32 | 33 | // Indicates which provider should be used to instrument code for coverage 34 | coverageProvider: "v8", 35 | 36 | // A list of reporter names that Jest uses when writing coverage reports 37 | // coverageReporters: [ 38 | // "json", 39 | // "text", 40 | // "lcov", 41 | // "clover" 42 | // ], 43 | 44 | // An object that configures minimum threshold enforcement for coverage results 45 | // coverageThreshold: undefined, 46 | 47 | // A path to a custom dependency extractor 48 | // dependencyExtractor: undefined, 49 | 50 | // Make calling deprecated APIs throw helpful error messages 51 | // errorOnDeprecated: false, 52 | 53 | // The default configuration for fake timers 54 | // fakeTimers: { 55 | // "enableGlobally": false 56 | // }, 57 | 58 | // Force coverage collection from ignored files using an array of glob patterns 59 | // forceCoverageMatch: [], 60 | 61 | // A path to a module which exports an async function that is triggered once before all test suites 62 | // globalSetup: undefined, 63 | 64 | // A path to a module which exports an async function that is triggered once after all test suites 65 | // globalTeardown: undefined, 66 | 67 | // A set of global variables that need to be available in all test environments 68 | // globals: {}, 69 | 70 | // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. 71 | // maxWorkers: "50%", 72 | 73 | // An array of directory names to be searched recursively up from the requiring module's location 74 | // moduleDirectories: [ 75 | // "node_modules" 76 | // ], 77 | 78 | // An array of file extensions your modules use 79 | // moduleFileExtensions: [ 80 | // "js", 81 | // "mjs", 82 | // "cjs", 83 | // "jsx", 84 | // "ts", 85 | // "tsx", 86 | // "json", 87 | // "node" 88 | // ], 89 | 90 | // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module 91 | // moduleNameMapper: {}, 92 | 93 | // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader 94 | // modulePathIgnorePatterns: [], 95 | 96 | // Activates notifications for test results 97 | // notify: false, 98 | 99 | // An enum that specifies notification mode. Requires { notify: true } 100 | // notifyMode: "failure-change", 101 | 102 | // A preset that is used as a base for Jest's configuration 103 | // preset: undefined, 104 | 105 | // Run tests from one or more projects 106 | // projects: undefined, 107 | 108 | // Use this configuration option to add custom reporters to Jest 109 | // reporters: undefined, 110 | 111 | // Automatically reset mock state before every test 112 | // resetMocks: false, 113 | 114 | // Reset the module registry before running each individual test 115 | // resetModules: false, 116 | 117 | // A path to a custom resolver 118 | // resolver: undefined, 119 | 120 | // Automatically restore mock state and implementation before every test 121 | // restoreMocks: false, 122 | 123 | // The root directory that Jest should scan for tests and modules within 124 | // rootDir: undefined, 125 | 126 | // A list of paths to directories that Jest should use to search for files in 127 | // roots: [ 128 | // "" 129 | // ], 130 | 131 | // Allows you to use a custom runner instead of Jest's default test runner 132 | // runner: "jest-runner", 133 | 134 | // The paths to modules that run some code to configure or set up the testing environment before each test 135 | // setupFiles: [], 136 | 137 | // A list of paths to modules that run some code to configure or set up the testing framework before each test 138 | // setupFilesAfterEnv: [], 139 | 140 | // The number of seconds after which a test is considered as slow and reported as such in the results. 141 | // slowTestThreshold: 5, 142 | 143 | // A list of paths to snapshot serializer modules Jest should use for snapshot testing 144 | // snapshotSerializers: [], 145 | 146 | // The test environment that will be used for testing 147 | // testEnvironment: "jest-environment-node", 148 | 149 | // Options that will be passed to the testEnvironment 150 | // testEnvironmentOptions: {}, 151 | 152 | // Adds a location field to test results 153 | // testLocationInResults: false, 154 | 155 | // The glob patterns Jest uses to detect test files 156 | // testMatch: [ 157 | // "**/__tests__/**/*.[jt]s?(x)", 158 | // "**/?(*.)+(spec|test).[tj]s?(x)" 159 | // ], 160 | 161 | // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped 162 | // testPathIgnorePatterns: [ 163 | // "/node_modules/" 164 | // ], 165 | 166 | // The regexp pattern or array of patterns that Jest uses to detect test files 167 | // testRegex: [], 168 | 169 | // This option allows the use of a custom results processor 170 | // testResultsProcessor: undefined, 171 | 172 | // This option allows use of a custom test runner 173 | // testRunner: "jest-circus/runner", 174 | 175 | // A map from regular expressions to paths to transformers 176 | // transform: undefined, 177 | 178 | // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation 179 | // transformIgnorePatterns: [ 180 | // "/node_modules/", 181 | // "\\.pnp\\.[^\\/]+$" 182 | // ], 183 | 184 | // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them 185 | // unmockedModulePathPatterns: undefined, 186 | 187 | // Indicates whether each individual test should be reported during the run 188 | // verbose: undefined, 189 | 190 | // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode 191 | // watchPathIgnorePatterns: [], 192 | 193 | // Whether to use watchman for file crawling 194 | // watchman: true, 195 | }; 196 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-api1-project", 3 | "version": "1.0.0", 4 | "description": "Node API 1 Project Code", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "test": "cross-env NODE_ENV=testing jest --verbose --runInBand" 9 | }, 10 | "devDependencies": { 11 | "@types/jest": "^27.5.0", 12 | "cross-env": "^7.0.3", 13 | "eslint": "^8.15.0", 14 | "jest": "^28.1.0", 15 | "supertest": "^6.2.3" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/BloomInstituteOfTechnology/node-api1-project.git" 20 | }, 21 | "dependencies": { 22 | "nanoid": "^3.3.4" 23 | } 24 | } 25 | --------------------------------------------------------------------------------