Comparing version 0.3.7 to 0.4.0
@@ -18,3 +18,4 @@ "use strict"; | ||
var _this = this; | ||
return this.http.get(api_helpers_1.ApiHelpers.interpolate(this.path + "/:id", { id: id })).map(function (res) { return _this.deserialize(res.json()); }); | ||
var requestOptions = new http_1.RequestOptions({ body: '' }); | ||
return this.http.get(api_helpers_1.ApiHelpers.interpolate(this.path + "/:id", { id: id }), requestOptions).map(function (res) { return _this.deserialize(res.json()); }); | ||
}; | ||
@@ -24,3 +25,6 @@ ApiService.prototype.findAll = function (search) { | ||
var interpolatedPath = api_helpers_1.ApiHelpers.interpolate(this.path, search, true); | ||
var requestOptions = new http_1.RequestOptions({ search: api_helpers_1.ApiHelpers.toSearch(search) }); | ||
var requestOptions = new http_1.RequestOptions({ | ||
body: '', | ||
search: api_helpers_1.ApiHelpers.toSearch(search) | ||
}); | ||
return this.http.get(interpolatedPath, requestOptions).map(function (res) { | ||
@@ -42,3 +46,4 @@ return res.json().map(function (item) { | ||
ApiService.prototype.delete = function (model) { | ||
return this.http.delete(api_helpers_1.ApiHelpers.interpolate(this.path + "/:id", model)).map(function (res) { return res.ok; }); | ||
var requestOptions = new http_1.RequestOptions({ body: '' }); | ||
return this.http.delete(api_helpers_1.ApiHelpers.interpolate(this.path + "/:id", model), requestOptions).map(function (res) { return res.ok; }); | ||
}; | ||
@@ -48,2 +53,2 @@ return ApiService; | ||
exports.ApiService = ApiService; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLXNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYXBpLXNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHFCQUF1QyxlQUFlLENBQUMsQ0FBQTtBQUV2RCxRQUFPLHVCQUF1QixDQUFDLENBQUE7QUFDL0IsNEJBQXlCLGVBQWUsQ0FBQyxDQUFBO0FBR3pDO0lBQ0Usb0JBQXNCLElB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AgICAgIHRoaXMuc2VyaWFsaXplKG1vZGVsKVxuICAgICkubWFwKChyZXM6IFJlc3BvbnNlKSA9PiB0aGlzLmRlc2VyaWFsaXplKHJlcy5qc29uKCkpKTtcbiAgfVxuXG4gIGRlbGV0ZShtb2RlbDogVCk6IE9ic2VydmFibGU8Ym9vbGVhbj4ge1xuICAgIGxldCByZXF1ZXN0T3B0aW9ucyA9IG5ldyBSZXF1ZXN0T3B0aW9ucyh7Ym9keTogJyd9KTtcblxuICAgIHJldHVybiB0aGlzLmh0dHAuZGVsZXRlKFxuICAgICAgQXBpSGVscGVycy5pbnRlcnBvbGF0ZShgJHt0aGlzLnBhdGh9LzppZGAsIG1vZGVsKSxcbiAgICAgIHJlcXVlc3RPcHRpb25zXG4gICAgKS5tYXAoKHJlczogUmVzcG9uc2UpID0+IHJlcy5vayk7XG4gIH1cbn1cbiJdfQ== |
@@ -41,5 +41,15 @@ // Karma configuration | ||
typescriptPreprocessor: { | ||
options: require('./tsconfig.json').compilerOptions, | ||
options: { | ||
"declaration": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noImplicitAny": true, | ||
"target": "es5", | ||
}, | ||
typings: [ | ||
"typings/main.d.ts" | ||
"typings/index.d.ts" | ||
] | ||
@@ -46,0 +56,0 @@ }, |
{ | ||
"name": "ng2-api", | ||
"version": "0.3.7", | ||
"version": "0.4.0", | ||
"description": "Angular2 API services", | ||
@@ -13,3 +13,3 @@ "main": "dist/ng2-api.js", | ||
"test:w": "karma start --no-single-run --auto-watch", | ||
"prepublish": "npm run build" | ||
"prepublish": "npm run build && npm test" | ||
}, | ||
@@ -16,0 +16,0 @@ "keywords": [ |
@@ -14,6 +14,6 @@ # ng2-api | ||
import {provide, Injectable, NgZone} from '@angular/core'; | ||
import {Http, Response} from '@angular/http'; | ||
import {Router} from '@angular/router-deprecated'; | ||
import {ApiConfig, ApiHttp} from 'ng2-api'; | ||
import { Injectable, NgZone } from '@angular/core'; | ||
import { Http, Response } from '@angular/http'; | ||
import { Router} from '@angular/router-deprecated'; | ||
import { ApiConfig, ApiHttp } from 'ng2-api'; | ||
@@ -45,3 +45,3 @@ export function authenticated(): boolean { | ||
this.zone.run(() => this.user = user); | ||
this.router.navigate(['/Dashboard']); | ||
this.router.navigate(['/Posts']); | ||
}); | ||
@@ -56,30 +56,49 @@ } | ||
} | ||
} | ||
} | ||
### app.module.ts | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { HttpModule, Http } from '@angular/http'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { ApiConfig, ApiHttp } from './ng2-api'; | ||
export const AUTH_PROVIDERS: any = [ | ||
provide(ApiHttp, { | ||
useFactory: (http: Http) => { | ||
return new ApiHttp(new ApiConfig({baseUrl: 'http://localhost:8081'}), http); | ||
import { AppComponent } from './app.component'; | ||
import { AuthService } from './shared/auth.service'; | ||
import { PostsComponent } from './posts/posts.component'; | ||
import { PostsService } from './posts/posts.service'; | ||
import { routing } from './app.routing'; | ||
@NgModule({ | ||
imports: [ | ||
BrowserModule, | ||
HttpModule, | ||
FormsModule, | ||
routing | ||
], | ||
declarations: [ | ||
AppComponent, | ||
PostsComponent, | ||
], | ||
providers: [ | ||
{ | ||
provide: ApiHttp, | ||
useFactory: (http: Http) => new ApiHttp(new ApiConfig({baseUrl: '/api'}), http), | ||
deps: [Http] | ||
}, | ||
deps: [Http] | ||
}), | ||
Auth | ||
]; | ||
AuthService, | ||
PostsService, | ||
], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule {} | ||
### bootstrap.ts | ||
bootstrap(App, [ | ||
...HTTP_PROVIDERS, | ||
...ROUTER_PROVIDERS, | ||
...AUTH_PROVIDERS | ||
]) | ||
### posts.service.ts | ||
import {Injectable} from '@angular/core'; | ||
import {Http} from '@angular/http'; | ||
import {ApiService} from 'ng2-api'; | ||
import { Injectable } from '@angular/core'; | ||
import { ApiService } from 'ng2-api'; | ||
export interface Post { | ||
id: number; | ||
id?: number; | ||
title: string; | ||
@@ -86,0 +105,0 @@ body: string; |
@@ -21,4 +21,7 @@ import {Response, RequestOptions} from '@angular/http'; | ||
find(id: number|string): Observable<T> { | ||
let requestOptions = new RequestOptions({body: ''}); | ||
return this.http.get( | ||
ApiHelpers.interpolate(`${this.path}/:id`, {id}) | ||
ApiHelpers.interpolate(`${this.path}/:id`, {id}), | ||
requestOptions | ||
).map((res: Response) => this.deserialize(res.json())); | ||
@@ -29,3 +32,6 @@ } | ||
let interpolatedPath = ApiHelpers.interpolate(this.path, search, true); | ||
let requestOptions = new RequestOptions({search: ApiHelpers.toSearch(search)}); | ||
let requestOptions = new RequestOptions({ | ||
body: '', | ||
search: ApiHelpers.toSearch(search) | ||
}); | ||
@@ -55,6 +61,9 @@ return this.http.get( | ||
delete(model: T): Observable<boolean> { | ||
let requestOptions = new RequestOptions({body: ''}); | ||
return this.http.delete( | ||
ApiHelpers.interpolate(`${this.path}/:id`, model) | ||
ApiHelpers.interpolate(`${this.path}/:id`, model), | ||
requestOptions | ||
).map((res: Response) => res.ok); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42610
608
129