Skip to content

Commit 667678f

Browse files
committed
compatible with angular-cli and AoT
1 parent c1c7f05 commit 667678f

21 files changed

+520
-77
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ typings/
2121
*.spec.js.map
2222
*.spec.d.ts
2323

24+
25+
/compiled
26+
*.metadata.json
27+
28+
*.map.js
29+
*.js # or /src/**/*.js

.npmignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,11 @@ npm-debug.log
1616
# RESOURCES
1717
node_modules/
1818
typings/
19-
src
19+
src
20+
21+
/compiled
22+
*.ngFactory.ts
23+
# ignore all typescript
24+
*.ts
25+
# allow only ambient type definitions
26+
!*.d.ts

index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export * from "./dist/index"
1+
export { SailsService } from './lib/sails.service';
2+
export { SailsModule } from './lib/sails.module';

index.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {SailsService} from './lib/sails.service';
2+
export {SailsModule} from './lib/sails.module';

lib/sails.module.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { ModuleWithProviders } from "@angular/core";
2+
export declare class SailsModule {
3+
static forRoot(): ModuleWithProviders;
4+
}

lib/sails.module.js

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/sails.module.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/sails.module.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {NgModule, ModuleWithProviders} from "@angular/core";
2+
import {SailsService} from "./sails.service";
3+
4+
@NgModule({
5+
imports: [],
6+
exports: [],
7+
declarations: [],
8+
providers: [],
9+
entryComponents: []
10+
})
11+
export class SailsModule {
12+
static forRoot(): ModuleWithProviders {
13+
return {
14+
ngModule: SailsModule,
15+
providers: [SailsService]
16+
};
17+
}
18+
}
19+

lib/sails.service.d.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { NgZone } from "@angular/core";
2+
import { Observable } from "rxjs/Rx";
3+
export declare class SailsService {
4+
private zone;
5+
private _io;
6+
private _connected;
7+
private _opts;
8+
private _restPrefix;
9+
private _serverUrl;
10+
private _pubsubSubscriptions;
11+
constructor(zone: NgZone);
12+
restPrefix: string;
13+
serverUrl: string;
14+
connect(url: any, opts?: any): void;
15+
/**
16+
* @title request
17+
*
18+
* @description Send a virtual request to a Sails server using Socket.io.
19+
* This function is very similar to .get(), .post(), etc.
20+
* except that it provides lower-level access to the request headers, parameters,
21+
* method, and URL of the request.
22+
*
23+
* example:
24+
* @Component()
25+
* export class MyClass implements OnInit {
26+
* constructor(private _sailsService:SailsService){}
27+
*
28+
* ngOnInit{
29+
*
30+
* let options = {
31+
* method: 'get',
32+
* url: 'http://localhost:1337/users'
33+
* data: {},
34+
* headers: {
35+
* 'x-csrf-token': 'ji4brixbiub3'
36+
* }
37+
* }
38+
*
39+
* this._sailsService.request().subscribe(data => {
40+
* // do something with the data
41+
* })
42+
*
43+
* }
44+
* }
45+
*
46+
* @param options
47+
* @return {Observable<T>}
48+
*/
49+
request(options: any): Observable<any>;
50+
/**
51+
*
52+
* @param url
53+
* @param data
54+
* @return {Observable<T>}
55+
*/
56+
get(url: any, data?: any): Observable<any>;
57+
/**
58+
*
59+
* @param url
60+
* @param data
61+
* @return {Observable<T>}
62+
*/
63+
post(url: any, data?: any): Observable<any>;
64+
/**
65+
*
66+
* @param url
67+
* @param data
68+
* @return {Observable<T>}
69+
*/
70+
put(url: any, data?: any): Observable<any>;
71+
/**
72+
*
73+
* @param url
74+
* @param data
75+
* @return {Observable<T>}
76+
*/
77+
delete(url: any, data?: any): Observable<any>;
78+
/**
79+
*
80+
* @param eventIdentity
81+
* @return {Observable<T>}
82+
*/
83+
on(eventIdentity: string): Observable<any>;
84+
}

0 commit comments

Comments
 (0)