- 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.,/userloadsshow-user.ejs, you have to register ejs egine in yourconfigureStaticWebmethod).vhost-{blog}=blog.com→ Rewrites/css/page.cssto/web/blog/css/page.cssif host isblog.com.compressed-js=gz→ Servesindex.jsasindex.js.gzif 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: