Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
ft-next-express
Advanced tools
next-express [![Build Status](https://travis-ci.org/Financial-Times/next-express.svg?branch=master)](https://travis-ci.org/Financial-Times/next-express) ============
Slightly enhanced Express.
npm install -S ft-next-express
Comes with:-
Handlebars (with added support for loading partials from bower_components
)
Origami Image Service integration
Sensible error handling (configurable via environment variables)
Full Next Flags integration
Next Metrics integration
fetch
api)express.metrics
Anti-search engine GET /robots.txt
(possibly might need to change in the future)
Symbol & (Isomorphic) Fetch polyfills
Exposes everything in the app's ./public
folder via ./{{name-of-app}}
(only in non-production environments, please use next-assets or hashed-assets in production)
Exposes app name via __name
to templates and in a data-next-app
attribute on the html tag in templates
Adds a /{{name-of-app}}/__about
endpoint, which exposes information about the current version of the application running
By default the application's templates are outputted unchanged, but ft-next-express provides 2 inheritable layouts
Exposes express.Router
Provides NODE_ENV
to templates via __environment
__isProduction
is true
if NODE_ENV
equals PRODUCTION
(exposed as data-next-is-production
on the <html>
tag in templates)
__version
is set to the same value as that used by next-build-tools/about (exposed as data-next-version
on the <html>
tag in templates)
Provides a range of handlebars helpers, including template inheritance and layouts
instruments fetch
to send data about server-to-server requests to graphite. See main.js for a list of services already instrumented. To add more services extend the list or, for services specific to a particular app, pass in a 'serviceDependencies' option (see examples below)
npm install --save ft-next-express
When using the default layout there is also a hard dependency on some bower components. To install them (and add to your app's bower.json) run the following on your local machine. It's assumed you will have bower installed globally.
$ ./path/to/ft-next-express/bower-install.sh
main.js
var express = require('ft-next-express');
var app = express({
// Optional. If name is not provided, next-express will try to infer it from package.json
name: "xian",
// Optional
helpers: {
uppercase: function(options) {
return options.fn(this).toUpperCase();
}
},
serviceDependencies: {
// service dependencies should be listed with a regex that matches urls for that service.
// regexes can be whatever you like so it's possible to treat paths within a given service
// as separate services
'youtube': /https?:\/\/youtube\.com/
},
// the following default to true but should normally be set to false if your app is an api
withFlags: false, // disable feature flag middleware
withHandlebars: false // disable handlebars middleware
withBackendAuthentication: false // disable authentication which only allows requests in via fastly
});
app.get('/', function(req, res, next) {
res.render('main', {
title: "FT",
image: "https://avatars0.githubusercontent.com/u/3502508?v=3",
date: new Date(),
text : "<p>This wont be shown</p><p>This will be shown</p><p>This wont be shown</p>"
});
});
app.listen(process.env.PORT, function() {
console.log("Listening on " + process.env.PORT);
});
views/main.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{title}}</title>
<!-- this will be output as <link rel="stylesheet" href="/xian/main.css"> -->
<link rel="stylesheet" href="/{{__name}}/main.css">
</head>
<body>
<h1>{{title}}</h1>
{{#uppercase}}this text will be uppercase{{/uppercase}}
<h2>An image resized to 150px wide</h2>
<img src="{{#resize 150}}{{image}}{{/resize}}" />
{{#flags.myFlag}}
The 'myFlag' flag is switched on
{{/flags.myFlag}}
<time data-o-component="o-date" class="o-date" datetime="{{#dateformat}}{{date}}{{/dateformat}}">
{{#dateformat "dddd, d mmmm, yyyy"}}{{date}}{{/dateformat}}
</time>
{{paragraphs text start=1 end=2}}
{{#removeImageTags}}
Image<img src="someimage.jpg" alt="This wont be shown"/>EndImage
{{/removeImageTags}}
</body>
</html>
If you’re using flags and testing with mocha, you’ll need to expose listen in your app:
module.exports.listen = app.listen(port);
And in your tests, add this:
before(function() {
return app.listen;
});
This’ll make sure your tests wait for flags to be ready.
FAQs
next-express [![Circle CI](https://circleci.com/gh/Financial-Times/next-express/tree/master.svg?style=svg)](https://circleci.com/gh/Financial-Times/next-express/tree/master) ============
The npm package ft-next-express receives a total of 3 weekly downloads. As such, ft-next-express popularity was classified as not popular.
We found that ft-next-express 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.