Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
express-ftwebservice
Advanced tools
Install FT Web Standard web service descriptions in an Express.js application
Installs routes for /__gtg
, /__health
, /__about
and /__error
.
Conforms to the FT Good to go standard, emitting a 200 OK
response if the application should be considered healthy, and 503 Service Unavailable
if it should not. This is intended to be used to make routing decisions.
Always returns 200 OK
unless a goodToGoTest
option is specified.
Conforms to the FT Healthcheck standard, returning JSON data summarising the current health status of the application.
Always returns a 'blank' healthcheck response (ie a valid healthcheck response with no checks) unless the healthCheck
option is specified.
Conforms to the (at time of writing, draft) FT About endpoint standard, returning JSON data describing the application, and providing links to all relevant dashboards and support documentation resources.
The information emitted by the about endpoint is populated from the about
option. The _hostname
and appVersion
fields will be populated automatically if not present in the data passed in through the about
option.
This endpoint simply throws a JavaScript error, and makes no attempt to handle it. This is useful for testing the way that your application handles runtime errors in prod, both in terms of reporting them (eg to a logging or aggregation tool) and presenting an appropriate UI to the end user.
Basic example:
var path = require('path');
var ftwebservice = require('express-ftwebservice');
var express = require('express');
var app = express();
ftwebservice(app, {
manifestPath: path.join(__dirname, 'package.json')
about: {
"schemaVersion": 1,
"name": "build-service",
"purpose": "Front end build process as a service. Fetches specified Origami components from git, runs Origami build process, and returns the resulting CSS or JS bundle over HTTP.",
"audience": "public",
"primaryUrl": "https://origami-build.ft.com",
"serviceTier": "gold"
}
});
Example with Good To Go logic and Healthcheck logic:
ftwebservice(app, {
manifestPath: path.join(__dirname, 'package.json')
about: {
"schemaVersion": 1,
"name": "build-service",
"purpose": "Front end build process as a service. Fetches specified Origami components from git, runs Origami build process, and returns the resulting CSS or JS bundle over HTTP.",
"audience": "public",
"primaryUrl": "https://origami-build.ft.com",
"serviceTier": "gold"
}
goodToGoTest: function() {
return new Promise(function(resolve, reject) {
resolve(isApplicationHappy());
});
},
healthCheck: function() {
// You might have several async checks that you need to perform or
// collect the results from, this is a really simplistic example
return new Promise(function(resolve, reject) {
resolve([
{
name: "Database TCP connectivity",
ok: false,
severity: 2,
businessImpact: "Article pages will not be available",
technicalSummary: "The database is dead",
panicGuide: "Check the health status of the database at host <database host>",
checkOutput: "tcp connect failed after 10 seconds on destination port 3306 - destination unreachable",
lastUpdated: new Date().toISOString()
}
]);
});
}
});
Option | Description |
---|---|
manifestPath | (Optional) Path to the app's package.json file. This will be used to populate the appVersion and dateDeployed properties of the /__about endpoint, if they are not specified explicitly. |
about | (Optional) Object containing standard runbook propeties as defined in the FT Runbook standard |
goodToGoTest | (Optional) A function that can be used to indicate the good to go status of the service, the function should return a Promise resolved with true to indicate a positive good to go status, and false to indicate a negative good to go status. |
healthCheck | (Optional) A function that can be used to generate structured healthcheck information, the function should return a Promise resolved with an array of healthcheck objects. |
routes | (Optional) An array of routes to install. Possible values are health , gtg , about and error . Defaults to ["health", "gtg", "about"] |
MIT
FAQs
Install FT Web Standard web service descriptions in an Express.js application
The npm package express-ftwebservice receives a total of 0 weekly downloads. As such, express-ftwebservice popularity was classified as not popular.
We found that express-ftwebservice demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.