Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@untool/express

Package Overview
Dependencies
Maintainers
3
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@untool/express - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

<a name="0.5.0"></a>
# [0.5.0](https://github.com/untool/untool/compare/v0.4.3...v0.5.0) (2018-05-07)
### Features
* **express:** add 404 middleware to renderer ([04aa35b](https://github.com/untool/untool/commit/04aa35b))
<a name="0.4.3"></a>

@@ -8,0 +19,0 @@ ## [0.4.3](https://github.com/untool/untool/compare/v0.4.2...v0.4.3) (2018-04-24)

4

lib/run.js

@@ -41,3 +41,3 @@ const { readFileSync: readFile } = require('fs');

module.exports = (app, config, inspectServer, logInfo, logError) => {
module.exports = (app, config, inspect, logInfo, logError) => {
const { ip = '0.0.0.0', port, basePath, https } = config;

@@ -51,3 +51,3 @@ const server = createServer(app, https);

} else {
inspectServer(server);
inspect(server);
logInfo(

@@ -54,0 +54,0 @@ 'server listening at %s',

@@ -7,5 +7,5 @@ const express = require('express');

module.exports = (options, config, initializeServer, finalizeServer) => {
module.exports = (method, options, config, initialize, finalize) => {
const app = express();
initializeServer(app, 'serve');
initialize(app, method);
app.use(rewriteMiddleware(options, config));

@@ -17,3 +17,6 @@ app.use(helmet());

setHeaders: function(res, filePath) {
if (res.locals.noCache || mime.getType(filePath) === 'text/html') {
if (
(res && res.locals && res.locals.noCache) ||
mime.getType(filePath) === 'text/html'
) {
helmet.noCache()(null, res, function() {});

@@ -26,4 +29,4 @@ }

app.use(helmet.noCache());
finalizeServer(app, 'serve');
finalize(app, method);
return app;
};

@@ -6,6 +6,7 @@ const EventEmitter = require('events');

module.exports = (options, config, initializeServer, finalizeServer) => {
module.exports = (method, options, config, initialize, finalize) => {
const app = new Router();
initializeServer(app, 'static');
finalizeServer(app, 'static');
initialize(app, method);
finalize(app, method);
app.use((req, res) => res.status(404).end());
return options => {

@@ -12,0 +13,0 @@ if (typeof options === 'string') {

@@ -1,2 +0,5 @@

const { sync: { sequence } } = require('mixinable');
const {
sync: { sequence, override: overrideSync },
async: { override: overrideAsync },
} = require('mixinable');

@@ -8,31 +11,29 @@ const { Mixin } = require('@untool/core');

class ExpressMixin extends Mixin {
constructor(...args) {
super(...args);
this.options = {};
create(method) {
const create = require(method === 'static'
? './lib/static'
: './lib/serve');
const { options, config, initializeServer, finalizeServer } = this;
return create(method, options, config, initializeServer, finalizeServer);
}
create(method, options) {
const create = require(`./lib/${method}`);
const { config, initializeServer, finalizeServer } = this;
return create(options, config, initializeServer, finalizeServer);
}
run(method, options) {
run(method) {
const run = require('./lib/run');
const { config, inspectServer, logInfo, logError } = this;
const app = this.create(method, options);
const app = this.create(method);
return run(app, config, inspectServer, logInfo, logError);
}
runServer(options) {
return this.run('serve', options);
runServer() {
return this.run('serve');
}
runDevServer(options) {
return this.run('develop', options);
runDevServer() {
return this.run('develop');
}
createServer(options) {
return this.create('serve', options);
createServer() {
return this.create('serve');
}
createDevServer(options) {
return this.create('develop', options);
createDevServer() {
return this.create('develop');
}
createRenderer(options) {
return this.create('static', options);
createRenderer() {
return this.create('static');
}

@@ -55,7 +56,2 @@ renderLocations() {

}
getAssetPath(filePath) {
const { config: { assetPath } } = this;
const { resolveRelative } = uri;
return resolveRelative(assetPath, filePath);
}
initializeServer(app, mode) {

@@ -77,3 +73,3 @@ const { compress } = this.config;

alias: 'p',
default: true,
default: false,
describe: 'Enable production mode',

@@ -95,5 +91,8 @@ type: 'boolean',

},
handler: argv => this.runServer(argv),
handler: () => this.runServer(),
});
}
handleArguments(argv) {
this.options = { ...this.options, ...argv };
}
}

@@ -105,4 +104,7 @@

inspectServer: sequence,
runServer: overrideSync,
runDevServer: overrideSync,
renderLocations: overrideAsync,
};
module.exports = ExpressMixin;
{
"name": "@untool/express",
"version": "0.4.3",
"version": "0.5.0",
"description": "untool express mixin",

@@ -26,3 +26,4 @@ "keywords": [

"dependencies": {
"@untool/core": "^0.4.3",
"@untool/core": "^0.5.0",
"@untool/yargs": "^0.5.0",
"compression": "^1.7.2",

@@ -29,0 +30,0 @@ "directory-index": "^0.1.0",

@@ -77,2 +77,14 @@ # `@untool/express`

### `runServer(options)` ([override](https://github.com/untool/mixinable/blob/master/README.md#defineoverride))
If you want to programmatically start a production ready Express server set up using `@untool/express`' [config](https://github.com/untool/untool/blob/master/packages/express/README.md#settings), you can use this utility mixin method that accepts the same options as the CLI [`serve`](https://github.com/untool/untool/blob/master/packages/express/README.md#arguments) method.
### `runDevServer(options)` ([override](https://github.com/untool/mixinable/blob/master/README.md#defineoverride))
To start a development mode Express server programmatically, you can use this utility mixin method. It uses a [`static`](https://github.com/untool/untool/blob/master/packages/express/README.md#-s----static) option and `@untool/express`' [settings](https://github.com/untool/untool/blob/master/packages/express/README.md#settings) for its configuration.
### `renderLocations()` ([override](https://github.com/untool/mixinable/blob/master/README.md#defineoverride))
With this method you can render HTML pages for all configured [`locations`](https://github.com/untool/untool/blob/master/packages/express/README.md#locations) using a simulated Express server configured using `@untool/express`' [settings](https://github.com/untool/untool/blob/master/packages/express/README.md#settings). This method returns a `Promise` resolving to a hash containing the rendered paths.
## Settings

@@ -79,0 +91,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc