@contextjs/webserver-middleware-static
v25.1.0
Published
Static files middleware for the ContextJS WebServer.
Downloads
67
Maintainers
Readme
@contextjs/webserver-middleware-static
Static files middleware for the ContextJS webserver.
Installation
npm i @contextjs/webserver-middleware-staticUsage
import "@contextjs/webserver-middleware-static";
import { Application } from "@contextjs/system";
import { WebServerOptions } from "@contextjs/webserver";
import { StaticFilesOptions } from "@contextjs/webserver-middleware-static";
const application = new Application();
application.useWebServer((options: WebServerOptions) => {
options.onEvent = e => console.log(`[WebServer:${e.type}]`, e.detail);
options.useStaticFiles((staticFilesOptions: StaticFilesOptions) => {
staticFilesOptions.publicFolder = "your-static-files_folder";
staticFilesOptions.fileExtensions = ["png", "jpg", "jpeg", "gif"]; // Only allow these file types
// staticFilesOptions.fileExtensions = []; // Uncomment to allow all file types
});
});
await application.runAsync();API Reference
For detailed API documentation, please refer to the API Reference.
