Giter VIP home page Giter VIP logo

beerlocker's People

Contributors

alejojamc avatar scottksmith95 avatar yamsellem 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beerlocker's Issues

Hi, I have a problem with this project which does not work. please help...

 ⋊> ~/D/OAuth2NodeServer node -v                                                                                                                             
 v6.9.1   
 ⋊> ~/D/OAuth2NodeServer npm -v         
 3.10.8 

macOS Sierra
10.12

Failed to load c++ bson extension, using pure JS version

  ⋊> ~/D/O/b/beerlocker-6.1 on master ⨯ git clone https://github.com/scottksmitcd  

  ⋊> ~/D/OAuth2NodeServer cd beerlocker/    

  ⋊> ~/D/O/beerlocker on master ⨯ cd beerlocker-6.1/   

  ⋊> ~/D/O/b/beerlocker-6.1 on master ⨯ npm update 

  ⋊> ~/D/O/b/beerlocker-6.1 on master ⨯ node-dev server.js    

{ Error: Cannot find module '../build/Release/bson'     .......
....      
js-bson: Failed to load c++ bson extension, using pure JS version                                                                                                    

##############################################################                                                                                                       
#                                                                                                                                                                    
#   !!! MONGOOSE WARNING !!!                                                                                                                                         
#                                                                                                                                                                    
#   This is an UNSTABLE release of Mongoose.                                                                                                                         
#   Unstable releases are available for preview/testing only.                                                                                                        
#   DO NOT run this in production.                                                                                                                                   
#                                                                                                                                                                    
##############################################################                                                                                                       
 ...                                                                                                                                                                    
TypeError: Cannot read property 'length' of undefined              

TypeError: Cannot read property '_id' of undefined

Hi,

Am getting this error after adding beer.userId = req.user._id , to the beer controller.

TypeError: Cannot read property '_id' of undefined

Code
beer_controller.js
`var Beer = require('../models/beer');
var User = require('../models/user');

// Create endpoint /api/beers for POST
exports.postBeers = function(req, res) {
// Create a new instance of the Beer model
var beer = new Beer();

// Set the beer properties that came from the POST data
beer.name = req.body.name;
beer.type = req.body.type;
beer.quantity = req.body.quantity;
beer.userId = req.user._id; // where the error is 


// Save the beer and check for errors
beer.save(function(err) {
    if (err)
        return res.send(err);

    res.json({ message: 'Beer added to the locker!', data: beer });
});

};

// Create endpoint /api/beers for GET
exports.getBeers = function(req, res) {
// Use the Beer model to find all beer
Beer.find({ userId: req.user._id }, function(err, beers) {
if (err)
return res.send(err);

    res.json(beers);
});

};

// Create endpoint /api/beers/:beer_id for GET
exports.getBeer = function(req, res) {
// Use the Beer model to find a specific beer
Beer.find({ userId: req.user._id, _id: req.params.beer_id }, function(err, beer) {
if (err)
return res.send(err);

    res.json(beer);
});

};

// Create endpoint /api/beers/:beer_id for PUT
exports.putBeer = function(req, res) {
// Use the Beer model to find a specific beer
Beer.update({ userId: req.user._id, _id: req.params.beer_id }, { quantity: req.body.quantity }, function(err, num, raw) {
if (err)
return res.send(err);

    res.json({ message: num + ' updated' });
});

};

// Create endpoint /api/beers/:beer_id for DELETE
exports.deleteBeer = function(req, res) {
// Use the Beer model to find a specific beer and remove it
Beer.remove({ userId: req.user._id, _id: req.params.beer_id }, function(err) {
if (err)
return res.send(err);

    res.json({ message: 'Beer removed from the locker!' });
});

};`

Body-Parser issue in server.js

I noticed in the code that you were using app.use(Body.Parser());

This has been deprecated and I found that it doesn't do the POST data correctly.

I changed it to

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));

and it POSTS just fine now.

Thanks so much for the tutorial. It's been a huge help in wrapping my head around Oauth2.

BadRequestError: Missing required parameter: transaction_id

Hi, I've following this tutorial to understand the OAuth flow and also to create custom oauth2 server.
Whenever I hit "Allow" button, it shows this error. I saw comments in the blog showing same error faced by the users.

BadRequestError: Missing required parameter: transaction_id
at SessionStore.load (C:\Users\User\projects\nodejs projects\beerlocker\node_modules\oauth2orize\lib\txn\session.js:25:25)
at transactionLoader (C:\Users\User\projects\nodejs projects\beerlocker\node_modules\oauth2orize\lib\middleware\transactionLoader.js:42:24)
at Layer.handle [as handle_request] (C:\Users\User\projects\nodejs projects\beerlocker\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\User\projects\nodejs projects\beerlocker\node_modules\express\lib\router\route.js:144:13)
at complete (C:\Users\User\projects\nodejs projects\beerlocker\node_modules\passport\lib\middleware\authenticate.js:271:13)
at C:\Users\User\projects\nodejs projects\beerlocker\node_modules\passport\lib\middleware\authenticate.js:278:15
at pass (C:\Users\User\projects\nodejs projects\beerlocker\node_modules\passport\lib\authenticator.js:428:14)
at Authenticator.transformAuthInfo (C:\Users\User\projects\nodejs projects\beerlocker\node_modules\passport\lib\authenticator.js:450:5)
at C:\Users\User\projects\nodejs projects\beerlocker\node_modules\passport\lib\middleware\authenticate.js:275:22
at IncomingMessage.req.login.req.logIn (C:\Users\User\projects\nodejs projects\beerlocker\node_modules\passport\lib\http\request.js:44:13)

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.