Gathering detailed insights and metrics for ng2-vs-backend
Gathering detailed insights and metrics for ng2-vs-backend
Gathering detailed insights and metrics for ng2-vs-backend
Gathering detailed insights and metrics for ng2-vs-backend
npm install ng2-vs-backend
Typescript
Module System
Node Version
NPM Version
74.2
Supply Chain
98.7
Quality
75.3
Maintenance
50
Vulnerability
99.3
License
TypeScript (75.72%)
JavaScript (17.82%)
HTML (6.46%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
16 Commits
2 Watchers
2 Branches
1 Contributors
Updated on Mar 02, 2017
Latest Version
0.0.4
Package Id
ng2-vs-backend@0.0.4
Size
139.70 kB
NPM Version
3.10.8
Node Version
6.9.1
Published on
Mar 01, 2017
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
45
https://llafuente.github.io/ng2-vs-backend/demo/
Module to create Mock API Backends for Angular 2, and if there is no handler found do a XHR.
Install through npm:
npm install --save ng2-vs-backend
Import VSBackendModule in your module
1import {NgModule} from '@angular/core'; 2import {BackendService} from './backendservice'; 3import {VSBackendModule} from 'ng2-vs-backend'; 4 5@NgModule({ 6 imports: [VSBackendModule], 7 providers: [ 8 BackendService, // this extends BackendBaseService 9 ] 10}) 11export class YourModule { 12 constructor(backendService: BackendService) { 13 backendService.init(); // initialize now! 14 } 15}
Extend BackendBaseService with your API declaration.
1import {BackendBaseService, ParsedRequest} from 'ng2-vs-backend'; 2import {Injectable} from '@angular/core'; 3import {MockBackend} from '@angular/http/testing'; 4import { 5 BaseRequestOptions, 6 ResponseOptions, 7 Headers, 8 XHRBackend, 9 RequestOptions, 10} from '@angular/http'; 11 12@Injectable() 13export class BackendService extends BackendBaseService { 14 constructor( 15 public backend: MockBackend, 16 public options: BaseRequestOptions, 17 public realBackend: XHRBackend 18 ) { 19 super(backend, options, realBackend); 20 } 21 22 init(): void { 23 super.init(); 24 // just return a value 25 let countries: any[] = [ 26 {id: 1, label: 'Spain'}, 27 {id: 2, label: 'France'}, 28 ]; 29 this.addValue('GET', '/api/v1/countries', countries); 30 31 this.addValuePaginated('GET', '/api/v1/countries2', countries); 32 33 // handle request yourself, for example to update a country 34 backendService.addListener('POST', /\/api\/v1\/country\/(.*)/, (p: ParsedRequest, matches: string[]) => { 35 // matches is the result of the RegExp sent 36 let id: number = parseInt(matches[1], 10); 37 38 countries[id].label = body.label; 39 40 return new ResponseOptions({ 41 status: 204 42 }); 43 }); 44 } 45} 46
You may also find it useful to view the demo source.
<script src="node_modules/dist/umd/ng2-vs-backend/ng2-vs-backend.js"></script>
<script>
// everything is exported VSBackend namespace
</script>
All documentation is auto-generated from the source via typedoc and can be viewed here: https://llafuente.github.io/ng2-vs-backend/docs/
npm install
while current directory is this repoRun npm start
to start a development server on port 8000 with auto reload + tests.
Run npm test
to run tests once or npm run test:watch
to continually run tests.
1npm run release
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/16 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More