Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@archetypical/scaffold

2.0.0 • Public • Published

Scaffold

Scaffold

Scaffold is an library designed to quickly build service workers modeled after the .NET core middleware pipeline.

Example implementation

// service-worker.ts
 
import { IApplicationBuilder, Scaffold } from "@archetypical/scaffold";
import { strategies } from "swork-cache";
 
const offlineAssets = ["/css/site.css", "/js/site.js", "/"];
 
class Startup {
    public configure(builder: IApplicationBuilder): void {
        builder
            .useInstallCache(offlineAssets)
            .map(offlineAssets, strategies.backgroundFetch());
    }
}
 
Scaffold
    .createBuilder("1.0.0")
    .useStartup(Startup)
    .build();

In the example above, we were able to quickly define a list of assets that should be cached up on install of the service worker. In addition, each new request for those assets will immediately return the cached response and update the cache with the latest version in a background process.

Install

npm i @archetypical/scaffold

DownloadsWeekly Downloads

4

Version

2.0.0

License

ISC

Unpacked Size

14.6 kB

Total Files

5

Last publish

Collaborators

  • avatar