
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@commander-lol/koa-mustache
Advanced tools
Mustache template rendering for Koa 2+
npm i --save @commander-lol/koa-mustache
const path = require('path')
const Koa = require('koa')
const mustache = require('@commander-lol/koa-mustache')
const app = new Koa()
const templatePath = path.join(__dirname, 'views')
app.use(mustache(templatePath))
// Respond to all requests with the template at `./views/index.mustache`
app.use(async ctx => {
await ctx.render('index')
})
const mustache = require('@commander-lol/koa-middleware')const middleware = mustache(myTemplateDirectoryPath, myOpts)app.use(middleware)ctx.render function has been added to all subsequent middleware (including routes when using routers).
await this function to render the specified params to the ctx body. If the template is not found, the status
will be set to 404. If the template path is not a regular file, the status will be set to 500.These are the types that you need to be aware of to use koa-mustache. The export of this module
(the object imported by require('@commander-lol/koa-mustache')) is of the type ConfigureMiddleware.
Configuration Options
type Options = {
debug(...args: any[]): void,
useCache?: boolean,
extension?: string,
partials?: string,
}
Module Export
type ConfigureMiddleware = (root: string, opts?: Options): KoaMiddleware
Render Function
type RenderTemplate = (template: string, data: Object): Promise<void>
| name | type | default | notes |
|---|---|---|---|
| debug | Function | noop | Will receive debug information. Typically printed with console.log, but could be sent elsewhere |
| useCache | boolean | if NODE_ENV is equal to production, true otherwise false | Will load templates on server boot, and exclusively use the in-memory cache for retrieving templates to render. Partials will always be loaded on boot |
| extension | string | .mustache | The file extension to use when loading templates (Must include leading dot) |
| partials | string | partials | The path, relative to the middleware root, where partials are located |
FAQs
Mustache rendering for Koa 2+
We found that @commander-lol/koa-mustache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.