You will have also an ability to define middleware to transform your storage content to the content you want for your application.

You register a middleware by providing a pattern when the middleware needs to be handled and the middleware implementation.

ss.use('*', new UpperMiddleware());

When you want to create your own middleware you can just implement the 'MiddlewareStack' interface.

An example of a middleware implementation that has a counter and transforms the content to uppercase when it is been set.

class UpperMiddleware implements MiddlewareStack {
    count = 1;
    set(storageInfo: StorageInfo, next: () => void) {
        storageInfo.content = storageInfo.content.toUpperCase();
    get(storageInfo: StorageInfo, next: () => void) {
        storageInfo.content = `${this.count} ${storageInfo.origin}`;

Last updated