Skip to content

Commit

Permalink
fix: aot build
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveVanOpstal committed Feb 28, 2018
1 parent 7647c49 commit 7dc419d
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 16 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ npm install angular-interceptors --save
- [Cache Interceptor](#cache-interceptor)
- [Ensure Https Interceptor](#ensure-https-interceptor)
- [Prefix Url Interceptor](#prefix-url-interceptor)
- [InjectionTokens](#injectiontokens)

### Cache Interceptor
Cache all HTTP `GET` requests.
Expand All @@ -20,7 +21,7 @@ import {CacheInterceptorModule} from 'angular-interceptors';

@NgModule({
imports: [
CacheInterceptorModule.forRoot(5 * 1000) // Max age in milliseconds. In this case 5 seconds.
CacheInterceptorModule.forRoot(3 * 1000) // Max age in milliseconds. In this case 3 seconds. Defaults to 5 seconds.
]
})
```
Expand Down Expand Up @@ -75,3 +76,17 @@ Example:
```typescript
this.http.get('/api/user'); // --> https://some.url/api/user
```

### InjectionTokens
`MAX_AGE_MS` for `CacheInterceptorModule` and `PREFIX` for `PrefixUrlInterceptorModule` are also available as `InjectionToken`s

``` typescript
import {MAX_AGE_MS, PREFIX} from 'angular-interceptors';

@NgModule({
providers: [
{provide: MAX_AGE_MS, useValue: 3 * 1000},
{provide: PREFIX, useValue: 'https://some.url'}
]
})
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"ngPackage": {
"dest": "lib",
"lib": {
"entryFile": "public_api.ts"
"entryFile": "src/public_api.ts"
}
}
}
3 changes: 0 additions & 3 deletions public_api.ts

This file was deleted.

File renamed without changes.
8 changes: 2 additions & 6 deletions src/cache/cache.module.ts → src/cache.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import {InjectionToken, ModuleWithProviders, NgModule} from '@angular/core';
import {CACHE_INTERCEPTOR_PROVIDER, MAX_AGE_MS} from './cache.interceptor';
export {MAX_AGE_MS} from './cache.interceptor';

@NgModule()
export class CacheInterceptorModule {
/**
* maxAgeMs InjectionToken
*/
static maxAgeMs = MAX_AGE_MS;

/**
* Cache all HTTP `GET` requests.
*/
static forRoot(maxAgeMs: number): ModuleWithProviders {
static forRoot(maxAgeMs: number = 5000): ModuleWithProviders {
return {
ngModule: CacheInterceptorModule,
providers: [CACHE_INTERCEPTOR_PROVIDER, {provide: MAX_AGE_MS, useValue: maxAgeMs}]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import {InjectionToken, ModuleWithProviders, NgModule} from '@angular/core';
import {PREFIX, PREFIX_URL_INTERCEPTOR_PROVIDER} from './prefix-url.interceptor';
export {PREFIX} from './prefix-url.interceptor';

@NgModule()
export class PrefixUrlInterceptorModule {
/**
* Prefix InjectionToken
*/
static prefix = PREFIX;

/**
* Prefix HTTP request urls.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export {CacheInterceptorModule, MAX_AGE_MS} from './cache.module';
export {EnsureHttpsInterceptorModule} from './ensure-https.module';
export {PrefixUrlInterceptorModule, PREFIX} from './prefix-url.module';

0 comments on commit 7dc419d

Please sign in to comment.