Skip to content

Commit

Permalink
Split the src files into service and service provider files
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhenry committed Jun 30, 2015
1 parent 1d80213 commit 2dca733
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 63 deletions.
16 changes: 16 additions & 0 deletions dist/ngJwtAuth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ declare module NgJwtAuth {
refresh?: string;
}
}
declare module NgJwtAuth {
class NgJwtAuthService implements INgJwtAuthService {
private $http;
static $inject: string[];
constructor($http: ng.IHttpService);
isLoginMethod(url: string, subString: string): boolean;
getUser(): Object;
getPromisedUser(): ng.IPromise<Object>;
processNewToken(rawToken: string): boolean;
clearToken(): boolean;
authenticate(username: string, password: string): ng.IPromise<Object>;
exchangeToken(token: string): ng.IPromise<Object>;
requireLogin(): ng.IPromise<Object>;
private getRemoteData(url);
}
}
declare module NgJwtAuth {
class NgJwtAuthServiceProvider implements ng.IServiceProvider, INgJwtAuthServiceProvider {
apiEndpoints: IEndpointDefinition;
Expand Down
56 changes: 32 additions & 24 deletions dist/ngJwtAuth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ngJwtAuth.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 1 addition & 38 deletions src/ngJwtAuth.ts → src/ngJwtAuthService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,7 @@

module NgJwtAuth {

export class NgJwtAuthServiceProvider implements ng.IServiceProvider, INgJwtAuthServiceProvider {

public apiEndpoints : IEndpointDefinition;

constructor() {

this.apiEndpoints = {
base: '/api/auth',
login: '/login',
tokenExchange: '/token',
refresh: '/refresh'
};

}

/**
* Set the API endpoints for the auth service to call
* @param config
* @returns {NgJwtAuth.NgJwtAuthServiceProvider}
*/
public setApiEndpoints(config:IEndpointDefinition) : NgJwtAuthServiceProvider {
this.apiEndpoints = _.defaults(config, this.apiEndpoints);
return this;
}


public $get(): INgJwtAuthService {

return new NgJwtAuthService(null);
}

}

class NgJwtAuthService implements INgJwtAuthService {
export class NgJwtAuthService implements INgJwtAuthService {

//list injected dependencies
private $http: ng.IHttpService;
Expand Down Expand Up @@ -94,8 +61,4 @@ module NgJwtAuth {

}

angular.module('ngJwtAuth', [])
.provider('ngJwtAuthService', NgJwtAuthServiceProvider)
;

}
45 changes: 45 additions & 0 deletions src/ngJwtAuthServiceProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/// <reference path="../typings/lodash/lodash.d.ts" />
/// <reference path="../typings/angularjs/angular.d.ts" />
/// <reference path="./ngJwtAuthInterfaces.ts" />
/// <reference path="./ngJwtAuthService.ts" />

module NgJwtAuth {

export class NgJwtAuthServiceProvider implements ng.IServiceProvider, INgJwtAuthServiceProvider {

public apiEndpoints : IEndpointDefinition;

constructor() {

this.apiEndpoints = {
base: '/api/auth',
login: '/login',
tokenExchange: '/token',
refresh: '/refresh'
};

}

/**
* Set the API endpoints for the auth service to call
* @param config
* @returns {NgJwtAuth.NgJwtAuthServiceProvider}
*/
public setApiEndpoints(config:IEndpointDefinition) : NgJwtAuthServiceProvider {
this.apiEndpoints = _.defaults(config, this.apiEndpoints);
return this;
}


public $get(): INgJwtAuthService {

return new NgJwtAuthService(null);
}

}

angular.module('ngJwtAuth', [])
.provider('ngJwtAuthService', NgJwtAuthServiceProvider)
;

}

0 comments on commit 2dca733

Please sign in to comment.