Gathering detailed insights and metrics for kth-node-cortina-block
Gathering detailed insights and metrics for kth-node-cortina-block
Gathering detailed insights and metrics for kth-node-cortina-block
Gathering detailed insights and metrics for kth-node-cortina-block
Node.js module for fetching Cortina blocks and optionally cache using Redis.
npm install kth-node-cortina-block
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
268 Commits
20 Watchers
7 Branches
13 Contributors
Updated on Jul 10, 2025
Latest Version
3.1.11
Package Id
kth-node-cortina-block@3.1.11
Unpacked Size
25.00 kB
Size
8.50 kB
File Count
15
NPM Version
6.13.4
Node Version
14.18.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
1
Fetch Cortina blocks and optionally cache using Redis.
1npm install kth-node-cortina-block
A basic NodeJS example is located under /examples/
.
1const cortina = require('kth-node-cortina-block') 2const options = { 3 /* see below for options */ 4} 5 6// somewhere else, usually in an express controller 7 8cortina(options) 9 .then(function (blocks) { 10 // blocks should be used in the layout/view 11 // each block contains HTML, 12 // meaning it should not be escaped in the view 13 14 // blocks is a plain object with the following properties: 15 // title, image, footer, search, language, analytics 16 17 res.render('page', { blocks: blocks }) 18 }) 19 .catch(function (err) { 20 log.error({ err: err }, 'failed to get cortina blocks') 21 22 // either display the error: 23 24 res.render('error', { err: err }) 25 26 // or render page without blocks: 27 28 res.render('page', { blocks: {} }) 29 })
url
is required. Should point to the Cortina block API endpoint.
headers
is optional, pass headers used when fetching Cortina blocks.
debug
is optional, defaults to false
. Enables logging of Redis
errors.
version
is optional, defaults to head
. Change if needed.
language
is optional, defaults to en
.
redisKey
is optional, defaults to CortinaBlock_
. Used as a prefix
for the Redis cache. The language
setting will be appended.
redisExpire
is optional, defaults to 600
(10 minutes). Sets
expiration time in seconds for blocks stored in Redis.
redis
is optional. Set to a Redis client instance when you want to
enable Redis caching. Basically requires an object with get
and
set
functions.
blocks
is optional. It's a plain object containing Cortina block IDs. The
following IDs are default and can be overridden.
title
defaults to 1.260060
.image
defaults to 1.77257
.footer
defaults to 1.202278
.search
defaults to 1.77262
.language
optional object with language block IDs.
en
defaults to 1.77273
.sv
defaults to 1.272446
._analytics
defaults to 1.464751
.gtmAnalytics
defaults to 1.714097
.gtmNoscript
defaults to 1.714099
.You can also add application specific blocks to the options obejct like this:
1blocks: { 2 placesSearch: '1.672888' 3}
Clone this repository, run npm install
followed by npm test
.
Run the npm version <version>
command. See https://docs.npmjs.com/cli/version
for more details.
A helper to modify paths in the blocks HTML for logo, site link/name, and locale link. The resulting blocks object should not be cached (i.e. called this after getting the blocks from the cache/API), because the locale URL changes with the request URL.
1const cortina = require('kth-cortina-block') 2 3function prepare(blocks, req, config) { 4 return cortina.prepare(blocks, { 5 urls: { 6 request: req.url, 7 app: config.full.hostUrl + config.full.proxyPrefixPath.uri, 8 }, 9 // more options below 10 }) 11}
blocks
is required. You get this from the main call to cortina
.config
is required. A plain object with the following properties:
siteName
is optional. Set this to override the site link text.localeText
is optional. Set this to override the locale link text.urls
is required. A plain object with the following properties:
prod
is optional, defaults to //www.kth.se
. The production URL.request
is required. Usually the express req.url
value.app
is optional, defaults to an empty string. Usually the
host URL and the proxy prefix path.siteUrl
is optional, overides default url on the site name only.selectors
is optional, defaults to a plain object with the
following properties:
logo
is optional, defaults to .imageWrapper img
.siteName
is optional, defaults to .siteName a
.localeLink
is optional, defaults to .block.link a.localeLink
.1 2title: "\n\n\n <h1 class=\"bloc…logy</a>\n </h1>\n\n\n", 3megaMenu: "\n\n\n\n <nav class=\"b…\n </nav>\n\n \n\n", 4secondaryMenu: "\n\n\n <div class=\"blo… </ul>\n </div>\n\n\n", 5image: "\n\n\n <figure class=\"… \n </figure>\n\n\n", 6footer: "\n\n\n <div class=\"blo… </div>\n </div>\n\n\n", 7search: "\n\n\n <div class=\"blo…aded=!0);</script>\n\n\n", 8language: "\n\n\n <a class=\"block…KTH på svenska</a>\n\n\n", 9analytics: "\n\n\n \n <!-- conte…r\n};</script>\n \n\n\n", 10gtmAnalytics: "\n\n\n <!-- Begin JavaS…entId-1_714097 -->\n\n\n", 11gtmNoscript: "\n\n\n <!-- Begin HTML …entId-1_714099 -->\n\n\n"
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
11 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 9
Reason
Found 1/11 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More