
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Aggregates JavaScript, CSS and any other text files for serving them to browsers with express. Supports wrapping and postprocessing outputs. A mirror can contain files, plain source code or other mirrors.
var mirror = require('mirror');
// Mirror guesses the MIME type based on the first file's extension.
var styles = new mirror([
__dirname + '/assets/main.css',
__dirname + '/assets/layout.css'
]);
// Proving direct source input requires specifying the MIME type manually.
var configuration = new mirror([
// Mirror automatically inserts line breaks and semicolons before/after
// each item in a "js" type mirror.
mirror('var basepath = "/"'),
mirror('var config = ' + JSON.stringify(config)),
// You can add functions to the mirror. They will be called on each request.
mirror(function(callback, req, res) {
callback(null, 'var url = ' + JSON.stringify(req.url));
})
], {
type: 'js',
maxAge: 60 // Only cache configuration file for 60 seconds.
});
// Store the array of files and remove or add files on-the-fly.
var files = [
require.resolve('underscore'),
require.resolve('backbone'),
require.resolve('mymodule/client.js'),
// Add other mirrors
configuration
];
// Add the mirrors to your express server.
app.get('/assets/style.css', styles);
app.get('/assets/configuration.json', configuration);
app.get('/assets/scripts.js', new mirror(files, { minify: true }));
NOTE: Mirror loads the requested files from disk for every request. It is meant to run behind a reverse proxy that caches. You can control the cache time with maxAge
(in seconds) in the options hash.
FAQs
Unknown package
We found that mirror demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.