https://github.com/endykaufman/ngx-remote-config
Remote configurations for Angular9+ applications, with built-in interceptor for mock REST data and non-permanent api
https://github.com/endykaufman/ngx-remote-config
angular api config directives mock remote rest settings
Last synced: about 2 months ago
JSON representation
Remote configurations for Angular9+ applications, with built-in interceptor for mock REST data and non-permanent api
- Host: GitHub
- URL: https://github.com/endykaufman/ngx-remote-config
- Owner: EndyKaufman
- License: mit
- Created: 2019-04-06T18:26:08.000Z (about 6 years ago)
- Default Branch: develop
- Last Pushed: 2024-03-26T21:47:03.000Z (about 1 year ago)
- Last Synced: 2024-04-14T13:52:37.278Z (about 1 year ago)
- Topics: angular, api, config, directives, mock, remote, rest, settings
- Language: TypeScript
- Homepage: https://endykaufman.github.io/ngx-remote-config
- Size: 2.92 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 47
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ngx-remote-config
[](https://travis-ci.org/EndyKaufman/ngx-remote-config)
[](https://badge.fury.io/js/ngx-remote-config)Remote configurations for Angular9+ applications, with built-in interceptor for mock REST data and non-permanent api
## Installation
```bash
npm i --save ngx-remote-config
```## Links
[Demo](https://endykaufman.github.io/ngx-remote-config) - Demo application with ngx-remote-config.
[Stackblitz](https://stackblitz.com/edit/ngx-remote-config) - Simply sample of usage on https://stackblitz.com
[Demo settings](https://testapi.io/api/EndyKaufman/ngx-remote-config.json) - Settings for demo application stored on https://testapi.io
[Demo Ionic](https://github.com/rucken/todo-ionic) - Example usage in ionic application with native HTTP module
[path-to-regexp](https://github.com/pillarjs/path-to-regexp) - Library usage for match url on interceptor
# Usage
app.module.ts
```js
import { HttpClientModule } from '@angular/common/http';
import { NgxRemoteConfigModule } from 'ngx-remote-config';@NgModule({
imports: [
...
HttpClientModule,
NgxRemoteConfigModule.forRoot({
url: 'https://testapi.io/api/EndyKaufman/ngx-remote-config.json'
}),
...
],
...
})
export class AppModule {}
```app.component.html
```html
...Load with directive
{{config|json}}
Load with service
{{serviceConfig|json}}
...
```app.component.ts
```js
import { NgxRemoteConfigService } from 'ngx-remote-config';
import { Observable } from 'rxjs';
...
serviceConfig$: Observable;
constructor(
private _ngxRemoteConfigService: NgxRemoteConfigService
) {
this.serviceConfig$ = this._ngxRemoteConfigService.config$.asObservable();
}
...
```settings.json (https://testapi.io/api/EndyKaufman/ngx-remote-config.json)
```js
{
"options":{
"name":"Remote name",
"description":"Remote description"
},
"/api/resource/2": {
"get": {
"status": 404,
"body": {
"message": "Fake not found message"
}
}
},
"/api/resource": {
"get": [
{
"name": "get:item1"
},
{
"name": "get:item2"
},
{
"name": "get:item3"
}
]
},
"/api/(.*)": "https://todo-nestjs.rucken.io/api/"
}
```## License
MIT