Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@scalvert/ember-setup-middleware-reporter
Advanced tools
Utilities to setup server middleware for Ember apps and addons
Utilities to setup server middleware for Ember apps and addons.
Ember apps and addons include a mechanism to setup server middleware in order to inject additional work into the ember-cli pipeline. The process of setting up server middleware is repetitive, so this package provides a few utilities to make it easier.
npm install @scalvert/ember-setup-middleware-reporter --save-dev
This package's functions are provided in small, composable pieces. Each allow you to succesively build up a middleware pipeline.
In most cases, using the setupMiddlewareHooks
function will be the easiest way to get started. By providing only the name
option, this value will be used for both the url
and reportDir
options. This means that any output generated as the result of this middleware running will be stored in the reportDir
directory.
'use strict';
const { setupMiddlewareHooks } = require('ember-setup-middleware-reporter');
module.exports = {
name: require('./package').name,
...setupMiddlewareHooks({
name: 'deprecation-workflow',
}),
};
You can additionally provide the following options:
'use strict';
const { setupMiddlewareHooks } = require('ember-setup-middleware-reporter');
module.exports = {
name: require('./package').name,
...setupMiddlewareHooks({
name: 'deprecation-workflow',
urlPath: 'deprecations',
reportDir: 'deprecation-reports',
}),
This will create a middleware that will listen for requests to the deprecations
path. Any requests to this path will be passed through to the deprecation-workflow
middleware. The output of this middleware will be stored in the deprecation-reports
directory.
It's also possible to provide your own handlers to the middleware. This is useful if you want to add additional functionality not provided out-of-the-box by this package, such as posting data to an API endpoint.
'use strict';
const { setupMiddlewareHooks } = require('ember-setup-middleware-reporter');
module.exports = {
name: require('./package').name,
...setupMiddlewareHooks({
name: 'deprecation-workflow',
buildMiddleware: (app, options) => {
// build and return an array of handlers
return [
async (req: Request, res: Response) => {
await fetch('http://some-domain/some-reporting-endpoint', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(req.body),
});
res.send({
success: true,
});
},
]
}
}),
Sets up the middleware hooks that are required by the ember-cli addon. The return value of this function should be merged into the object returned from an ember app or addon's index.js file.
A utility function that sets up posting to a specific middleware endpoint for the ember-cli addon.
Builds an array of default handlers that can be leveraged out of the box by the ember-cli addon. The default handlers include one that writes the response to a file.
Builds the root directory for the middleware report.
Builds the URL for the middleware report.
Builds the report directory for the middleware report.
Sets up the middleware hooks that are required by the ember-cli addon. The return value of this function should be merged into the object returned from an ember app or addon's index.js file.
Kind: global function Returns: An object containing a serverMiddleware and testemMiddleware functions that setup the middleware.
Param | Description |
---|---|
options | An options object that contains necessary information for the middleware to run. |
options.name | The name of the middleware. |
[options.urlPath] | The url that the middleware should respond to. If url is not provided, options.name will be used. |
[options.reportDir] | The directory where the reports should be written to. If reportDir is not provided, options.name will be used. |
[options.buildHandlers] | A function that takes the options object and returns an array of handlers. |
Example
'use strict';
const { setupMiddlewareHooks } = require('ember-setup-middleware-reporter');
module.exports = {
name: require('./package').name,
...setupMiddlewareHooks({
name: 'deprecations',
reportDir: 'deprecation-reports',
}),
};
A utility function that sets up posting to a specific middleware endpoint for the ember-cli addon.
Kind: global function Returns: An object containing a serverMiddleware and testemMiddleware functions that setup the middleware.
Param | Description |
---|---|
app | The express application. |
options | An options object that contains necessary information for the middleware to run. |
options.name | The name of the middleware. |
[options.urlPath] | The url that the middleware should respond to. If url is not provided, options.name will be used. |
[options.reportDir] | The directory where the reports should be written to. If reportDir is not provided, options.name will be used. |
[options.buildHandlers] | A function that takes the options object and returns an array of handlers. |
Builds an array of default handlers that can be leveraged out of the box by the ember-cli addon. The default handlers include one that writes the response to a file.
Kind: global function Returns: An array of default handlers.
Param | Description |
---|---|
app | The express application. |
options | An options object that contains necessary information for the middleware to run. |
options.name | The name of the middleware. |
[options.urlPath] | The url that the middleware should respond to. If url is not provided, options.name will be used. |
[options.reportDir] | The directory where the reports should be written to. If reportDir is not provided, options.name will be used. |
Builds the root directory for the middleware report.
Kind: global function Returns: A string containing the root directory for the middleware report.
Param | Description |
---|---|
options | An options object that contains necessary information for the middleware to run. |
options.name | The name of the middleware. |
[options.urlPath] | The url that the middleware should respond to. If url is not provided, options.name will be used. |
[options.reportDir] | The directory where the reports should be written to. If reportDir is not provided, options.name will be used. |
Builds the URL for the middleware report.
Kind: global function Returns: A string containing the url for the middleware report.
Param | Description |
---|---|
options | An options object that contains necessary information for the middleware to run. |
options.name | The name of the middleware. |
[options.urlPath] | The url that the middleware should respond to. If url is not provided, options.name will be used. |
[options.reportDir] | The directory where the reports should be written to. If reportDir is not provided, options.name will be used. |
Builds the report directory for the middleware report.
Kind: global function Returns: A string containing the report directory for the middleware report.
Param | Description |
---|---|
options | An options object that contains necessary information for the middleware to run. |
options.name | The name of the middleware. |
[options.urlPath] | The url that the middleware should respond to. If url is not provided, options.name will be used. |
[options.reportDir] | The directory where the reports should be written to. If reportDir is not provided, options.name will be used. |
FAQs
Utilities to setup server middleware for Ember apps and addons
We found that @scalvert/ember-setup-middleware-reporter 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.