
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
Angular2 API services that wrap Http. See full client and server example ng2-api-examples
npm i --save ng2-api
import {provide, Injectable, NgZone} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Router} from '@angular/router-deprecated';
import {ApiConfig, ApiHttp} from 'ng2-api';
export function authenticated(): boolean {
return !!localStorage.getItem('token');
}
@Injectable()
export class Auth {
user: Object;
constructor(protected http: ApiHttp,
protected zone: NgZone,
protected router: Router) {
this.user = JSON.parse(localStorage.getItem('profile'));
}
authenticated() {
return authenticated();
}
login(params: any) {
return this.http.post('login', JSON.stringify(params))
.subscribe((res: Response) => {
let {token, user} = res.json();
localStorage.setItem('profile', JSON.stringify(user));
localStorage.setItem('token', token);
this.zone.run(() => this.user = user);
this.router.navigate(['/Dashboard']);
});
}
logout() {
localStorage.removeItem('profile');
localStorage.removeItem('token');
this.zone.run(() => this.user = null);
this.router.navigate(['/Login']);
}
}
export const AUTH_PROVIDERS: any = [
provide(ApiHttp, {
useFactory: (http: Http) => {
return new ApiHttp(new ApiConfig({baseUrl: 'http://localhost:8081'}), http);
},
deps: [Http]
}),
Auth
];
bootstrap(App, [
...HTTP_PROVIDERS,
...ROUTER_PROVIDERS,
...AUTH_PROVIDERS
])
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import {ApiService} from 'ng2-api';
export interface Post {
id: number;
title: string;
body: string;
}
@Injectable()
export class PostsService extends ApiService<Post> {
constructor(protected http: ApiHttp) {
super(http, 'posts');
}
}
find(id: number | string): Observable<Post>
findAll(search?: any): Observable<Post[]>
create(model: Post): Observable<Post>
update(model: Post): Observable<Post>
delete(model: Post): Observable<boolean>
npm i
npm run build
npm run test:w
MIT
FAQs
Angular2 API services
The npm package ng2-api receives a total of 2 weekly downloads. As such, ng2-api popularity was classified as not popular.
We found that ng2-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.