api/static

Description:
  • API Static Module - Handles serving static files and templates with Express.

    Features:

    • Static file serving from multiple directories
    • View templating engine mapping or redirection (e.g., using EJS, Pug) of any request path, allows dynamically use API routes, templating views or static files with configuration only, supports template placeholders from module:api.checkRequestPlaceholders
    • Virtual hosting with custom paths
    • Regex-based path matching for rules
    • Compression (GZIP/Brotli) for static assets
    • Custom MIME type definitions
    • Development/production caching controls

    Explanation of the example below

    • disabled=true → The app acts like a pure API (no static files at all).
    • views-{regex} acts like URL-to-template routing (e.g., /user loads show-user.ejs, you have to register ejs egine in your configureStaticWeb method).
    • vhost-{blog}=blog.com → Rewrites /css/page.css to /web/blog/css/page.css if host is blog.com.
    • compressed-js=gz → Serves index.js as index.js.gz if the file exists.
Source:
Example
api-static-disabled=false
api-static-views-^/user=show-user.ejs
api-static-vhost-blog=blog.com
api-static-compressed-js=gz

module:api/static

Description:
  • Default module to return assets using Express static

Source: