![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@kth/basic-html-templates
Advanced tools
Npm: @kth/basic-html-templates
A simple way to get web pages to look somewhat like the kth.se design. The templates are intended to be used in private to semiprivate services.
const express = require("express");
const { templates } = require("@kth/basic-html-templates");
const httpResponse = require("@kth/http-responses");
const app = express();
const started = new Date();
/**
* Index page.
*/
app.get("/", function (request, response) {
httpResponse.ok(request, response, templates.index((title = "Demo App")));
});
/**
* About page. Versions and such.
*/
app.get("/_about", function (request, response) {
const about = {
dockerName: "demo-app",
dockerVersion: "0.0.1_abc123",
jenkinsBuildDate: new Date(),
};
httpResponse.ok(request, response, templates._about(about, started));
});
/**
* Health check route.
*/
app.get("/_monitor", function (request, response) {
httpResponse.ok(
request,
response,
templates._monitor((status = "OK")),
httpResponse.contentTypes.PLAIN_TEXT
);
});
/**
* Crawler access definitions.
*/
app.get("/robots.txt", function (request, response) {
httpResponse.ok(
request,
response,
templates.robotstxt(),
httpResponse.contentTypes.PLAIN_TEXT
);
});
/**
* Generic error page for 5xx response codes.
* Includes application information from /_application.
*/
app.get("/error5xx.html", function (request, response) {
httpResponse.internalServerError(request, response, badGateway.error5xx());
});
/**
* Ignore favicons.
*/
app.get("/favicon.ico", function (request, response) {
httpResponse.noContent(request, response);
});
/**
* Default route, if no other route is matched (404 Not Found).
*/
app.use(function (request, response) {
httpResponse.notFound(request, response, templates.error404());
});
app.listen(80, function () {
console.log("Server started.");
});
{
"name": "demo-app",
"version": "1.0.0",
"description": "Demo app for @kth/basic-html-templates",
"main": "index.js",
"scripts": {
"clean": "rm -r ./node_modules && rm package-lock.json"
},
"author": "paddy@kth.se",
"license": "MIT",
"dependencies": {
"@kth/basic-html-templates": "^1.0.24",
"@kth/http-responses": "^1.0.20",
"express": "^4.17.1"
}
}
Examples:
FAQs
Basic html templates for simple gui:s
We found that @kth/basic-html-templates demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.