Giter VIP home page Giter VIP logo

Comments (5)

Scarygami avatar Scarygami commented on September 13, 2024

So I've been thinking that we could add the following attributes to allow most flexibility while keeping the defaults simple:

local / boolean / default false
localHost / string / default 'localhost'
localPort/ int / default 8080

With local set, http://{{localHost}}:{{localPort}}/_ah/api would be used with the defaults used as in the app engine default configuration. The appId parameter would be ignored in this case.
Default values could be overwritten using localHost and localPort, e.g. if you are running your dev server on a different machine.

In the simplest case you would then have
Dev env: <google-api-loader api="myApi" version="v1" local></google-api-loader>
Deployed: <google-api-loader api="myApi" version="v1" appId="myAppId"></google-api-loader>

Developers could also use a conditional attribute for local, to simply switch between dev and deployed environment, but that's up to them how to implement this:
<google-api-loader api="myApi" version="v1" appId="myAppId" local?="{{dev}}"></google-api-loader>

@ebidel, thoughts? I could PR those changes if they sound okay to you.

from google-apis.

ebidel avatar ebidel commented on September 13, 2024

I think we need a new element for the cloud stuff for two reasons:

  1. these additional params won't make sense for the majority of the API
  2. we should exercise the extensibility and reusability of components :)

` (or something similar).

For the specific param name, I like what the app engine dev_server does with --host and --port. We could do:

<google-cloud-endpoints-api appId="myAppId" host="localhost" port="8080"></google-cloud-endpoints-api>

If host or port are given, they override appId to form the URL.

An alternative (but more work) would be to create a mock element for testing. Scott through this POC together for core-ajax: https://github.com/PolymerLabs/mock-ajax

from google-apis.

x1ddos avatar x1ddos commented on September 13, 2024

mock-ajax sounds great but I think it has a different purpose. You'd still want to be able to load a custom API from dev server to run a local copy of the app, as well as maybe run automated tests with mock-ajax. But it's different, unless I'm missing something.

Why not just change appId attribute to root? That way the loader would support both dev and production/deployed:

Dev:
<google-api-loader name="myApi" version="v1" root="http://localhost:8080/_ah/api">

Prod:
<google-api-loader name="myApi" version="v1" root="https://myapp.appspot.com/_ah/api">

statuses_[this.name] = 'loading';
loaders_[this.name] = this;
gapi.client.load(this.name, this.version, 
    this.handleLoadResponse.bind(this), this.root);

from google-apis.

softkot avatar softkot commented on September 13, 2024

Can't use this element with polymer starter kit and local development endpont cause new root property overlaps with some #document-fragment and can't be set. I think it should be renamed to somethong other than root, apiroot for example.

from google-apis.

Scarygami avatar Scarygami commented on September 13, 2024

Hah, I just encountered a similar problem and created a new issue here: #49
:)

from google-apis.

Related Issues (20)

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.