Coder Social home page Coder Social logo

loopback-getting-started-intermediate's Introduction

loopback-getting-started-intermediate

Please see LoopBack Getting started part II for the tutorial that walks you through creating this application.

$ git clone https://github.com/strongloop/loopback-getting-started-intermediate.git
$ cd loopback-getting-started-intermediate
$ npm install
$ node .

More LoopBack examples

loopback-getting-started-intermediate's People

Contributors

amir-61 avatar crandmck avatar dhmlau avatar superkhau 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

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

loopback-getting-started-intermediate's Issues

Unable to create relationships in step2

I can't create relationships

(and not just because I'm a programmer)

If I run

$ git clone https://github.com/strongloop/loopback-getting-started-intermediate.git
$ cd loopback-getting-started-intermediate
$ git checkout step2
$ npm install
$ slc loopback:relation

I am unable to use the arrow keys to select a model to create a relationship from.

I'm using...

  • Windows 8.1
  • Node v0.10.36
  • Strongloop v4.0.5

Restrict a reviwer can only able to read the reviews for he is owner of ?

I was experimenting with this code for a time and i try to implement some like the below requirement.

Consider like there is no such option All Reviews.
A Reviewer can able to read only his own reviews and My Reviews will list out only the reviews which he is owner of

For that i changed the excisting ACLs with the below ACLs

"acls": [
    {
      "accessType": "*",
      "principalType": "ROLE",
      "principalId": "$everyone",
      "permission": "DENY"
    },
    {
      "accessType": "EXECUTE",
      "principalType": "ROLE",
      "principalId": "$authenticated",
      "permission": "ALLOW",
      "property": "create"
    },
    {
      "accessType": "READ",
      "principalType": "ROLE",
      "principalId": "$everyone",
      "permission": "DENY"
    },
    {
      "accessType": "READ",
      "principalType": "ROLE",
      "principalId": "$owner",
      "permission": "ALLOW"
    },
    {
      "accessType": "WRITE",
      "principalType": "ROLE",
      "principalId": "$owner",
      "permission": "ALLOW"
    }

But after i execute the find reviews where publisherId={publisherId}, the result is a authorization error,
http://localhost:3000/api/Reviews?filter=where publisherId="583b2d3bd7f0308f2054bfb9"

{
  "error": {
    "name": "Error",
    "status": 401,
    "message": "Authorization Required",
    "statusCode": 401,
    "code": "AUTHORIZATION_REQUIRED",
    "stack": "Error: Authorization Required\n    at /home/iss/Desktop/coderef/fbmashup/POC/loopback-getting-started-intermediate/node_modules/loopback/lib/application.js:399:21\n    at ...............etc}

So how this is possible through Without any Custom Remote method

Review belongs to CoffeeShop, But Review not have coffeeShopId in review.json file

in create-sample-models.js:

...
Review.create([{
        date: Date.now() - (DAY_IN_MILLISECONDS * 4),
        rating: 5,
        comments: 'A very good coffee shop.',
        publisherId: reviewers[0].id,
        coffeeShopId: coffeeShops[0].id,
      }, {
        date: Date.now() - (DAY_IN_MILLISECONDS * 3),
        rating: 5,
        comments: 'Quite pleasant.',
        publisherId: reviewers[1].id,
        coffeeShopId: coffeeShops[0].id,
      }, {
        date: Date.now() - (DAY_IN_MILLISECONDS * 2),
        rating: 4,
        comments: 'It was ok.',
        publisherId: reviewers[1].id,
        coffeeShopId: coffeeShops[1].id,
      }, {
        date: Date.now() - (DAY_IN_MILLISECONDS),
        rating: 4,
        comments: 'I go here everyday.',
        publisherId: reviewers[2].id,
        coffeeShopId: coffeeShops[2].id,
      }], cb);
    });

and in review.json:

{
  "name": "Review",
  ...
  "properties": {
    "date": {
      "type": "date",
      "required": true
    },
    "rating": {
      "type": "number"
    },
    "comments": {
      "type": "string",
      "required": true
    }
  },
  ...
}

It made me confused

Presence of server/boot/root.js here may confuse users.

Feel free to just close this one if I'm off the mark here but since it took me a bit to figure out what was going on I decided to open it.

Although the accompanying tutorial specifies in its Change or modify the default root route handler section that the user should [e]ither delete it or just rename it to something without a .js ending, the experience of cloning this app and immediately following the instructions in README.md may lead the user to think its sole purpose is to show uptime, e.g., {"started":"2015-07-06T17:21:02.230Z","uptime":4.614}.

If the user removes or renames the recently added server/boot/root.js before running the app, the full functionality is revealed as expected but if the intent is to show the user a finished example of what they will build before going through the tutorial, it may make sense to already have server/boot/root.js renamed or removed.

Reviewers API { "error": { "name": "Error", "status": 401, "message": "Authorization Required" }}

My question is why I cannot access Reviewers API even though user is log in and
header is set?
Authorization THieYuz51yWTPN9YTtHlfOEcMrFzTilmmF2YtRDCkuc2eCvq5EqWbQi7lou1S160

I can use some of the API but most of the API cannot be touch.
Here is some that cannot be used

get /Reviewers 
get /Reviewers/{id}/accessTokens 
post /Reviewers/{id}/accessTokens 
get /Reviewers/{id}/exists 

How do I configure to be able to use? Why error ? What make error happen? I cannot find any info anywhere.

Any help will be appreciated.

Thanks

Extends Users to MyAppUser instead of Reviewer

Hello,
I try to change reviewer class to another class name that best fits my app.
I create the model, regenerate lb-services and change
.factory('AuthService', ['Reviewer', '$q', '$rootScope', function(User, $q,

by.

factory('AuthService', ['MyAppUser', '$q', '$rootScope', function(User, $q,

I did not find any other occurence of Reviewer in any source file. So I am a little upset.
Is this something I did wrong or an issue ? I do not see why an issue.

Thanks

Add Review tab 401 - Unauthorized Error on GET /api/CoffeeShops

Looks like the Add Review tab needs an additional ACL added to permit logged in users from being able to query for the list of CoffeeShops:

image

Adding the following ACL to the coffee-shop.json seems to work:

{
     "accessType": "READ",
     "principalType": "ROLE",
     "principalId": "$everyone",
     "permission": "ALLOW"
}

creating relation error "Getting started part II"

From @tktk8924 on May 9, 2016 3:16

I'm trying "Getting started part II" and having a problem with creating relation between CoffeeShop and Review models.

I got the following error:

? Select the model to create the relationship from: CoffeeShop
? Relation type: has many
? Choose a model to create a relationship with: Review
? Enter the property name for the relation: (reviews)


/Users/takehiro/.nodebrew/node/v5.11.1/lib/node_modules/strongloop/node_modules/rx/dist/rx.js:77
    throw e;
    ^
true

I followed the following steps:

$ git clone https://github.com/strongloop/loopback-getting-started-intermediate.git
$ cd loopback-getting-started-intermediate
$ git checkout step2
$ npm install
$ slc loopback:relation

Versions:

  • Node.js: v5.11.1
  • strongloop: 6.0.0

Thanks.

Copied from original issue: strongloop/strongloop#309

currentUser gets wiped on page refresh

After logging in and hitting F5 (page refresh) in the browser the rootScope gets wiped and so gets the currentUser variable, resulting in the user gets logged out after this. On the other side, the actual User Model from lb-services and the AuthService still have the login Data stored in cookies and Model.isAuthenticated() will still return true.

Why are u using the rootScope for storing the user when the AuthService is handling this and is there a way to restore it after page refresh?

GET reviewer > RESPONSE "message": "Authorization Required",

I cannot use most of the reviewer API. It give the error with "message": "Authorization Required"

I create a user and log in before access API but it does not work

I create a reviewer and log in with reviewer API since it extends base User, but it does not work !!!!

Documentation create-sample-model.js bug

The create-sample-model.js code in the documentation for this tutorial contains a bug. The computed value for coffeeShopId in the 4th review should be coffeeShops[2].id. Currently it is reviewers[2].id.

In addition, the unhandled returned err when calling createReviews should be addressed per pull request #9

Client code generation

This tutorial introduces the client (Angular) code in a "deus ex machina" fashion (it's just defined in GitHub -- not generated by invocation of a loopback service). So, I am presuming that there is no such service. At the same time, loopback has many nice services on the "server-side", like slc loopback:datasource, slc loopback:model etc.

I believe that slc is a domesticated version of yeoman, so adding the support for the "client side" may not be difficult.

Note: I am reporting it here, knowing that this issue belongs somewhere else. However, as I am rewriting the loopback-getting-started sample from scratch I will have to use something like https://github.com/DaftMonk/generator-angular-fullstack to get my initial skeleton.

Login issue

Hi,
I'm new to this loopback.
I started with Guide and at this step (step6) I can't login into [email protected] account.
What could go wrong? Even after I download the code from this, I still face the same error.
Please help me understand this.
Thanks

Problem running the creation of a AngularJS client

Hi, I tried to complete the tutorial in [1]. But I failed at step 6 with the following error message:

root@mymachine:~/myfolder# lb-ng server/server.js client/js/services/lb-services.js
Loading LoopBack app "/home/ubuntu/simpletest/server/server.js"
Generating "lbServices" for the API endpoint "/api"
Warning: scope User.accessTokens targets class "AccessToken", which is not exposed
via remoting. The Angular code for this scope won't be generated.
Warning: scope Reviewer.accessTokens targets class "AccessToken", which is not exposed
via remoting. The Angular code for this scope won't be generated.
/usr/local/lib/node_modules/loopback-sdk-angular-cli/node_modules/ejs/lib/ejs.js:322
  throw err;
  ^

ReferenceError: ejs:526
    524|             /**
    525|              * @ngdoc method
 >> 526|              * @name <%- moduleName %>.<%- modelName %>#<%- methodName %>
    527|              * @methodOf <%- moduleName %>.<%- modelName %>
    528| <% if (action.deprecated) { -%>
    529|              * @deprecated <%- action.deprecated %>

moduleName is not defined
    at ngdocForMethod (eval at <anonymous> (/usr/local/lib/node_modules/loopback-sdk-angular-cli/node_modules/ejs/lib/ejs.js:549:12), <anonymous>:537:17)
    at eval (eval at <anonymous> (/usr/local/lib/node_modules/loopback-sdk-angular-cli/node_modules/ejs/lib/ejs.js:549:12), <anonymous>:89:5)
    at Array.forEach (native)
    at eval (eval at <anonymous> (/usr/local/lib/node_modules/loopback-sdk-angular-cli/node_modules/ejs/lib/ejs.js:549:12), <anonymous>:87:21)
    at returnedFn (/usr/local/lib/node_modules/loopback-sdk-angular-cli/node_modules/ejs/lib/ejs.js:580:17)
    at Object.exports.render (/usr/local/lib/node_modules/loopback-sdk-angular-cli/node_modules/ejs/lib/ejs.js:384:37)
    at Object.generateServices [as services] (/usr/local/lib/node_modules/loopback-sdk-angular-cli/node_modules/loopback-sdk-angular/lib/services.js:102:14)
    at EventEmitter.runGenerator (/usr/local/lib/node_modules/loopback-sdk-angular-cli/bin/lb-ng.js:53:26)
    at emitNone (events.js:67:13)
    at EventEmitter.emit (events.js:166:7)
    at /home/ubuntu/simpletest/node_modules/loopback-boot/lib/executor.js:63:9
    at /home/ubuntu/simpletest/node_modules/loopback-boot/node_modules/async/lib/async.js:251:17
    at /home/ubuntu/simpletest/node_modules/loopback-boot/node_modules/async/lib/async.js:154:25
    at /home/ubuntu/simpletest/node_modules/loopback-boot/node_modules/async/lib/async.js:248:21
    at /home/ubuntu/simpletest/node_modules/loopback-boot/node_modules/async/lib/async.js:612:34
    at nextTickCallbackWith0Args (node.js:419:9)

To reproduce this you only have to:

$ git clone https://github.com/strongloop/loopback-getting-started-intermediate.git
$ cd loopback-getting-started-intermediate
$ git checkout step6
$ npm install
$ npm install -g loopback-sdk-angular-cli
$ mkdir -p client/js/services
$ lb-ng server/server.js client/js/services/lb-services.js

Which is what is just written in the Tutorial.

What am I doing wrong? Or is the tutorial not working at the moment?

My version of the loopback cli tools (lb) is

[1] https://loopback.io/doc/en/lb3/Create-AngularJS-client.html

Handshake inactivity timeout

{ [Error: Handshake inactivity timeout]
code: 'PROTOCOL_SEQUENCE_TIMEOUT',
fatal: true,
timeout: 10000 }

I get this error when I try to run the app as is.

My PC resides behind secure proxy.

ACL typo?

I tried to translate this example onto my own code. I was unable to call 'create' when $authenticated.
See here: http://docs.strongloop.com/display/public/LB/Define+access+controls

The example says that the file should look like this:

...
{
  "accessType": "EXECUTE",
  "principalType": "ROLE",
  "principalId": "$authenticated",
  "permission": "ALLOW",
  "property": "create"
},
...

However, I am unable to create anything with this setup. But when I change to accessType "WRITE" it works. Which seems correct according to this page: http://docs.strongloop.com/display/public/LB/Controlling+data+access

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.