Commit 807f6df689415c1cafe199090d3c1cf4ed3c6387
1 parent
17b9833a
Exists in
master
and in
1 other branch
added ng-noosfero-api lib path
Showing
4 changed files
with
76 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | + | ||
2 | +module NgNoosferoAPI { | ||
3 | + export interface NoosferoHttpServiceConfig { | ||
4 | + protocol: string; | ||
5 | + hostname: string; | ||
6 | + port: number; | ||
7 | + apiPath: string; | ||
8 | + acceptHeader: string; | ||
9 | + contentTypeHeader: string; | ||
10 | + textEncoding: string; | ||
11 | + | ||
12 | + } | ||
13 | + | ||
14 | + export function configNoosferoHttpService(hostname: string, port?: number, protocol?: string) { | ||
15 | + return <NoosferoHttpServiceConfig>{ | ||
16 | + hostname: hostname, | ||
17 | + port: port || 80, | ||
18 | + apiPath: "/api/v1", | ||
19 | + protocol: protocol || "http", | ||
20 | + acceptHeader: "application/json", | ||
21 | + contentTypeHeader: "application/json", | ||
22 | + textEncoding: "UTF-8" | ||
23 | + }; | ||
24 | + } | ||
25 | + | ||
26 | +} | ||
0 | \ No newline at end of file | 27 | \ No newline at end of file |
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +module NgNoosferoAPI { | ||
2 | + | ||
3 | + | ||
4 | + // The following class represents the provider | ||
5 | + export class NoosferoHttpServiceConfigProvider implements ng.IServiceProvider { | ||
6 | + private config = <NoosferoHttpServiceConfig>{ | ||
7 | + hostname: "localhost", | ||
8 | + protocol: "http", | ||
9 | + port: 3000, | ||
10 | + apiPath: "/api/v1", | ||
11 | + acceptHeader: "application/json", | ||
12 | + contentTypeHeader: "application/json", | ||
13 | + textEncoding: "UTF-8" | ||
14 | + }; | ||
15 | + | ||
16 | + | ||
17 | + // Configuration function | ||
18 | + public setConfig(config: NoosferoHttpServiceConfig) { | ||
19 | + this.config = config; | ||
20 | + } | ||
21 | + | ||
22 | + // Provider's factory function | ||
23 | + public $get(): NoosferoHttpServiceConfig { | ||
24 | + return this.config; | ||
25 | + } | ||
26 | + } | ||
27 | + | ||
28 | + ngModule.provider("NoosferoHttpServiceConfig", NoosferoHttpServiceConfigProvider); | ||
29 | + | ||
30 | +} | ||
0 | \ No newline at end of file | 31 | \ No newline at end of file |