
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
Servelet is a simple Node.js module to serve dynamic page modules and static pages. A dynamic page module exports a function that receives a data object that is used to build the dynamic page using JavaScript template literals.
npm install servelet
When servelet is required, it will search all files in the 'views' and 'partials' folders for static and dynamic files. By setting the staticExt and dynamicExt options we tell the module to look for static .htm or .html, and dynamic .js files.
const servelet = require('servelet')({
globalData: { gValue: 123 }
});
Here is an example of a dynamic .js file that uses custom data, global data, and the include method to include a file from the 'views/partials' folder. This file points out the ease of using JavaScript template literals for building dynamic content.
// index.js
// Exports a function that returns a template literal, using properties and methods of the data parameter
module.exports = (data) => `
<!DOCTYPE html>
<html lang="en">
${data.include('head')}
<body>
<p>This is a global value: ${data.global.gValue}.</p>
<p>These are custom values: ${(data.userName) ? `Welcome ${data.userName}` : 'Welcome Guest'}</p>
</body>
`;
Then we can serve the page in a GET request through Express, and feed in our custom values.
const app = require('express')();
app.get('/', (req, res) => {
servelet.serve('index', { userName: 'Michael' }, (html) => {
res.send(html);
});
});
let servelet = require('servelet')(options);
| Key | Description | Default |
|---|---|---|
| root | The root directory if different than the current one | '' |
| views | The name of the views folder | 'views' |
| partials | The name of the partials folder inside the views folder | 'partials' |
| staticExt | The static file extensions separated by a semi-colon | 'html' |
| dynamicExt | The dynamic file extensions separated by a semi-colon | 'js' |
| globalData | The data to send to all dynamic files (accessed by data.global) | '' |
Get the most recent error object, or null
If the module has set up all the dynamic and static pages
Get the content of dynamic or static pages.
app.get('/about', (req, res) => {
const userData = getTheUserData(); // Make use of some data that alters the about page
servelet.serve('about', { user: req.userData }, (html) => {
res.send(html); // Send the compiled page text to the response
});
});
Update the global data object that is sent to all dynamic pages.
// app.js
const servelet = require('servelet')({
globalData: { dynamicId: 342 }
});
servelet.updateGlobalData({ dynamicId: 738 });
servelet.serve('index', (html) => { res.send(html); });
----------
// index.js
module.exports = (data) => `
<p>The ID is: ${data.globalData.dynamicId}</p>
`;
// HTML Response: <p>The ID is: 738</p>
Add an event listener for an event.
servelet.on('error', myErrorCallback)
.on('warning', (w) => { console.log('Warning: ' + w); })
.on('ready', () => { console.log('Servelet is ready.'); });
Remove an event listener for an event.
servelet.off('error', myErrorCallback);
Reload a static page in the servelet cache. This is useful with a GET request to reload one or more static pages that have been altered on the server.
servelet.reloadStaticPage(callback); // Reloads all static pages
servelet.reloadStaticPage('index', callback);
servelet.reloadStaticPage(['index', 'nav'], callback);
These methods are available on the data object that is sent into the dynamic pages.
Include a partial file.
// home.js
module.exports = (data) => `
<p>Include a partial file: ${data.include('message', { name: 'Bob' })}</p>
`;
Include a layout file for the current dynamic page.
// index.js
// Exports a function that returns the result of the layout method call
module.exports = (data) => data.layout('layout:main', `
<p>This is the main portion for the layout file.</p>
`;
----------
// layout.js
// Uses the main property from the index.js file, and includes a partial
module.exports = (data) => `
<body>
${data.main}
${data.include('article')}
</body>
`;
FAQs
Servelet is a simple module to serve dynamic page modules and static pages.
We found that servelet 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.