Skip to content

Commit 6e5d128

Browse files
committed
tsd update
1 parent 5598a22 commit 6e5d128

File tree

4 files changed

+92
-16
lines changed

4 files changed

+92
-16
lines changed

README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@ Angular2 HTTP client to consume RESTful services. Built on angular2/http with Ty
88
npm install angular2-rest
99
```
1010

11-
Load components to your Angular2 project with direct import:
12-
13-
```ts
14-
import {...} from './node_modules/angular2-rest/angular2-rest';
15-
```
16-
17-
Or with SystemJS:
18-
19-
```js
20-
System.config({
21-
map: {
22-
'angular2-rest': 'node_modules/angular2-rest'
23-
}
24-
});
25-
```
26-
2711
## Example
2812

2913
```ts

angular2-rest.d.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { Http, Headers as AngularHeaders } from 'angular2/http';
2+
export interface IRequest {
3+
url: string;
4+
headers: AngularHeaders;
5+
body?: Object;
6+
}
7+
export interface IResponse {
8+
}
9+
/**
10+
* Angular 2 RESTClient class.
11+
*
12+
* @class RESTClient
13+
* @constructor
14+
*/
15+
export declare class RESTClient {
16+
protected http: Http;
17+
constructor(http: Http);
18+
protected getBaseUrl(): string;
19+
protected getDefaultHeaders(): Object;
20+
/**
21+
* Request Interceptor
22+
*
23+
* @method requestInterceptor
24+
* @param {IRequest} req - request object
25+
*/
26+
protected requestInterceptor(req: IRequest): void;
27+
/**
28+
* Response Interceptor
29+
* NOT IMPLEMENTED YET!
30+
*
31+
* @method responseInterceptor
32+
* @param {IResponse} resp - response object
33+
*/
34+
protected responseInterceptor(resp: IResponse): void;
35+
}
36+
/**
37+
* Set the base URL of REST resource
38+
* @param {String} url - base URL
39+
*/
40+
export declare function BaseUrl(url: string): <TFunction extends Function>(Target: TFunction) => TFunction;
41+
/**
42+
* Set default headers for every method of the RESTClient
43+
* @param {Object} headers - deafult headers in a key-value pair
44+
*/
45+
export declare function DefaultHeaders(headers: any): <TFunction extends Function>(Target: TFunction) => TFunction;
46+
/**
47+
* Path variable of a method's url, type: string
48+
* @param {string} key - path key to bind value
49+
*/
50+
export declare var Path: (key: string) => (target: RESTClient, propertyKey: string | symbol, parameterIndex: number) => void;
51+
/**
52+
* Query value of a method's url, type: string
53+
* @param {string} key - query key to bind value
54+
*/
55+
export declare var Query: (key: string) => (target: RESTClient, propertyKey: string | symbol, parameterIndex: number) => void;
56+
/**
57+
* Body of a REST method, type: key-value pair object
58+
* Only one body per method!
59+
*/
60+
export declare var Body: (target: RESTClient, propertyKey: string | symbol, parameterIndex: number) => void;
61+
/**
62+
* Custom header of a REST method, type: string
63+
* @param {string} key - header key to bind value
64+
*/
65+
export declare var Header: (key: string) => (target: RESTClient, propertyKey: string | symbol, parameterIndex: number) => void;
66+
/**
67+
* Set custom headers for a REST method
68+
* @param {Object} headersDef - custom headers in a key-value pair
69+
*/
70+
export declare function Headers(headersDef: any): (target: RESTClient, propertyKey: string, descriptor: any) => any;
71+
/**
72+
* GET method
73+
* @param {string} url - resource url of the method
74+
*/
75+
export declare var GET: (url: string) => (target: RESTClient, propertyKey: string, descriptor: any) => any;
76+
/**
77+
* POST method
78+
* @param {string} url - resource url of the method
79+
*/
80+
export declare var POST: (url: string) => (target: RESTClient, propertyKey: string, descriptor: any) => any;
81+
/**
82+
* PUT method
83+
* @param {string} url - resource url of the method
84+
*/
85+
export declare var PUT: (url: string) => (target: RESTClient, propertyKey: string, descriptor: any) => any;
86+
/**
87+
* DELETE method
88+
* @param {string} url - resource url of the method
89+
*/
90+
export declare var DELETE: (url: string) => (target: RESTClient, propertyKey: string, descriptor: any) => any;

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ gulp.task('compile', function () {
88
.pipe(typescript({
99
"target": "es5",
1010
"noImplicitAny": false,
11+
"declaration": true,
1112
"emitDecoratorMetadata": true,
1213
"experimentalDecorators": true,
1314
}))

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "angular2-rest",
33
"version": "0.0.1",
44
"description": "Angular2 HTTP client to consume RESTful services.",
5+
"typings": "./angular2-rest.d.ts",
56
"scripts": {
67
"test": "gulp test"
78
},

0 commit comments

Comments
 (0)