Git Product home page Git Product logo

restfulapitutorial's People

Contributors

dependabot[bot] avatar generalgmt avatar olatundeg 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

restfulapitutorial's Issues

Error: data and salt arguments required

After cloned the project I've updated according to new mongoose version by adding **'useMongoClient : true'** . And the project is running ok.

When I send 'localhost:3000/auth/register' POST request via postman I'm getting this error. Is it a bug ? Or what have I done wrong ?

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Error</title>
    </head>
    <body>
        <pre>Error: data and salt arguments required
            <br> &nbsp; &nbsp;at Object.hashSync (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/bcrypt/bcrypt.js:71:15)
            <br> &nbsp; &nbsp;at exports.register (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/api/controllers/userController.js:9:34)
            <br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/layer.js:95:5)
            <br> &nbsp; &nbsp;at next (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/route.js:137:13)
            <br> &nbsp; &nbsp;at Route.dispatch (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/route.js:112:3)
            <br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/layer.js:95:5)
            <br> &nbsp; &nbsp;at /home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/index.js:281:22
            <br> &nbsp; &nbsp;at Function.process_params (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/index.js:335:12)
            <br> &nbsp; &nbsp;at next (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/index.js:275:10)
            <br> &nbsp; &nbsp;at jsonParser (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/body-parser/lib/types/json.js:112:7)
            <br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/layer.js:95:5)
            <br> &nbsp; &nbsp;at trim_prefix (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/index.js:317:13)
            <br> &nbsp; &nbsp;at /home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/index.js:284:7
            <br> &nbsp; &nbsp;at Function.process_params (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/index.js:335:12)
            <br> &nbsp; &nbsp;at next (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/express/lib/router/index.js:275:10)
            <br> &nbsp; &nbsp;at urlencodedParser (/home/pankaja/Projects/Nodejs/Tutorial/todoApp/RESTfulAPITutorial/node_modules/body-parser/lib/types/urlencoded.js:100:7)
        </pre>
    </body>
</html>

Deployment

How we can deploy the project rather than copy the entire project. Is there any way to bundle the application same as Angular.

Doesn't work

# git clone https://github.com/generalgmt/RESTfulAPITutorial.git && cd RESTfulAPITutorial

# npm install

# npm run start

> [email protected] start /home/px/src/RESTfulAPITutorial
> nodemon server.js

[nodemon] 1.17.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
todo list RESTful API server started on: 3000

In the JS console:

Content Security Policy: Couldn't process unknown directive 'report-to'

http://localhost:3000/tasks doesn't respond ; the loading icon keeps spinning ; Oh well, 10 (more like 25) minutes down the drain :)

PS - just to be sure, I tried running it with pm2 ; no luck :(

npm run start issue

todo list RESTful API server started on: 3000
(node:22876) DeprecationWarning: open() is deprecated in mongoose >= 4.11.0, use openUri() instead, or set the useMongoClient option if using connect() or createConnection(). See http://mongoosejs.com/docs/4.x/docs/connections.html#use-mongo-client

events.js:160
throw er; // Unhandled 'error' event
^
MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool. (/root/jwt/RESTfulAPITutorial/node_modules/mongodb-core/lib/topologies/server.js:336:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection. (/root/jwt/RESTfulAPITutorial/node_modules/mongodb-core/lib/connection/pool.js:280:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket. (/root/jwt/RESTfulAPITutorial/node_modules/mongodb-core/lib/connection/connection.js:189:49)
at Socket.g (events.js:292:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1281:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
[nodemon] app crashed - waiting for file changes before starting...

Mongoose error

When I run the server it throw's me this error:

/opt/lampp/htdocs/RESTfulAPITutorial/node_modules/mongoose/lib/connection.js:309
var promise = new Promise.ES6(function(resolve, reject) {
^
TypeError: undefined is not a function
at NativeConnection.Connection.open (/opt/lampp/htdocs/RESTfulAPITutorial/node_modules/mongoose/lib/connection.js:309:17)
at Mongoose.connect (/opt/lampp/htdocs/RESTfulAPITutorial/node_modules/mongoose/lib/index.js:242:47)
at Object. (/opt/lampp/htdocs/RESTfulAPITutorial/server.js:9:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
[nodemon] app crashed - waiting for file changes before starting...

Ths !

Bug in document update

todoListController is using findOneAndUpdate to update mongo document, The result is that it updates the first entry in the collection, no-matter the passed taskId value.
The solution is to use findByIdAndUpdate instead of findOneAndUpdate.

You might also add res.status(400) before res.send(err);

Error on nodemon

Seems like there is a code that must be changed or upgrade

npm run start

> [email protected] start /home/putrapc/webproject/RESTfulAPITutorial
> nodemon server.js

[nodemon] 1.17.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
todo list RESTful API server started on: 3000
(node:22613) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/4.x/docs/connections.html#use-mongo-client

events.js:183
      throw er; // Unhandled 'error' event
      ^
MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
    at Pool.<anonymous> (/home/putrapc/webproject/RESTfulAPITutorial/node_modules/mongodb-core/lib/topologies/server.js:336:35)
    at emitOne (events.js:116:13)
    at Pool.emit (events.js:211:7)
    at Connection.<anonymous> (/home/putrapc/webproject/RESTfulAPITutorial/node_modules/mongodb-core/lib/connection/pool.js:280:12)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at Connection.emit (events.js:214:7)
    at Socket.<anonymous> (/home/putrapc/webproject/RESTfulAPITutorial/node_modules/mongodb-core/lib/connection/connection.js:189:49)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
[nodemon] app crashed - waiting for file changes before starting...

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.