Notoriously Pedantic Magistrate

    @bayerjs/static
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.0-alpha.1 • Public • Published

    @bayerjs/static

    Static middleware for Bayer.js.

    Note of caution

    This is a pretty naive implementation, without proper MIME handling, or security concerns. It is mainly provided as a convinience function.

    Usage

    import Bayer from "@bayerjs/core";
    import staticFiles from "@bayerjs/static";
    
    const server = new Bayer();
    server.use(staticFiles({ localPath: "../public" }));

    The options object has the following structure:

    /**
     * Options interface for the Bayer.js static middleware.
     */
    export interface IBayerStaticOptions {
      /** Local path to the directory containing the */
      localPath: string;
      /** Whether to use the index file on directory hits */
      useIndexFile?: boolean; // default: true
      /** File to serve on directory hits, relative to the hit directory */
      indexFile?: string; // default: "index.html"
      /** Whether to enable SPA mode, which serves a file relative to localPath on 404 errors */
      spaMode?: boolean; // default: false
      /** File to serve on 404 errors */
      spaFile?: string; // default: "index.html"
    }

    Install

    npm i @bayerjs/static

    DownloadsWeekly Downloads

    2

    Version

    0.3.0-alpha.1

    License

    MIT

    Unpacked Size

    15.9 kB

    Total Files

    7

    Last publish

    Collaborators

    • solarliner