Giter Site home page Giter Site logo

vidly-api-node's Introduction

Introduction

This project is the backend of Vidly, an imaginary video rental app. I've used Vidly as an example in several of my online programming courses, such as:

This is the implementation of Vidly in Node.js.

Setup

Make sure to follow all these steps exactly as explained below. Do not miss any steps or you won't be able to run this application.

Install MongoDB

To run this project, you need to install the latest version of MongoDB Community Edition first.

https://docs.mongodb.com/manual/installation/

Once you install MongoDB, make sure it's running.

Install the Dependencies

Next, from the project folder, install the dependencies:

npm i

Populate the Database

node seed.js

Run the Tests

You're almost done! Run the tests to make sure everything is working:

npm test

All tests should pass.

Start the Server

node index.js

This will launch the Node server on port 3900. If that port is busy, you can set a different point in config/default.json.

Open up your browser and head over to:

http://localhost:3900/api/genres

You should see the list of genres. That confirms that you have set up everything successfully.

(Optional) Environment Variables

If you look at config/default.json, you'll see a property called jwtPrivateKey. This key is used to encrypt JSON web tokens. So, for security reasons, it should not be checked into the source control. I've set a default value here to make it easier for you to get up and running with this project. For a production scenario, you should store this key as an environment variable.

On Mac:

export vidly_jwtPrivateKey=yourSecureKey

On Windows:

set vidly_jwtPrivateKey=yourSecureKey

vidly-api-node's People

Contributors

mosh-hamedani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vidly-api-node's Issues

npm install bug -> [email protected] library

Hello,

I learn to react with mosh at his website and we need to install this for the backend to vidly project but I got an error when I tried to install this library... I checked the library npm and it been told that this library was down from sever

what should I do now? I stuck and cannot move forward with my course.

image

URL String Parser is deprecated / Current Server Discovery and Monitoring engine

(node:6448) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:6448) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Done!

node seed.js DeprecationWarning

After wading through a number of problems with this outdated project, and failing to have a clean npm install, I got to the "node seed.js" bit, and got the following errors:

">node seed.js
(node:3140) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:3140) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Done!"

It is unclear to me whether these are errors emerging from the previous vulnerabilities when installing npm, or if this is simply an outdated command... I wonder if someone smarter than me can help me out, as I'm stuck on this!

Error when I'm trying to npm install in Windows 10 Please Help!!!

E:\React JS\Mastering React\vidly-api-node\vidly-api-node>npm i

[email protected] install E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v83-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v83-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI) (falling back to source compile with node-gyp)
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2017 (15.9.28307.1216) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp ERR! find VS - "Visual Studio C++ core features" missing
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack at VisualStudioFinder.fail (C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack at C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack at C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack at C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack at C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack at C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack at ChildProcess.exithandler (child_process.js:315:5)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1048:16)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt\lib\binding"
gyp ERR! cwd E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt
gyp ERR! node -v v14.15.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt\lib\binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1048:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt
node-pre-gyp ERR! node -v v14.15.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok
gypFailed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Soumyadeep Mondal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=E:\React JS\Mastering React\vidly-api-node\vidly-api-node\node_modules\bcrypt\lib\binding' (1)
ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2017 (15.9.28307.1216) found at:
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Soumyadeep Mondal\AppData\Roaming\npm-cache_logs\2021-03-23T17_42_40_519Z-debug.log

SyntaxError: Unexpected token function

I have run
node seed.js
and I get the below error. I retyped the function again and deleted the existing line in the JS file and still did not work.
Can you assist me please?

D:\Projects\ReactJS\vidly-api-node\seed.js:41
async function seed() {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)

npm i not working coming from React Course

This is the error I get when running npm i, please help

PS I:\Work\Learning React\vidly-api-node> npm i

[email protected] install I:\Work\Learning React\vidly-api-node\node_modules\bcrypt
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v72-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v72-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI) (falling back to source compile with node-gyp)
gyp ERR! find VS
gyp ERR!gyp find VS msvs_version not set from command line or npm config
gypERR! ERR!find VS
find VSgyp VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config
could not use PowerShell to find Visual Studio 2017 or newer
gypgyp ERR!ERR! find VSfind VS VCINSTALLDIR not set, not running in VS Command Prompt
looking for Visual Studio 2015
gypgyp ERR!ERR! find VSfind VS could not use PowerShell to find Visual Studio 2017 or newer

  • not found
    gypgyp ERR! find VSERR! looking for Visual Studio 2015
    gypfind VS not looking for VS2013 as it is only supported up to Node.js 8
    ERR!gyp find VSERR! - not found
    gypfind VS
    ERR!gyp find VSERR! not looking for VS2013 as it is only supported up to Node.js 8
    gypfind VS **************************************************************
    ERR!gyp find VSERR!
    gypfind VS You need to install the latest version of Visual Studio
    ERR!gyp find VSERR! **************************************************************
    gypfind VS including the "Desktop development with C++" workload.
    ERR!gyp find VSERR! You need to install the latest version of Visual Studio
    gypfind VS For more information consult the documentation at:
    ERR!gyp find VSERR! including the "Desktop development with C++" workload.
    gypfind VS https://github.com/nodejs/node-gyp#on-windows
    ERR!gyp find VSERR! For more information consult the documentation at:
    gypfind VS **************************************************************
    ERR!gyp find VSERR! https://github.com/nodejs/node-gyp#on-windows
    gypfind VS
    ERR! find VS **************************************************************
    gyp ERR! find VS
    gyp gypERR! ERR!configure error
    configure errorgyp
    gypERR! stackERR! Error: Could not find any Visual Studio installation to use
    gypstack Error: Could not find any Visual Studio installation to use
    ERR!gyp ERR!stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
    stackgyp at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
    gyp ERR!ERR! stackstack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
    at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
    gypgyp ERR!ERR! stackstack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
    at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
    gypgyp ERR!ERR! stackstack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
    at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
    gypgyp ERR!ERR! stackstack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
    at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
    gypgyp ERR!ERR! stackstack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
    gyp at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
    gypERR! ERR!stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
    gypstack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
    ERR!gyp stackERR! at ChildProcess.exithandler (child_process.js:310:5)
    gyp stackERR! at ChildProcess.exithandler (child_process.js:310:5)
    gyp stackERR! at ChildProcess.emit (events.js:315:20)
    gypstack at ChildProcess.emit (events.js:315:20)
    gypERR! ERR!stack at maybeClose (internal/child_process.js:1021:16)
    stackgyp at maybeClose (internal/child_process.js:1021:16)
    gypERR! ERR!System Windows_NT 10.0.19041
    Systemgyp Windows_NT 10.0.19041
    ERR! gyp commandERR! "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=I:\Work\Learning React\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=I:\Work\Learning React\vidly-api-node\node_modules\bcrypt\lib\binding"
    gypcommand "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=I:\Work\Learning React\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=I:\Work\Learning React\vidly-api-node\node_modules\bcrypt\lib\binding"
    ERR!gyp cwdERR! I:\Work\Learning React\vidly-api-node\node_modules\bcrypt
    gypcwd I:\Work\Learning React\vidly-api-node\node_modules\bcrypt
    ERR!gyp node -vERR! v12.18.4
    gypnode -v v12.18.4
    ERR!gyp node-gyp -vERR! v5.1.0
    gypnode-gyp -v v5.1.0
    ERR!gyp not okERR!
    not ok
    node-pre-gyp ERR! build error
    node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=I:\Work\Learning React\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=I:\Work\Learning React\vidly-api-node\node_modules\bcrypt\lib\binding' (1)
    node-pre-gyp ERR! stack at ChildProcess. (I:\Work\Learning React\vidly-api-node\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
    node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
    node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
    node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
    node-pre-gyp ERR! System Windows_NT 10.0.19041
    node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "I:\Work\Learning React\vidly-api-node\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
    node-pre-gyp ERR! cwd I:\Work\Learning React\vidly-api-node\node_modules\bcrypt
    node-pre-gyp ERR! node -v v12.18.4
    node-pre-gyp ERR! node-pre-gyp -v v0.6.36
    node-pre-gyp ERR! not ok
    Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=I:\Work\Learning React\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=I:\Work\Learning React\vidly-api-node\node_modules\bcrypt\lib\binding' (1)
    npm WARN [email protected] No repository field.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shess\AppData\Roaming\npm-cache_logs\2020-09-28T20_25_34_844Z-debug.log

Increased auth performance

Hello, I am a starting with node.js and I found something interesting:

On auth file in routes folder I changed this on line 17:

const validPassword = await bcrypt.compare(req.body.password, user.password);
if (!validPassword) return res.status(400).send("Invalid email or password.");

image

to this:

await bcrypt.compare(req.body.password, user.password, function(err, result) {
    if (!result) return res.status(400).send("Invalid email or password.");
});

image

and decreased request processing time from 85 ms to 5 ms average.

Why is that?

Note: I am using bcrypt v3.0.6

Thank you very much

npm test fail

Unfortunately I can't finish the course "Mastering React" because I can't get "npm test" to run in the "Section 8 Calling Backend Services". It always aborts with the error message. (see below)

  1. I installed user dataset manually
  2. I installed bcrypt manually

but it didn't help.

at Object.close (tests/integration/returns.test.js:55:18)

โ— /api/returns โ€บ should return 200 if we have a valid request

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/returns โ€บ should return 200 if we have a valid request

TypeError: app.address is not a function

  16 |   const exec = () => {
  17 |     return request(server)
> 18 |       .post('/api/returns')
     |        ^
  19 |       .set('x-auth-token', token)
  20 |       .send({ customerId, movieId });
  21 |   };

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/returns.test.js:18:8)
  at Object.exec (tests/integration/returns.test.js:102:23)

โ— /api/returns โ€บ should return 200 if we have a valid request

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

โ— /api/returns โ€บ should set the returnDate if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/returns โ€บ should set the returnDate if input is valid

TypeError: app.address is not a function

  16 |   const exec = () => {
  17 |     return request(server)
> 18 |       .post('/api/returns')
     |        ^
  19 |       .set('x-auth-token', token)
  20 |       .send({ customerId, movieId });
  21 |   };

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/returns.test.js:18:8)
  at Object.exec (tests/integration/returns.test.js:108:23)

โ— /api/returns โ€บ should set the returnDate if input is valid

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

โ— /api/returns โ€บ should set the rentalFee if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/returns โ€บ should set the rentalFee if input is valid

TypeError: Cannot set property 'dateOut' of undefined

  114 | 
  115 |   it('should set the rentalFee if input is valid', async () => {
> 116 |     rental.dateOut = moment().add(-7, 'days').toDate();
      |     ^
  117 |     await rental.save();
  118 | 
  119 |     const res = await exec();

  at Object.<anonymous> (tests/integration/returns.test.js:116:5)

โ— /api/returns โ€บ should set the rentalFee if input is valid

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

โ— /api/returns โ€บ should increase the movie stock if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/returns โ€บ should increase the movie stock if input is valid

TypeError: app.address is not a function

  16 |   const exec = () => {
  17 |     return request(server)
> 18 |       .post('/api/returns')
     |        ^
  19 |       .set('x-auth-token', token)
  20 |       .send({ customerId, movieId });
  21 |   };

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/returns.test.js:18:8)
  at Object.exec (tests/integration/returns.test.js:126:23)

โ— /api/returns โ€บ should increase the movie stock if input is valid

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

โ— /api/returns โ€บ should return the rental if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/returns โ€บ should return the rental if input is valid

TypeError: app.address is not a function

  16 |   const exec = () => {
  17 |     return request(server)
> 18 |       .post('/api/returns')
     |        ^
  19 |       .set('x-auth-token', token)
  20 |       .send({ customerId, movieId });
  21 |   };

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/returns.test.js:18:8)
  at Object.exec (tests/integration/returns.test.js:133:23)

โ— /api/returns โ€บ should return the rental if input is valid

TypeError: server.close is not a function

  53 | 
  54 |   afterEach(async () => {
> 55 |     await server.close(); 
     |                  ^
  56 |     await Rental.remove({});
  57 |     await Movie.remove({});
  58 |   });

  at Object.close (tests/integration/returns.test.js:55:18)

FAIL tests/integration/genres.test.js (81.21s)
/api/genres
GET /
ร— should return all genres (5997ms)
GET /:id
ร— should return a genre if valid id is passed (5013ms)
ร— should return 404 if invalid id is passed (4ms)
ร— should return 404 if no genre with the given id exists (7ms)
POST /
ร— should return 401 if client is not logged in (39ms)
ร— should return 400 if genre is less than 5 characters (11ms)
ร— should return 400 if genre is more than 50 characters (22ms)
ร— should save the genre if it is valid (8ms)
ร— should return the genre if it is valid (10ms)
PUT /:id
ร— should return 401 if client is not logged in (5006ms)
ร— should return 400 if genre is less than 5 characters (5004ms)
ร— should return 400 if genre is more than 50 characters (5005ms)
ร— should return 404 if id is invalid (5006ms)
ร— should return 404 if genre with the given id was not found (5009ms)
ร— should update the genre if input is valid (5002ms)
ร— should return the updated genre if it is valid (5003ms)
DELETE /:id
ร— should return 401 if client is not logged in (5002ms)
ร— should return 403 if the user is not an admin (5004ms)
ร— should return 404 if id is invalid (5003ms)
ร— should return 404 if no genre with the given id was found (5001ms)
ร— should delete the genre if input is valid (5003ms)
ร— should return the removed genre (5006ms)

โ— /api/genres โ€บ GET / โ€บ should return all genres

Cannot find module 'bcrypt' from 'users.js'

However, Jest was able to find:
    '../routes/users.js'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

However, Jest was able to find:
    'startup/routes.js'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

However, Jest was able to find:
    '../../index.js'

You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

  1 | const auth = require("../middleware/auth");
> 2 | const bcrypt = require("bcrypt");
    |                ^
  3 | const _ = require("lodash");
  4 | const { User, validate } = require("../models/user");
  5 | const express = require("express");

  at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:230:17)
  at Object.require (routes/users.js:2:16)

โ— /api/genres โ€บ GET / โ€บ should return all genres

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:

  14 | 
  15 |   describe('GET /', () => {
> 16 |     it('should return all genres', async () => {
     |     ^
  17 |       const genres = [
  18 |         { name: 'genre1' },
  19 |         { name: 'genre2' },

  at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
  at Suite.it (tests/integration/genres.test.js:16:5)
  at Suite.describe (tests/integration/genres.test.js:15:3)
  at Object.describe (tests/integration/genres.test.js:8:1)

โ— /api/genres โ€บ GET / โ€บ should return all genres

TypeError: Cannot read property 'close' of undefined

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ GET /:id โ€บ should return a genre if valid id is passed

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:

  32 | 
  33 |   describe('GET /:id', () => {
> 34 |     it('should return a genre if valid id is passed', async () => {
     |     ^
  35 |       const genre = new Genre({ name: 'genre1' });
  36 |       await genre.save();
  37 | 

  at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
  at Suite.it (tests/integration/genres.test.js:34:5)
  at Suite.describe (tests/integration/genres.test.js:33:3)
  at Object.describe (tests/integration/genres.test.js:8:1)

โ— /api/genres โ€บ GET /:id โ€บ should return a genre if valid id is passed

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ GET /:id โ€บ should return 404 if invalid id is passed

TypeError: app.address is not a function

  43 | 
  44 |     it('should return 404 if invalid id is passed', async () => {
> 45 |       const res = await request(server).get('/api/genres/1');
     |                                         ^
  46 | 
  47 |       expect(res.status).toBe(404);
  48 |     });

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as get] (node_modules/supertest/index.js:25:14)
  at Object.get (tests/integration/genres.test.js:45:41)

โ— /api/genres โ€บ GET /:id โ€บ should return 404 if invalid id is passed

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ GET /:id โ€บ should return 404 if no genre with the given id exists

TypeError: app.address is not a function

  50 |     it('should return 404 if no genre with the given id exists', async () => {
  51 |       const id = mongoose.Types.ObjectId();
> 52 |       const res = await request(server).get('/api/genres/' + id);
     |                                         ^
  53 | 
  54 |       expect(res.status).toBe(404);
  55 |     });

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as get] (node_modules/supertest/index.js:25:14)
  at Object.get (tests/integration/genres.test.js:52:41)

โ— /api/genres โ€บ GET /:id โ€บ should return 404 if no genre with the given id exists

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ POST / โ€บ should return 401 if client is not logged in

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:81:25)

โ— /api/genres โ€บ POST / โ€บ should return 401 if client is not logged in

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ POST / โ€บ should return 400 if genre is less than 5 characters

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:89:25)

โ— /api/genres โ€บ POST / โ€บ should return 400 if genre is less than 5 characters

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ POST / โ€บ should return 400 if genre is more than 50 characters

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:97:25)

โ— /api/genres โ€บ POST / โ€บ should return 400 if genre is more than 50 characters

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ POST / โ€บ should save the genre if it is valid

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:103:13)

โ— /api/genres โ€บ POST / โ€บ should save the genre if it is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ POST / โ€บ should return the genre if it is valid

TypeError: app.address is not a function

  66 |     const exec = async () => {
  67 |       return await request(server)
> 68 |         .post('/api/genres')
     |          ^
  69 |         .set('x-auth-token', token)
  70 |         .send({ name });
  71 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as post] (node_modules/supertest/index.js:25:14)
  at post (tests/integration/genres.test.js:68:10)
  at Object.exec (tests/integration/genres.test.js:111:25)

โ— /api/genres โ€บ POST / โ€บ should return the genre if it is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ PUT /:id โ€บ should return 401 if client is not logged in

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ PUT /:id โ€บ should return 401 if client is not logged in

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:145:25)

โ— /api/genres โ€บ PUT /:id โ€บ should return 401 if client is not logged in

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ PUT /:id โ€บ should return 400 if genre is less than 5 characters

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ PUT /:id โ€บ should return 400 if genre is less than 5 characters

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:153:25)

โ— /api/genres โ€บ PUT /:id โ€บ should return 400 if genre is less than 5 characters

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ PUT /:id โ€บ should return 400 if genre is more than 50 characters

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ PUT /:id โ€บ should return 400 if genre is more than 50 characters

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:161:25)

โ— /api/genres โ€บ PUT /:id โ€บ should return 400 if genre is more than 50 characters

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ PUT /:id โ€บ should return 404 if id is invalid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ PUT /:id โ€บ should return 404 if id is invalid

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:169:25)

โ— /api/genres โ€บ PUT /:id โ€บ should return 404 if id is invalid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ PUT /:id โ€บ should return 404 if genre with the given id was not found

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ PUT /:id โ€บ should return 404 if genre with the given id was not found

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:177:25)

โ— /api/genres โ€บ PUT /:id โ€บ should return 404 if genre with the given id was not found

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ PUT /:id โ€บ should update the genre if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ PUT /:id โ€บ should update the genre if input is valid

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:183:13)

โ— /api/genres โ€บ PUT /:id โ€บ should update the genre if input is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ PUT /:id โ€บ should return the updated genre if it is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ PUT /:id โ€บ should return the updated genre if it is valid

TypeError: app.address is not a function

  124 |     const exec = async () => {
  125 |       return await request(server)
> 126 |         .put('/api/genres/' + id)
      |          ^
  127 |         .set('x-auth-token', token)
  128 |         .send({ name: newName });
  129 |     }

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> [as put] (node_modules/supertest/index.js:25:14)
  at put (tests/integration/genres.test.js:126:10)
  at Object.exec (tests/integration/genres.test.js:191:25)

โ— /api/genres โ€บ PUT /:id โ€บ should return the updated genre if it is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 401 if client is not logged in

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 401 if client is not logged in

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:223:25)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 401 if client is not logged in

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 403 if the user is not an admin

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 403 if the user is not an admin

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:231:25)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 403 if the user is not an admin

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 404 if id is invalid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 404 if id is invalid

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:239:25)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 404 if id is invalid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 404 if no genre with the given id was found

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 404 if no genre with the given id was found

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:247:25)

โ— /api/genres โ€บ DELETE /:id โ€บ should return 404 if no genre with the given id was found

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ DELETE /:id โ€บ should delete the genre if input is valid

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ DELETE /:id โ€บ should delete the genre if input is valid

TypeError: app.address is not a function

  202 | 
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:253:13)

โ— /api/genres โ€บ DELETE /:id โ€บ should delete the genre if input is valid

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close(); 
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 | 

  at Object.close (tests/integration/genres.test.js:11:18)

โ— /api/genres โ€บ DELETE /:id โ€บ should return the removed genre

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

  at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

โ— /api/genres โ€บ DELETE /:id โ€บ should return the removed genre

TypeError: app.address is not a function

  202 |
  203 |     const exec = async () => {
> 204 |       return await request(server)
      |                    ^
  205 |         .delete('/api/genres/' + id)
  206 |         .set('x-auth-token', token)
  207 |         .send();

  at Test.Object.<anonymous>.Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
  at new Test (node_modules/supertest/lib/test.js:36:12)
  at Object.obj.<computed> (node_modules/supertest/index.js:25:14)
  at exec (tests/integration/genres.test.js:204:20)
  at Object.exec (tests/integration/genres.test.js:261:25)

โ— /api/genres โ€บ DELETE /:id โ€บ should return the removed genre

TypeError: server.close is not a function

   9 |   beforeEach(() => { server = require('../../index'); })
  10 |   afterEach(async () => {
> 11 |     await server.close();
     |                  ^
  12 |     await Genre.remove({});
  13 |   });
  14 |

  at Object.close (tests/integration/genres.test.js:11:18)

Test Suites: 3 failed, 2 passed, 5 total
Tests: 35 failed, 2 passed, 37 total
Snapshots: 0 total
Time: 84.325s
Ran all test suites.

Watch Usage
โ€บ Press f to run only failed tests.
โ€บ Press o to only run tests related to changed files.
โ€บ Press p to filter by a filename regex pattern.
โ€บ Press t to filter by a test name regex pattern.
โ€บ Press q to quit watch mode.
โ€บ Press Enter to trigger a test run.

MongoDB Compass doesn't show the vidly-tests folder or the users folder inside the vidly folder?

Hi everyone,

I'm doing the Mastering React course, Calling Backend Services section on Lesson 20. So I solved one issue, which was in the MongoDB Compass, and the problem was that the vidly folder was not showing in my cluster / database but I couldn't get the users folder inside the vidly folder and I didn't get the vidly-tests folder either.

No users folder?
No vidly-tests folder?
Tests failed

Also when I run npm test all of the tests fail (see Tests failed image) and I don't get why. I did everything he did properly and I also looked on the React 2019 Course | Bcrypt issue and I updated it, did npm i and I also deleted the package-lock.json because it gave me an error when I ran npm i. Please help with this issue, I would very much appreciate it.

I rewatched the videos, (Lesson 19 and 20) over 4 times and researched them in his forum and on the net. I hope I explained my problem well, if you need anymore details please ask me.

Thanks!

Pug issue

I have implemented the templating engine "Pug" the way explained in lecture but getting "TypeError: View is not a constructor". If anyone had this issue before, do let me know. Thanks

"pug": "^3.0.0"

Issue-The value entering into Object field

Hi, I am not able to enter value to field which is created as object and same i have validated using Joi.
I am getting error "it (field name) must be an Object'.
Could you please help me to how to handle?
Thanks!

node seed.js fails

I'm running through the React course now and just installed MongoDB. I run node seed.js and get the error:

Ryan@DESKTOP-ILLP59F MINGW64 ~/Desktop/code-projects/react/Section 8- Calling Backend Services/start/vidly-api-node (master)
$ node seed.js
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'joi'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\Users\Ryan\Desktop\code-projects\react\Section 8-
Calling Backend Services\start\vidly-api-node\models\genre.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Is joi not initialized on the project?

node index.js is not running

{"date":"Sun May 07 2023 16:46:46 GMT+0530 (India Standard Time)","error":{},"exception":true,"level":"error","message":"uncaughtException: The provided mongoose instance is invalid\nError: The provided mongoose instance is invalid\n at Object.init (C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\node_modules\fawn\lib\fawn.js:30:15)\n at Object. (C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\routes\rentals.js:11:6)\n at Module._compile (node:internal/modules/cjs/loader:1254:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)\n at Module.load (node:internal/modules/cjs/loader:1117:32)\n at Module._load (node:internal/modules/cjs/loader:958:12)\n at Module.require (node:internal/modules/cjs/loader:1141:19)\n at require (node:internal/modules/cjs/helpers:110:18)\n at Object. (C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\startup\routes.js:5:17)\n at Module._compile (node:internal/modules/cjs/loader:1254:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)\n at Module.load (node:internal/modules/cjs/loader:1117:32)\n at Module._load (node:internal/modules/cjs/loader:958:12)\n at Module.require (node:internal/modules/cjs/loader:1141:19)\n at require (node:internal/modules/cjs/helpers:110:18)\n at Object. (C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\index.js:8:1)","os":{"loadavg":[0,0,0],"uptime":55895.156},"process":{"argv":["C:\Program Files\nodejs\node.exe","C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\index.js"],"cwd":"C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node","execPath":"C:\Program Files\nodejs\node.exe","gid":null,"memoryUsage":{"arrayBuffers":18367963,"external":19193702,"heapTotal":59416576,"heapUsed":29415504,"rss":85082112},"pid":18320,"uid":null,"version":"v18.14.1"},"stack":"Error: The provided mongoose instance is invalid\n at Object.init (C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\node_modules\fawn\lib\fawn.js:30:15)\n at Object. (C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\routes\rentals.js:11:6)\n at Module._compile (node:internal/modules/cjs/loader:1254:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)\n at Module.load (node:internal/modules/cjs/loader:1117:32)\n at Module._load (node:internal/modules/cjs/loader:958:12)\n at Module.require (node:internal/modules/cjs/loader:1141:19)\n at require (node:internal/modules/cjs/helpers:110:18)\n at Object. (C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\startup\routes.js:5:17)\n at Module._compile (node:internal/modules/cjs/loader:1254:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)\n at Module.load (node:internal/modules/cjs/loader:1117:32)\n at Module._load (node:internal/modules/cjs/loader:958:12)\n at Module.require (node:internal/modules/cjs/loader:1141:19)\n at require (node:internal/modules/cjs/helpers:110:18)\n at Object. (C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\index.js:8:1)","trace":[{"column":15,"file":"C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\node_modules\fawn\lib\fawn.js","function":"Object.init","line":30,"method":"init","native":false},{"column":6,"file":"C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\routes\rentals.js","function":null,"line":11,"method":null,"native":false},{"column":14,"file":"node:internal/modules/cjs/loader","function":"Module._compile","line":1254,"method":"_compile","native":false},{"column":10,"file":"node:internal/modules/cjs/loader","function":"Module._extensions..js","line":1308,"method":".js","native":false},{"column":32,"file":"node:internal/modules/cjs/loader","function":"Module.load","line":1117,"method":"load","native":false},{"column":12,"file":"node:internal/modules/cjs/loader","function":"Module._load","line":958,"method":"_load","native":false},{"column":19,"file":"node:internal/modules/cjs/loader","function":"Module.require","line":1141,"method":"require","native":false},{"column":18,"file":"node:internal/modules/cjs/helpers","function":"require","line":110,"method":null,"native":false},{"column":17,"file":"C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\startup\routes.js","function":null,"line":5,"method":null,"native":false},{"column":14,"file":"node:internal/modules/cjs/loader","function":"Module._compile","line":1254,"method":"_compile","native":false},{"column":10,"file":"node:internal/modules/cjs/loader","function":"Module._extensions..js","line":1308,"method":".js","native":false},{"column":32,"file":"node:internal/modules/cjs/loader","function":"Module.load","line":1117,"method":"load","native":false},{"column":12,"file":"node:internal/modules/cjs/loader","function":"Module._load","line":958,"method":"_load","native":false},{"column":19,"file":"node:internal/modules/cjs/loader","function":"Module.require","line":1141,"method":"require","native":false},{"column":18,"file":"node:internal/modules/cjs/helpers","function":"require","line":110,"method":null,"native":false},{"column":1,"file":"C:\Users\saurav kumar\OneDrive\Documents\react\vidly-api-node\index.js","function":null,"line":8,"method":null,"native":false}]}

React Course: Vidly app Deployment in 2019

Screenshot (1)
Screenshot (2)

I HAVE FOLLOWED EXACTLY STEP BY STEP OF WHAT MOSH TAUGHT BUT THE CONNECTION STRING FROM MONGODB ATLAS IS USED HERE INSTEAD OF THE MLAB WHICH MOSH TAUGHT BECAUSE THE MLAB IS BOUGHT BY MONGODB. I FOLLOWED THE MONGODB ATLAS GUIDE AND PICKED UP THE CONNECTION STRING FROM THE "CONNECT WITH MONGODB COMPASS" OPTION. I HAVE DONE EXACTLY WHAT MOSH TAUGHT BUT IT IS SHOWING THE ABOVEMENTIONED ERRORS. PLEASE HELP.

Section Authentication and Authorization can not be learnt and followed

Because of the issue in backed where the mongo database is not populated with users and auth collections, this sections is really a waste of time and very disappointing to the whole course which is designed very well!

@mosh-hamedani Could please fix the issue bcrypt and particularly why the database is not populated with Users and Auth collections and how to add them.

I am using windows 10

Thanks

Integration tests are failing randomly

Summary

Integration tests fail in a random manner.

Steps

  1. Run npm test

Result:

Some integration tests are failing with:

...................

auth middleware
    โœ• should return 401 if no token is provided (342ms)
    โœ• should return 400 if token is invalid (132ms)
    โœ“ should return 200 if token is valid (122ms)

  โ— auth middleware โ€บ should return 401 if no token is provided

    listen EADDRINUSE :::3900

      12 | 
      13 | const port = process.env.PORT || config.get("port");
    > 14 | const server = app.listen(port, () =>
      15 |   winston.info(`Listening on port ${port}...`)
      16 | );

...............

Expected Result

All tests (unit and integration) should pass

Probable reason

Race condition. The server has not been stopped on time when the next test cases initiates.

React > Unable to add user.

I have followed full instruction and was able to add Movies and Edit them perfectly. However, when I trying ADDING (Post) user while all my configuration is perfect and according to Mosh... I keep on getting "Server responded with a status of 500 (Internal Server Error). Also on node.js command prompt screen I am getting following error.

error: bcrypt.genSalt is not a function TypeError: bcrypt.genSalt is not a function
at router.post (C:\React\vidly-api-node\routes\users.js:21:29)

I user Google extention Postman and same issue there too.

However, when I added user manually in Mongodb and add same record through Vidly it caught the recod and threw User Already Exit message.

Tests fail

when two integration tests run using same port. one of them gets
listen EADDRINUSE :::3900

steps to reproduce

  1. clone
  2. npm i
  3. mongod
  4. node seed.js
  5. npm test

I'm using

  • Node version 8.11.3
  • NPM version 5.6.0

September 2020: Unable to add new movies

Hello there,
Whenever I try to add new movies via Postman I get a 404 error: "title" is required.
Here is my request body(row->JSON):
{ "title":"The Lord of The Rings", "numberInStock":2, "dailyRentalRate":5, "genreId":"5f607904cdb2ec2d701930a7" }

React 2019 Course | Bcrypt error

Unable to run "npm i", because i'm getting a bcrypt error unable to download and some other dependencies like node, node-gyp and node-pre-gy.
My solution was to installing these packages on their own and instead of using bcrypt, i used bcryptjs.
Afterwards you need to go into the auth and users file and change:
const bcrypt = require("bcrypt");
to
const bcrypt = require("bcryptjs");
and it should be working fine.

Error When Try to install by using npm i

Hi Mosh, when I try to install by using npm i then it's showing error and not installed properly, if you could look into this issue then it would be great.

Thanks

One of the properties of customer `isGold` is not override in rentals api

One of the properties of customer isGold is not override in rentals api

When we call rental post route ( like this http://localhost:3000/api/rentals/) with given value

{
    "customerId":"5f6f53afb53731ef06d7c01e",
    "movieId":"5f6f5180b53731ef06d7c01c"
}

although our customer is Gold customer it is not assign in rental document it shows isGold:false .

{
    "_id": "5f6f55548ac0e2f2c6532571",
    "customer": {
        "isGold": false,
        "_id": "5f6f53afb53731ef06d7c01e",
        "name": "Soumadip Dey",
        "phone": "8768454982"
    },
    "movie": {
        "_id": "5f6f5180b53731ef06d7c01c",
        "title": "Ratsasant",
        "dailyRentalRate": 20
    },
    "dateOut": "2020-09-26T14:51:00.943Z",
    "__v": 0
}

It's happening for the rental schema's customer customer child schema's isGold default value

isGold: {
        type: Boolean,
        default: false
      }

sollution

We need to override isGold property in rental api's post route like this

 
customer: {
      _id: customer._id,
      name: customer.name, 
      phone: customer.phone,
      isGold:customer.isGold
    }

Solution to those who are not able to POST 'users' data to the DB or the 'bcrypt' error.

Just install 'bcrypt' if not already or check if already installed.
npm i bcrypt

Now, in your vidly-api-node folder goto routes folder and open up users.js in your code editor. and change this code (probably on line 21 & 22):
const salt = await bcrypt.genSalt(10); user.password = await bcrypt.hash(user.password, salt);
with this:
const saltRounds = 10; const myPlaintextPassword = user.password; const bcrypt = require("bcrypt"); const salt = bcrypt.genSaltSync(saltRounds); const hash = bcrypt.hashSync(myPlaintextPassword, salt); user.password = hash;
Save the file and you are good to go :)

node seed.js fail

/Users/user/Development/vidly-api-node/node_modules/mongodb-core/lib/connection/pool.js:595
          return handleOperationCallback(self, workItem.cb, new MongoError(message.documents[0]));
                                                            ^
MongoError: Unsupported OP_QUERY command: delete. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal
    at /Users/user/Development/vidly-api-node/node_modules/mongodb-core/lib/connection/pool.js:595:61
    at authenticateStragglers (/Users/user/Development/vidly-api-node/node_modules/mongodb-core/lib/connection/pool.js:513:16)
    at Connection.messageHandler (/Users/user/Development/vidly-api-node/node_modules/mongodb-core/lib/connection/pool.js:549:5)
    at emitMessageHandler (/Users/user/Development/vidly-api-node/node_modules/mongodb-core/lib/connection/connection.js:309:10)
    at Socket.<anonymous> (/Users/user/Development/vidly-api-node/node_modules/mongodb-core/lib/connection/connection.js:452:17)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  ok: 0,
  errmsg: 'Unsupported OP_QUERY command: delete. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal',
  code: 352,
  codeName: 'UnsupportedOpQueryCommand'
}

Multiple returns issue on /api/returns

1- user returns a rental and rental fee is calculated.
2-same user rents the same movie but in a different timestamp.
3-rentals.lookup() fails to distinguish between newly added rental(same movie) and the processed rental -->exp: i have watched matrix 2 for almost 5 times :D

bcrypt can not be installed

When I try to install the dependencies to the backend service with command "npm i" then one of them can not be found on the given github release link therefore end up with the error: "Failed at the [email protected] install script".

The exact error message is:
node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v64-win32-x64.tar.gz

I am not sure where this link coming from, i did not find it in the package-lock.json.
However, it is really wrong and gets to a 404.

Sorry for the noob question, I'm really new in node. Thank You for the answer in advance.

npm install produces a lot of errors as shown below

[email protected] install C:\projects\vidly-api-node\node_modules\bcrypt
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v79-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v79 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v79-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v79 ABI) (falling back to source compile with node-gyp)
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if the py launcher can be used to find Python 2
gyp ERR! find Python - "py.exe" is not in PATH or produced an error
gyp ERR! find Python checking if Python is C:\Python27\python.exe
gyp ERR! find Python - "C:\Python27\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Python37\python.exe
gyp ERR! find Python - "C:\Python37\python.exe" could not be run
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
gyp ERR! find Python (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python npm config set python "C:\Path\To\python.exe"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! gypfind Python
gyp ERR! ERR!find Python Python is not set from command line or npm configuration
gypconfigure error ERR!
find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gypgyp ERR! stack Error: Could not find any Python installation to use
ERR!gyp ERR! find Pythonstack - "python2" is not in PATH or produced an error
at PythonFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:307:47)
gypgyp ERR! stack at PythonFinder.runChecks (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:136:21)
ERR!gyp find PythonERR! checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Pythonstack at PythonFinder. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:225:16)
gyp ERR! stack at PythonFinder.execFileCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:271:16)
gyp ERR! stack at exithandler (child_process.js:310:5)
gyp ERR! stack at ChildProcess.errorhandler (child_process.js:322:5)
gyp ERR! stack at ChildProcess.emit (events.js:321:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
gyp ERR! stack at onErrorNT (internal/child_process.js:469:16)
gyp ERR! stack at processTicksAndRejections (internal/process/task_queues.js:84:21)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\projects\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\projects\vidly-api-node\node_modules\bcrypt\lib\binding"
gyp ERR! cwd C:\projects\vidly-api-node\node_modules\bcrypt
gyp ERR! node -v v13.6.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
checking if the py launcher can be used to find Python 2
gyp ERR! find Python - "py.exe" is not in PATH or produced an error
gyp ERR! find Python checking if Python is C:\Python27\python.exe
gyp ERR! find Python - "C:\Python27\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Python37\python.exe
gyp ERR! find Python - "C:\Python37\python.exe" could not be run
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
gyp ERR! find Python (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python npm config set python "C:\Path\To\python.exe"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack at PythonFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:307:47)
gyp ERR! stack at PythonFinder.runChecks (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:136:21)
gyp ERR! stack at PythonFinder. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:225:16)
gyp ERR! stack at PythonFinder.execFileCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:271:16)
gyp ERR! stack at exithandler (child_process.js:310:5)
gyp ERR! stack at ChildProcess.errorhandler (child_process.js:322:5)
gyp ERR! stack at ChildProcess.emit (events.js:321:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
gyp ERR! stack at onErrorNT (internal/child_process.js:469:16)
gyp ERR! stack at processTicksAndRejections (internal/process/task_queues.js:84:21)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\projects\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\projects\vidly-api-node\node_modules\bcrypt\lib\binding"
gyp ERR! cwd C:\projects\vidly-api-node\node_modules\bcrypt
gyp ERR! node -v v13.6.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\projects\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\projects\vidly-api-node\node_modules\bcrypt\lib\binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (C:\projects\vidly-api-node\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:321:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1028:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Windows_NT 10.0.18362
node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\projects\vidly-api-node\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\projects\vidly-api-node\node_modules\bcrypt
node-pre-gyp ERR! node -v v13.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\projects\vidly-api-node\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\projects\vidly-api-node\node_modules\bcrypt\lib\binding' (1)
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Yonus Bakhshi\AppData\Roaming\npm-cache_logs\2020-01-31T20_09_24_774Z-debug.log

I am taking the React course and so far progressed very well but right now i am stack here after setting the Mongodb but setting up the project vidly-api-node does not work.

Your help in this regard will be highly appreciated!

npm test fails with Error: Cannot find module 'walker'

[email protected] test C:\projects\vidly-api-node
jest --watchAll --verbose --runInBand

Error: Cannot find module 'walker'
Require stack:

  • C:\projects\vidly-api-node\node_modules\sane\src\common.js
  • C:\projects\vidly-api-node\node_modules\sane\src\node_watcher.js
  • C:\projects\vidly-api-node\node_modules\sane\index.js
  • C:\projects\vidly-api-node\node_modules\jest\node_modules\jest-cli\node_modules\jest-haste-map\build\index.js
  • C:\projects\vidly-api-node\node_modules\jest\node_modules\jest-cli\node_modules\jest-runtime\build\index.js
  • C:\projects\vidly-api-node\node_modules\jest\node_modules\jest-cli\build\cli\index.js
  • C:\projects\vidly-api-node\node_modules\jest\node_modules\jest-cli\bin\jest.js
  • C:\projects\vidly-api-node\node_modules\jest\bin\jest.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object. (C:\projects\vidly-api-node\node_modules\sane\src\common.js:3:14)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    npm ERR! Test failed. See above for more details.

seed.js does not populate users

Hi, this problem still exists. It seems the github download as of today is incomplete and missing parts which completely hinders the ability to continue the tutorial. I spent a while to figure it out and this is how you can insert it yourself and then also change the api so that it is readable by the web.

Go to command prompt and type "mongo" to enter the shell
type "use vidly" to use that db
type
db.users.insert(
{
"name":"Tom Hanks",
"email":"[email protected]",
"password":"234242"
})
Now youve inserted and created a new collections called "users" with one object

Go to vidly-api-node folder and open routes/users.js file
insert this code to top after all the const declarations

router.get("/", async (req, res) => {
const users = await User.find();
res.send(users);
});

restart node using the "node index.js" command

use postman and do a test call to
http://localhost:3900/api/users

It works.

Dear Mosh, your tutorials are awesome, can you please fix this so people can finish them and recommend you even more around the world. Thank you.

React Vidly App Deployment

Hello,
I'm trying to deploy React Vidly App and have a problem with that. In Mosh videos he's using mlab for MongoBD data but this is no longer available. I'm using MongoDB Atlas now and following tutorials but whatever I do the application shows error. Just wonder if there is anything else we need to do to configure the custom-environment-variables.json files as I added "db": "vidly_db" as per video. Any help would be much appreciated.
Danius

Node.js course - Error connecting to MongoDB in Heroku deploy

Very last video of the Node.js course, and I'm ending with an unresolved error which is frustrating. The steps for setting up a free mLab account for 500mb of storage is a bit different now (it transfers you to MongoDB Atlas, rather than doing everything in mLab now), but I think I did everything Mosh did, but am stuck, unable to connect to MongoDB. I've looked at logs and documentation for two hours and can't come up with anything, and reviewed the videos to make sure I didn't miss anything.

One portion of the log says it failed at the start script, also says failed to connect to server, and the uncaughtException.log file also says failed to connect to server connection refused. I'm not sure why this is happening. Any help would be much appreciated.

Here is my log:
>heroku logs 2019-09-10T22:24:39.000000+00:00 app[api]: Build started by user [email protected] 2019-09-10T22:25:36.350660+00:00 heroku[web.1]: State changed from crashed to starting 2019-09-10T22:25:35.910501+00:00 app[api]: Deploy 93a36670 by user [email protected] 2019-09-10T22:25:35.910501+00:00 app[api]: Release v7 created by user [email protected] 2019-09-10T22:25:36.000000+00:00 app[api]: Build succeeded 2019-09-10T22:25:38.839155+00:00 heroku[web.1]: Starting process with command npm start2019-09-10T22:25:40.904305+00:00 app[web.1]: 2019-09-10T22:25:40.904322+00:00 app[web.1]: > [email protected] start /app 2019-09-10T22:25:40.904324+00:00 app[web.1]: > node index.js 2019-09-10T22:25:40.904326+00:00 app[web.1]: 2019-09-10T22:25:41.618034+00:00 app[web.1]: WARNING: NODE_ENV value of 'production' did not match any deployment config file names. 2019-09-10T22:25:41.618562+00:00 app[web.1]: WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode 2019-09-10T22:25:41.841717+00:00 app[web.1]: (node:23) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect. 2019-09-10T22:25:41.844331+00:00 app[web.1]: {"message":"Listening on port 5000...","level":"info"} 2019-09-10T22:25:42.022695+00:00 app[web.1]: {"error":{"name":"MongoNetworkError","errorLabels":["TransientTransactionError"]},"level":"error","message":"uncaughtException: failed to connect to server [vidly-shard-00-01-9gnfk.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to vidly-shard-00-01-9gnfk.mongodb.net:27017 closed]\nMongoNetworkError: failed to connect to server [vidly-shard-00-01-9gnfk.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to vidly-shard-00-01-9gnfk.mongodb.net:27017 closed]\n at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:431:11)\n at Pool.emit (events.js:198:13)\n at connect (/app/node_modules/mongodb-core/lib/connection/pool.js:557:14)\n at callback (/app/node_modules/mongodb-core/lib/connection/connect.js:109:5)\n at runCommand (/app/node_modules/mongodb-core/lib/connection/connect.js:129:7)\n at Connection.errorHandler (/app/node_modules/mongodb-core/lib/connection/connect.js:321:5)\n at Object.onceWrapper (events.js:286:20)\n at Connection.emit (events.js:198:13)\n at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:350:12)\n at Object.onceWrapper (events.js:286:20)\n at TLSSocket.emit (events.js:198:13)\n at _handle.close (net.js:606:12)\n at TCP.done (_tls_wrap.js:388:7)","stack":"MongoNetworkError: failed to connect to server [vidly-shard-00-01-9gnfk.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to vidly-shard-00-01-9gnfk.mongodb.net:27017 closed]\n at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:431:11)\n at Pool.emit (events.js:198:13)\n at connect (/app/node_modules/mongodb-core/lib/connection/pool.js:557:14)\n at callback (/app/node_modules/mongodb-core/lib/connection/connect.js:109:5)\n at runCommand (/app/node_modules/mongodb-core/lib/connection/connect.js:129:7)\n at Connection.errorHandler (/app/node_modules/mongodb-core/lib/connection/connect.js:321:5)\n at Object.onceWrapper (events.js:286:20)\n at Connection.emit (events.js:198:13)\n at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:350:12)\n at Object.onceWrapper (events.js:286:20)\n at TLSSocket.emit (events.js:198:13)\n at _handle.close (net.js:606:12)\n at TCP.done (_tls_wrap.js:388:7)","exception":true,"date":"Tue Sep 10 2019 22:25:42 GMT+0000 (Coordinated Universal Time)","process":{"pid":23,"uid":22531,"gid":22531,"cwd":"/app","execPath":"/app/.heroku/node/bin/node","version":"v10.16.0","argv":["/app/.heroku/node/bin/node","/app/index.js"],"memoryUsage":{"rss":82886656,"heapTotal":62169088,"heapUsed":25412032,"external":18262612}},"os":{"loadavg":[3.90625,6.11376953125,8.89306640625],"uptime":892987},"trace":[{"column":11,"file":"/app/node_modules/mongodb-core/lib/topologies/server.js","function":null,"line":431,"method":null,"native":false},{"column":13,"file":"events.js","function":"Pool.emit","line":198,"method":"emit","native":false},{"column":14,"file":"/app/node_modules/mongodb-core/lib/connection/pool.js","function":"connect","line":557,"method":null,"native":false},{"column":5,"file":"/app/node_modules/mongodb-core/lib/connection/connect.js","function":"callback","line":109,"method":null,"native":false},{"column":7,"file":"/app/node_modules/mongodb-core/lib/connection/connect.js","function":"runCommand","line":129,"method":null,"native":false},{"column":5,"file":"/app/node_modules/mongodb-core/lib/connection/connect.js","function":"Connection.errorHandler","line":321,"method":"errorHandler","native":false},{"column":20,"file":"events.js","function":"Object.onceWrapper","line":286,"method":"onceWrapper","native":false},{"column":13,"file":"events.js","function":"Connection.emit","line":198,"method":"emit","native":false},{"column":12,"file":"/app/node_modules/mongodb-core/lib/connection/connection.js","function":null,"line":350,"method":null,"native":false},{"column":20,"file":"events.js","function":"Object.onceWrapper","line":286,"method":"onceWrapper","native":false},{"column":13,"file":"events.js","function":"TLSSocket.emit","line":198,"method":"emit","native":false},{"column":12,"file":"net.js","function":"_handle.close","line":606,"method":"close","native":false},{"column":7,"file":"_tls_wrap.js","function":"TCP.done","line":388,"method":"done","native":false}]} 2019-09-10T22:25:45.115380+00:00 heroku[web.1]: State changed from starting to crashed 2019-09-10T22:25:45.035380+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2019-09-10T22:25:45.035882+00:00 app[web.1]: npm ERR! errno 1 2019-09-10T22:25:45.037140+00:00 app[web.1]: npm ERR! [email protected] start:node index.js 2019-09-10T22:25:45.037317+00:00 app[web.1]: npm ERR! Exit status 1 2019-09-10T22:25:45.039203+00:00 app[web.1]: npm ERR! 2019-09-10T22:25:45.039592+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script. 2019-09-10T22:25:45.039950+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2019-09-10T22:25:45.048694+00:00 app[web.1]: 2019-09-10T22:25:45.048842+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2019-09-10T22:25:45.048919+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-09-10T22_25_45_042Z-debug.log 2019-09-10T22:25:45.099192+00:00 heroku[web.1]: Process exited with status 1

This is what I could make out to be the relevant portion of the uncaughtExceptions.log file:
{"error":{"name":"MongoNetworkError","errorLabels":["TransientTransactionError"]},"level":"error","message":"uncaughtException: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]\nMongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]\n at Pool.<anonymous>

npm install fails

I'm going through React course at the moment and got stuck on Setting up the node backend.
I've cloned repo and under the vidly-api-node tried to run command npm i . As the result I've got this:
`npm i

[email protected] install /Users/yegorsteshenko/Projects/vidly-api-node/node_modules/fsevents
node install

node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.4/fse-v1.2.4-node-v67-darwin-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI, unknown) (falling back to source compile with node-gyp)
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
In file included from ../fsevents.cc:6:
In file included from ../node_modules/nan/nan.h:203:
In file included from ../node_modules/nan/nan_new.h:189:
../node_modules/nan/nan_implementation_12_inl.h:337:28: warning: 'New' is deprecated: Use Isolate*
version [-Wdeprecated-declarations]
return v8::StringObject::New(value).Asv8::StringObject();
^
/Users/yegorsteshenko/.node-gyp/11.9.0/include/node/v8.h:5241:3: note: 'New' has been explicitly marked
deprecated here
V8_DEPRECATED("Use Isolate* version",
^
/Users/yegorsteshenko/.node-gyp/11.9.0/include/node/v8config.h:326:29: note: expanded from macro
'V8_DEPRECATED'
declarator attribute((deprecated(message)))
^
In file included from ../fsevents.cc:6:
../node_modules/nan/nan.h:1034:44: warning: 'ToString' is deprecated: Use maybe version
[-Wdeprecated-declarations]
v8::Localv8::String string = from->ToString();
^
/Users/yegorsteshenko/.node-gyp/11.9.0/include/node/v8.h:2548:10: note: 'ToString' has been explicitly
marked deprecated here
inline V8_DEPRECATED("Use maybe version", Local ToString() const);
^
/Users/yegorsteshenko/.node-gyp/11.9.0/include/node/v8config.h:326:29: note: expanded from macro
'V8_DEPRECATED'
declarator attribute((deprecated(message)))
^
In file included from ../fsevents.cc:6:
../node_modules/nan/nan.h:1044:27: warning: 'WriteUtf8' is deprecated: Use Isolate* version
[-Wdeprecated-declarations]
length_ = string->WriteUtf8(str_, static_cast(len), 0, flags);
^
/Users/yegorsteshenko/.node-gyp/11.9.0/include/node/v8.h:2753:3: note: 'WriteUtf8' has been explicitly
marked deprecated here
V8_DEPRECATED("Use Isolate* version",
^
/Users/yegorsteshenko/.node-gyp/11.9.0/include/node/v8config.h:326:29: note: expanded from macro
'V8_DEPRECATED'
declarator attribute((deprecated(message)))
^
../fsevents.cc:63:6: warning: field 'async_resource' will be initialized after field 'lockStarted'
[-Wreorder]
: async_resource("fsevents:FSEvents"), lockStarted(false) {
^
4 warnings generated.
SOLINK_MODULE(target) Release/fse.node
COPY /Users/yegorsteshenko/Projects/vidly-api-node/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node
TOUCH Release/obj.target/action_after_build.stamp

[email protected] install /Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v67-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v67-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI) (falling back to source compile with node-gyp)
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
rm: ./Release/.deps/Release/obj.target/bcrypt_lib/src/blowfish.o.d.raw: No such file or directory
make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 1
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:197:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/Cellar/node/11.9.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt/lib/binding"
gyp ERR! cwd /Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt
gyp ERR! node -v v11.9.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/11.9.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt/lib/binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:197:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:978:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 18.7.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/11.9.0/bin/node" "/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt
node-pre-gyp ERR! node -v v11.9.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node/11.9.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt/lib/binding' (1)
error: error opening './Release/.deps/Release/obj.target/bcrypt_lib/src/bcrypt.o.d.raw': No such file or
directory
1 error generated.
make: *** [Release/obj.target/bcrypt_lib/src/bcrypt.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:197:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/Cellar/node/11.9.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt/lib/binding"
gyp ERR! cwd /Users/yegorsteshenko/Projects/vidly-api-node/node_modules/bcrypt
gyp ERR! node -v v11.9.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/yegorsteshenko/.npm/_logs/2019-10-10T12_26_57_005Z-debug.log
`
Here is an attached complete log of this run:
2019-10-10T12_26_57_005Z-debug.log

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

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

  • D3 photo D3

    Data-Driven Documents codes.