Giter VIP home page Giter VIP logo

aurelia-api's People

Contributors

adamwillden avatar doktordirk avatar fedoranimus avatar greenkeeperio-bot avatar kellyethridge avatar kukks avatar nevercast avatar pfurini avatar rwoverdijk avatar yutackall 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aurelia-api's Issues

the getRequestPath does not allow something like resource/id?option=foo

I've been trying to send the access_token in the url without success. Checking and the source code I could see the getRequestPath function does not transforms properly the criteria.

Going back to my example, sending query parameters and and ID to fetch a resource is not possible.

doing something like apiEndpoint.find('users', 1, {token: asdasdads}); only returns users/1; the access option is lost.

Endpoint.of() typing should resolve to Rest

The aurelia-api typings mention that Endpoint.of() resolve to a Endpoint when it is actually a Rest instance if I am not mistaking:

/**
 * Endpoint class. A resolver for endpoints which allows injection of the corresponding Rest client into a class
 */
export declare class Endpoint {
  
  /**
     * Construct the resolver with the specified key.
     *
     * @param {string} key
     */
  constructor(key: string);
  
  /**
     * Resolve for key.
     *
     * @param {Container} container
     *
     * @return {Rest}
     */
  get(container: Container): Rest;
  
  /**
     * Get a new resolver for `key`.
     *
     * @param {string} key  The endpoint name
     *
     * @return {Endpoint}  Resolves to the Rest client for this endpoint
     */
  static of(key: string): Endpoint; //****** this should resolve to Rest *******
}

Add ability to set Default host name

It would be great if we could configure the default host name for endpoints.

Having to prepend a host name other than the current client url is a bit tedious and error-prone.

If this is already available, please let me know.

Allow the resource path to contain query parameters

In several setups, I don't have to possibility to activate rewriting for ReSTful API pathes, so I have to setup the API endpoint like following:

this.fetchClient.baseUrl = backend.basepath+'/api/index.php?_p=';

But this fails when trying to find() in aurelia-orm with criteria:

this.assetRepository.find({criteria:1}).then(assets=>{
    // assets
});

requests to http://dev-server/api/index.php?_p=/assets?criteria=1

Config coupled to aurelia-fetch-client

Hey guys,

I am currently trying to test my app using the aurelia-http-client-mock. Therefore, I register the Mock for HttpClient. However, the aurelia-api Config is currently coupled to aurelia-fetch-client and, therefore, I can't replace the HTTP client.

Are there any reasons this is coupled at the moment? Any plans to change this?

Best Regards

Fetch error message discarded

I've been trying to receive error message without success.
I believe it's because of those lines in rest.js:

    return this.client.fetch(path, requestOptions).then(response => {
      if (response.status >= 200 && response.status < 400) {
        return response.json().catch(error => null);
      }

      throw response;
    });

specifically: response.json().catch(error => null);
the discarded error contains the actual data passed with the error.
but instead the response is thrown: throw response;.
when trying to read from response again "Already read" error is thrown.

In many cases the status error code is not sufficient and the custom error message contains vital information.

Would you consider attaching error to the response before throwing, or giving some API for retrieving the error.

Thanks in advance

remove trailing slash hack

instead of managing trailing slashes to request urls by resource parameter magic, a configuration option might be preferable

Header not being applied

Adding a Content-Type header as below:

config.registerEndpoint('auth', 'http://localhost:5000/connect/', { 
          headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        }
);

However, my request is still using the default Content-Type of 'application/json'. Note: This endpoint is being used by Aurelia-Authentication as well, issue could be in there?

Edit: Fixed formatting

Question: Configure endpoints from Swagger

Has anyone explored the possibility of configuring aurelia-api endpoints from a swagger.json definition?

I like the way the swagger parameters object has types: header, path, query, body which could be used to expand upon and standardize the way aurelia-api builds paths and query strings.

Perhaps there would be implications to aurelia-orm as well since swagger definitions contain schema.

Thanks and keep up the great work!

Default headers are not applied with configuration type 5

Hi, I am trying to configure the aurelia-api plugin to communicate with an API that communicate with the JSON API SPEC.
There are two ways to configure defaults for the fetch client https://aurelia-api.spoonx.org/configuration.html (configuration 3 and 5) but only the configuration 3 works with me.

// configuration type 3
aurelia.use
    .standardConfiguration()
    .feature('resources')
    .plugin('aurelia-api', config => {
      config
        .registerEndpoint('api', `${environment.apiBaseUrl}/`, {
          headers: {
            'Content-Type': 'application/vnd.api+json',
            'Accept': 'application/vnd.api+json'
          }
        })
        .setDefaultEndpoint('api');
    });

// configuration type 5
aurelia.use
    .standardConfiguration()
    .feature('resources')
    .plugin('aurelia-api', config => {
      config
        .registerEndpoint('api', fetchConfig => {
          fetchConfig
            .withBaseUrl(`${environment.apiBaseUrl}/`)
            .withDefaults({
              'headers': {
                'Content-Type': 'application/vnd.api+json',
                'Accept': 'application/vnd.api+json'
              }
            });
          })
        .setDefaultEndpoint('api');
    })

If I run my request with configuration 3, the headers are defined properly, however if I run my request with configuration 5 the Content-Type and Accept headers are set to the classic application/json and thus my request fail.

If I log the HttpClient to the console before the request is made, we can see that the defaults are properly saved, but apparently they are not used

HttpClient {activeRequestCount: 0, isRequesting: false, isConfigured: true, baseUrl: "http://localhost:8000/", defaults: Object…}
activeRequestCount : 0
baseUrl : "http://localhost:8000/"
defaults : Object
  headers : Object
    Accept : "application/vnd.api+json"
    Content-Type : "application/vnd.api+json"
    __proto__ : Object
  __proto__ : Object
interceptors : Array(1)
isConfigured : true
isRequesting : false

I would rather use the configuration 5 because it allows me to easily add custom interceptors (for example, automatically parse the request to json which is not done by default with this content-type).

I am doing something wrong or is there really a bug hiding there ?

Multiple endpoints

The real-world usage of aurelia-api has shown to have some limitations. The largest of which, is working with multiple endpoints.

This is a proposal for a different structure, to allow for more flexibility.

This snippet should explain my idea:

export function configure (aurelia) {
  aurelia.use
    .plugin('aurelia-api', configure => {
      configure.registerEndpoint('auth', baseConfig => {
        baseConfig.withBaseUrl('https://auth.com/server');
      });

      configure.registerEndpoint('api', baseConfig => {
        baseConfig.withBaseUrl('https://api.server.io/v1');
      });
    })
    .plugin('spoonx/aurelia-auth', (baseConfig) => {
      baseConfig.configure({
        // The rest client we just configured. _maybe_ make aurelia-auth smart
        restClient : 'auth'

        // or alternatively pass it an HttpClient instance:
        // restClient : aurelia.container.get(Rest).getEndpoint('auth')
        /* ... */
      });
    })
  ;
}

Default

By default, the singleton HttpClient will be used, to serve the 90%. To make life easier, we'll allow you to configure that through aurelia-api, too:

export function configure (aurelia) {
  aurelia.use
    .plugin('aurelia-api', configure => {
      configure.getEndpoint(baseConfig => {
        baseConfig.withBaseUrl('https://auth.com/server');
      });
    });
}

I'm not sure if we should go with endpoint or perhaps just restClient. In the future I want to add websocket adapters, in which case using endpoint still makes sense.

passing date parameter

I just did a jspm update and now every place I pass a date value with your api, the date value does not get passed.

See below code example:
return this.endpoint.find('scheduling/scheduleentry', { shiftDate : shiftDate, shiftId : shiftId })
.then(response => {
return response;
}).catch(console.error);

Below is the error I'm getting showing only shiftId is getting sent:
aurelia-fetch-client.js:140 GET http://localhost:1672/api/scheduling/scheduleentry?shiftId=1 500 (Internal Server Error)

"getEndpoint is not a function"

Hello there.
I have a problem when I use this library.

As per official guideline, the library configuration in my main.ts is something like this.

  aurelia.use
    .plugin('aurelia-api', config => {
      config.registerEndpoint('api', 'https://some.api.site');
    });

and in one of the class


    constructor(conn: Config, private ea: EventAggregator)  {
      this.apiEndpoint = conn.getEndpoint('api');
      // snip...
     return this.apiEndpoint.find(params.kos).then(ids => // snip.

but I got an error about getEndpoint is not a function. And here's the part of the generated app-bundle.js from the snippet above.

            this.apiEndpoint = conn.getEndpoint('api');
            ea.subscribe(something_1.Something, function (msg) {
                var ids = msg.what;
                Object.assign(_this.ids, ids);
            });

Thank you for your explanation.

FEAT: add a pathTemplate option to cope with different uri path schemes

Ref: #176 (comment)

Proposal

Add a pathTemplate property to Rest with a default of '${resource}/${id}', that is used to build the actual url to fetch. The property must be added at the end of the ctor as optional.
Please note this isn't an ES6 template string, the ${resource} and ${id} will be simply substituted with the first two parameters of various Rest methods (either resource and id, or resource and criteria).
Also add a new setDefaultPathTemplate() method to the config, that must be called prior to registerEndpoint to set a custom default for all endpoints (in a field like defaultPathTemplate, passed as the last parameter to the Rest ctor).

Things to consider:

  • the join method in aurelia-path will not be used anymore, and it is simply a user's responsibility to pass sensible parameters with proper slashes. No assumptions could be made on the contents of the pathTemplate property.
  • the hasSlash hack must be removed for this to work properly (already logged as #146)

Benefits

One could use that property to talk to an API that expects resource paths in other formats, like OData style:
'${resource}(${id})' -> path(id)

Allow configuring/using FetchClient

I have already a configured FetchClient for CORS and CSRF-Protection.
Aurelia-ORM should use this FetchClient instead of creating a new one.

Expose response object from fetch call

Exposing the actual Response object after a successful fetch would add unlimited flexibility to handling the response outside of the body(e.g. response headers as we talked about on Gitter @RWOverdijk ).

Maybe we can change the request(method: string, path: string, body?: {}, options?: {}): Promise<any|Error> signature to request(method: string, path: string, body?: {}, options?: {}, responseOutput?: { response: Response}): Promise<any|Error> and all wrapper functions that use it?

so the impl would be something like:

 request(method: string, path: string, body?: {}, options?: {}, responseOutput?: { response: Response}): Promise<any|Error> {
    let requestOptions = extend(true, {headers: {}}, this.defaults, options || {}, {method, body});
    let contentType    = requestOptions.headers['Content-Type'] || requestOptions.headers['content-type'];

    if (typeof body === 'object' && body !== null && contentType) {
      requestOptions.body = (/^application\/json/).test(contentType.toLowerCase())
                          ? JSON.stringify(body)
                          : buildQueryString(body);
    }

    return this.client.fetch(path, requestOptions).then((response: Response) => {
      if (response.status >= 200 && response.status < 400) {
        if(responseOutput){
          responseOutput.response = response;
        }       
        return response.json().catch(() => null);
      }

      throw response;
    });
  }

enable Content-Type header charset

Content-Type header , in the case described charset, JSON is not sent and query string sent.

code

let headers = {
  headers: {
    'Content-Type': 'application/json; charset=UTF-8'
  }
}
config.registerEndpoint('api', 'http://examle.com', headers);

Unable to find module with ID: aurelia-api when using Webpack Skeleton and Visual Studio

I'm sure that there's some sort of workaround at this point, but after several hours of research I'm stumped on how to proceed to resolve this.

I've installed using npm install aurelia-api -- save and see a corresponding entry in my package.json file:

"aurelia-api": "3.1.1" ,

I've added the following to boot.ts:

aurelia.use
.standardConfiguration()
...
.plugin(PLATFORM.moduleName("aurelia-api", (config:any) => {...}))

However, when I run the app I get the following error:

Uncaught (in promise) Error: Unable to find module with ID: aurelia-api
at WebpackLoader. (aurelia-loader-webpack.js:187)
at step (aurelia-loader-webpack.js:36)
...

Option to pass id with body

Great plugin, I love it so far. I would like some options around how the requests are built though, for example I had originally written my PUT api like so:

[HttpPut]
public async Task<JsonResult> Put([FromBody] T item) {
    // ...
}

but after seeing the HTTP traffic from this plugin I had to change it to:

[HttpPut("{id}")]
public async Task<JsonResult> Put([FromRoute] Guid id, [FromBody] T item) {
    item.Id = id;
    // ...
}

For now this works great, but once I start adding validation rules I will probably need a ViewModel on the backend with an optional Id to support this request.

GET request method body not passed as querystring

When trying to execute .request('GET', 'some/url', {foo: 'bar'}) it warns about:

Failed to construct 'Request': Request with GET/HEAD method cannot have body

Should it not pass the body as a query string if it's a GET?

How do change the value of a header after the initial endpoint configuration?

This question may be related to #185

I have setup two endpoints auth and api. The auth endpoint returns a session token which I need to use for further requests to the api endpoint. For the api endpoint I need to also add a header with the value set to the session token from the auth endpoint.

Endpoints setup in main.js

Auth endpoint:

config.registerEndpoint('auth',dfconfig.loginurl(),{headers: { "X-DreamFactory-Application-Name":app_name}});

Api endpoint:

config.registerEndpoint('api',dfconfig.database(),{headers: { "X-DreamFactory-Session-Token": token}});

I do not know the value of token until the auth endpoints returns the session value.

Can I just leave out the X-DreamFactory-Session-Token and then add it to auth endpoint when I actually use it? Or can I leave the header in as just set the value of token before I use the api endpoint?

Requesting non JSON content

Hi, It doesn't seem possible to request an URL that returns non-JSON content as by line 71 of /src/rest.js all responses are parsed as json. It seems to me that this should only be done if the Accept header is application/json. Any toughts ?

problems with forks

unnoticed forks of aurelia-api mess up authentication and orm. should have a way to warn users if they do . i'm thinking of a simple configured= true or something

Make buildQueryString second parameter 'traditional' configurable

Problem:

let params={mylist:["one", "two", "three"]};
this.apiEndpoint.find('something', params);

Makes query ?mylist[]=one&mylist[]=two&mylist[]=three.

but is needed query ?mylist=one&mylist=two&mylist=three.

aurelia-api uses aurelia-path function buildQueryString(params, traditional), that makes query the way it is needed when traditional = true.

Needed feature:

Provide a way to configure buildQueryString-s traditional parameter.

added 2 overloads to rest:find()

declare module 'aurelia-api' {
import * as qs from 'qs';
import * as extend from 'extend';
import {
json,
HttpClient
} from 'aurelia-fetch-client';
import {
resolver
} from 'aurelia-dependency-injection';
export class Rest {
defaults: any;

/**
   * Inject the httpClient to use for requests.
   *
   * @param {HttpClient} httpClient
   */
constructor(httpClient: any);

/**
   * Make a request to the server.
   *
   * @param {string} method
   * @param {string} path
   * @param {{}}     [body]
   * @param {{}}     [options]
   *
   * @return {Promise}
   */
request(method: any, path: any, body: any, options?: any): any;

/**
   * Find a resource.
   *
   * @param {string}           resource Resource to find in
   * @param {{}|string|Number} criteria Object for where clause, string / number for id.
   * @param {{}}               [options] Extra fetch options.
   *
   * @return {Promise}
   */
find(resource: any, criteria: any, options: any): Promise<any>;
find(resource: any, criteria: any): Promise<any>;
find(resource: any): Promise<any>;

/**
   * Create a new instance for resource.
   *
   * @param {string} resource
   * @param {{}}     body
   * @param {{}}     [options]
   *
   * @return {Promise}
   */
post(resource: any, body: any, options: any): any;

/**
   * Update a resource.
   *
   * @param {string}        resource  Resource to update
   * @param {string|Number} criteria  String / number of the id to update.
   * @param {object}        body      New data for provided criteria.
   * @param {{}}            [options]
   *
   * @return {Promise}
   */
update(resource: any, criteria: any, body: any, options: any): any;

/**
   * Delete a resource.
   *
   * @param {string}        resource  The resource to delete in
   * @param {string|Number} criteria  String / number of the id to delete.
   * @param {{}}            [options]
   *
   * @return {Promise}
   */
destroy(resource: any, criteria: any, options: any): any;

/**
   * Create a new instance for resource.
   *
   * @param {string} resource
   * @param {{}}     body
   * @param {{}}     [options]
   *
   * @return {Promise}
   */
create(resource: any, body: any, options: any): any;

}
export class Config {
endpoints: any;
defaultEndpoint: any;

/**
   * Register a new endpoint.
   *
   * @param {string}          name              The name of the new endpoint.
   * @param {function|string} [configureMethod] Configure method or endpoint.
   * @param {{}}              [defaults]        Defaults for the HttpClient
   *
   * @see http://aurelia.io/docs.html#/aurelia/fetch-client/latest/doc/api/class/HttpClientConfiguration
   * @return {Config}
   */
registerEndpoint(name: any, configureMethod: any, defaults?: any): any;

/**
   * Get a previously registered endpoint. Returns null when not found.
   *
   * @param {string} [name] Returns default endpoint when not set.
   *
   * @return {Rest|null}
   */
getEndpoint(name: any): any;

/**
   * Check if an endpoint has been registered.
   *
   * @param {string} name
   *
   * @return {boolean}
   */
endpointExists(name: any): any;

/**
   * Set a previously registered endpoint as the default.
   *
   * @param {string} name
   *
   * @return {Config}
   */
setDefaultEndpoint(name: any): any;

}
export class Endpoint {

/**
   * Construct the resolver with the specified key.
   *
   * @param {string} key
   */
constructor(key: any);

/**
   * Resolve for key.
   *
   * @param {Container} container
   *
   * @return {*}
   */
get(container: any): any;

/**
   * Get a new resolver for `key`.
   *
   * @param {string} key
   *
   * @return {Endpoint}
   */
static of(key: any): any;

}
}

Rest.post function submits raw string requests

Hi I found an issue with Rest.post submitting requests with raw strings yet the header is "application/json".

My user case is I need to submit a URL to a REST service. Using Rest's post function creates a request with a raw string body. The REST service's JSON parser rightly thinks the URL is a JSON object due to the colon after http.

Cannot use Endpoint.of as a parameter decorator

The following code results in Error: src\app.ts(18,15): error TS1239: Unable to resolve signature of parameter decorator when called as an expression. Cannot invoke an expression whose type lacks a call signature. Type 'Endpoint' has no compatible call signatures.

I'd like to resolve my endpoints in the constructor while also using autoinject in typescript. Is this possible? The example on Aurelia Hub for Resolves in TS mode seems to suggest it: http://aurelia.io/hub.html#/doc/article/aurelia/dependency-injection/latest/dependency-injection-basics/6

@autoinject
export class App {
  constructor(private authService: AuthService,
              private eventAggregator: EventAggregator,
              @Endpoint.of('protected-api')
              private privateResource: Endpoint){}
}

Trailing Slashes

The API I'm accessing, always redirects me to a path with trailing slashes.

For example, it try aceesing this urls:
http://url.com/api/product
http://url.com/api/product/3

I get redirected to those paths, respectively:
http://url.com/api/product/
http://url.com/api/product/3/

The thing is, aurelia-api always never uses trailing slashes, and I end up getting this error:

Fetch API cannot load http://localhost:8000/api/v1/product/3. The request was redirected to 'http://url.com/api/v1/product/3/', which is disallowed for cross-origin requests that require preflight.

Yeah, I know that this is a CORS limitation/security_measure.
But I think it is really use to address this situation in aurelia-api. Having the option to add the trailing slash, shouldn't be a big deal.

Thank you very for your time, btw =)

Environment based Endpoints

Hi,

would it be possible to implement endpoint selection based on environments?
What I would like to do is something like this:

config.registerEndpoint('dev', 'https://localhost);
config.registerEndpoint('stage', 'https://staging.xyz.de/');
config.registerEndpoint('production', 'https://xyz.de/');
config.setEnvironments({
        development: ['localhost'],
        stage: ['staging.xyz.de'],
        production: ['xyz.de']
      });
.setDefaultEndpoint(basedOnEnvironments);

The import part would be the setDefaultEndpoint(). Based on the param, I can tell your plugin to select the default endpoint based on my configured environments (which is more or less a mapping between hostname and endpoint).
Perhaps it is also possible to skip the definition of environments and simply say, if I want an environment based default endpoint, search for the one with the correct hostname in all registered ones.

Best Regards
Marc

Add upload method

It would be really nice to allow users to upload files.

I was thinking of allowing the use of a simple .upload(file), just like any other request. Async uploads ftw!

The project is not loading up correctly.

Not sure whether this is related to the latest release but can someone please help looking at this error and identify what is wrong?

bluebird.min.js:31 Unhandled rejection (SystemJS) exports is not defined ReferenceError: exports is not defined at eval (http://localhost:9000/jspm_packages/npm/[email protected]/aurelia-api.js:5:1) at eval (http://localhost:9000/jspm_packages/npm/[email protected]/aurelia-api.js:249:3) at eval (<anonymous>) at r (http://localhost:9000/jspm_packages/npm/[email protected]/js/browser/bluebird.min.js:33:7722) at i._settlePromiseFromHandler (http://localhost:9000/jspm_packages/npm/[email protected]/js/browser/bluebird.min.js:32:13044) at i._settlePromise (http://localhost:9000/jspm_packages/npm/[email protected]/js/browser/bluebird.min.js:32:13847) at i._settlePromise0 (http://localhost:9000/jspm_packages/npm/[email protected]/js/browser/bluebird.min.js:32:14548) at i._settlePromises (http://localhost:9000/jspm_packages/npm/[email protected]/js/browser/bluebird.min.js:32:15878) at r._drainQueue (http://localhost:9000/jspm_packages/npm/[email protected]/js/browser/bluebird.min.js:31:3148) at r._drainQueues (http://localhost:9000/jspm_packages/npm/[email protected]/js/browser/bluebird.min.js:31:3209) at drainQueues (http://localhost:9000/jspm_packages/npm/[email protected]/js/browser/bluebird.min.js:31:1238) Evaluating http://localhost:9000/jspm_packages/npm/[email protected]/aurelia-api.js Error loading http://localhost:9000/jspm_packages/npm/[email protected]/aurelia-api.js as "npm:[email protected]/aurelia-api" from http://localhost:9000/jspm_packages/npm/[email protected]

typescript errors

I repeated the actions described in the Getting started section of the Aurelia-api document, using the typescript version of the navigation skeleton. Running gulp watch command I get

λ gulp watch
[17:22:58] Using gulpfile H:\work\aurelia-auth0\basic-templates\skeleton-typescript-fs\fe\gulpfile.js
[17:22:58] Starting 'build'...
[17:22:58] Starting 'unbundle'...
[17:22:58] Finished 'unbundle' after 7.27 ms
[17:22:58] Starting 'clean'...
[17:22:59] Finished 'clean' after 36 ms
[17:22:59] Starting 'build-system'...
[17:22:59] Starting 'build-html'...
[17:22:59] Starting 'build-css'...
[17:22:59] Finished 'build-css' after 5.81 ms
[17:22:59] Finished 'build-html' after 153 ms
src\users.ts(11,10): error TS2339: Property 'githubEndpoint' does not exist on type 'Users'.
[17:23:00] gulp-notify: [Error running Gulp] Error: src\users.ts(11,10): error TS2339: Property 'githubEndpoint' does not exist on type 'Users'.
src\users.ts(15,17): error TS2339: Property 'githubEndpoint' does not exist on type 'Users'.
[17:23:00] gulp-notify: [Error running Gulp] Error: src\users.ts(15,17): error TS2339: Property 'githubEndpoint' does not exist on type 'Users'.
[17:23:00] TypeScript: 2 semantic errors
[17:23:00] TypeScript: emit succeeded (with errors)
[17:23:00] Finished 'build-system' after 1.98 s
[17:23:00] Finished 'build' after 2.03 s

Note that I did run the command typings i github:spoonx/aurelia-api - and when that did not help, I manually added the line "aurelia-api": "github:spoonx/aurelia-api", to the typings.json file.

I would presume that this is a problem due to a newer version of tsc.exe (I have the version 1.1.2 installed).

Not configuring on safari

Hey,

The plugin isn't getting configured on safari. I am assuming this has something to do with fetch polyfill. Or maybe something else

Debug log when app loaded in chrome

DEBUG [aurelia] Loading plugin aurelia-validation. aurelia-a3368a4d90.js:7 
DEBUG [aurelia] Configured plugin aurelia-validation. aurelia-a3368a4d90.js:7 
DEBUG [aurelia] Loading plugin aurelia-api. aurelia-a3368a4d90.js:7 
DEBUG [aurelia] Configured plugin aurelia-api. aurelia-a3368a4d90.js:7 

vs
debug log when app loaded in safari

[Debug] DEBUG [aurelia] – "Loading plugin aurelia-validation." (index.html, line 7)
[Debug] DEBUG [aurelia] – "Configured plugin aurelia-validation." (index.html, line 7)
[Debug] DEBUG [aurelia] – "Loading plugin aurelia-api." (index.html, line 7)

Can someone please help me out, thanks?

TS Definitions

Are there any plans to add typescript definitions for this project

Better implementation of Interceptors

Having worked with Aurelia-API for a couple of months now, I'm finding dealing with the interceptors very restrictive. I know too that others have had issue with these, recently @rafaelcamargo has ran in to the same troubles as I.

I understand that the interceptors used through Aurelia-API are actually just the interceptors originating in the Aurelia Fetch Client. However, as Aurelia-API is a wrapper for the Fetch Client, I feel that it should offer a better implementation of the interceptors.

There is a couple of main issues;

The Response Interceptor doesn't allow access to the response body. The response body at the point the interceptor runs is a ReadableStream. This can be read by introducing an async promise to parse the JSON once the body has been recieved, but introducing this promise into the repsonse flow breaks the process. In my opinion - there should be a method available to intercept the response when it has completed, and before the result it passed back to the calling method.

In a similar vein the request interceptor - it seems - offers no way of actually altering the request or its headers prior to the request being made. I had a use case where I needed to take a version from the request body (which was JSON) and add it to the If-Match header. As I couldn't do this through the interceptor I had to create my own wrapper, which wraps Aurelia-API, to set the headers prior to the request being made, and then unsets them afterwards. It really wasn't an ideal solution.

I'd love to hear your thoughts on whether Aurelia-API can offer better, and actually useful, Interceptors.

FEAT: support of traditional URI request templates (RFC6570) when building query strings

Reason: Some endpoints require the old syntax for passing array-like query parameters, like the following ?sort=name&sort=surname (one popular example is Spring Data REST).

Now the Rest object lacks the ability to enable this flag, but the underlying aurelia-path lib that it uses to build query strings supports a traditional flag to enable RFC6570.

I propose a PR that adds a useTraditionalUriTemplates property to the Rest class, that's disabled by default. One can simply set this to true to enable the behavior for the whole instance.
I prefered not to alter all the method signatures, and by the way is more common to have the RFC6570 syntax enabled for the entire API surface and not for some methods only..

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.