1.0.0 • Published 12 months ago
express-license v1.0.0
Express License
A simple express middleware to add a license page to your app.
Installation
npm install express-license
Usage
const express = require('express');
const expressLicense = require('express-license');
const app = express();
const license = expressLicense({
appName: 'My App',
additionalDeps:[{
name:'Example Dependency',
licensePath:'https://example.com/license' // This can be any valid URL, including a local file path
}],
additionalHtml: '<p>Some additional HTML appended to the end of the list</p>'
projectNodeModulesPath: 'node_modules' // Optional, defaults to 'node_modules',
routePath: '/licenses', // Optional, defaults to anything before :scope?
autoPopulate:true, // Optional, defaults to true. If false, the middleware will not automatically populate the license list from projectNodeModulesPath
filter: (pkg) => pkg.startsWith('my-app-') // Optional, defaults to null. If provided, only packages that pass the filter will be included in the license list
});
app.get('/licenses/:scope?/:package?', license);
app.listen(3000, () => { console.log('Server started on port 3000'); });
IMPORTANT: The middleware must be mounted at a path that includes
:scope?
and:package?
as parameters. The middleware will not work if mounted at a path that does not include these parameters.
1.0.0
12 months ago