
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@dlarsson-se/cached-api
Advanced tools
A library for handling cached web requests.
npm install @dlarsson-se/cached-api -S
import { APIModule, CachedAPIService } from '@dlarsson-se/cached-api;
@NgModule({
imports: [ APIModule.forRoot() ] // If it works, or
...
imports: [ APIModule ], // If it doesn't
providers: [ CachedAPIService ]
})
export class AppModule {
constructor(public apiService: CachedAPIService) {
/* If the requests should contain Authorization: Bearer TOKEN */
apiService.setToken('YOUR_TOKEN');
/* Default URL for TestData objects. */
apiService.addURL(TestData, "http://localhost/testdata");
/* Custom URL for the find command. */
apiService.addURL(TestData, "http://localhost/testdatas", "find");
}
}
import { CachedAPIService } from '@dlarsson-se/cached-api';
export class AppComponent {
constructor(private apiService: CachedAPIService) {
let id = 1;
/* Get By ID */
apiService.get(TestData, id)
.subscribe((value) => {
/* Do something with the reply. */
}, (error) => {
/* Error handling. */
})
/* Find */
apiService.find(TestData)
.subscribe((values) => {
/* Do something with the reply. */
}, (error) => {
/* Error handling. */
})
}
}
import { APIComponent, CachedAPIService } from '@dlarsson-se/cached-api';
export class AppComponent extends APIComponent {
constructor(public apiService: CachedAPIService) {
super(apiService);
let id = 1;
/* get with mandatory supplied id. */
let p1 = this.getAsync(TestData, id)
/* find with optional querystring. */
let p2 = this.findAsync(TestData, "YOUR_QUERY_HERE")
/* Handle all promises. */
Promise
.all([p1, p2])
.then((values) => {
/* Do something with the reply. */
})
.catch((error) => {
/* Error handling. */
})
}
}
import { IAPIClass } from '@dlarsson-se/cached-api';
export class TestData implements IAPIClass {
public _cachedAt: number = 0;
public _className: string = "TestData";
}
npm test
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
npm run format
npm run lint
FAQs
Cached API request package.
We found that @dlarsson-se/cached-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.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.