
Security News
Static vs. Runtime Reachability: Insights from Latio’s On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
express-package-json
Advanced tools
express middleware to expose the contents of package.json to the view engine via res.locals
Simple express function to expose the contents
of a package.json
file to the view engine. This is useful for displaying
the software version on a web page without having to update the page every
time the version changes in package.json
.
npm install --save express-package-json
Parameters:
pathToPackageJson
- path to the package.json
file. String. Defaults to ./package.json
.propertyName
- name of property to add to res.locals
. String. Defaults to pkg
.Returns:
(req, res, next)
.res.locals[variableName]
is set to a JavaScript object containing the parsed package.json
.next()
is called when complete.app.js
:
"use strict";
var express = require('express');
var expressPackageJson = require('express-package-json');
var app = express();
app.set('view engine', 'hbs');
app.use(expressPackageJson(path.join(__dirname, 'package.json')));
app.get('/', function (req, res) {
res.render('index');
});
views/index.hbs
:
{{pkg.name}} v{{pkg.version}}
npm test
See LICENSE.md
FAQs
express middleware to expose the contents of package.json to the view engine via res.locals
The npm package express-package-json receives a total of 28 weekly downloads. As such, express-package-json popularity was classified as not popular.
We found that express-package-json 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
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.