npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@kth/cortina-block

v7.2.1

Published

Node.js module for fetching Cortina blocks and optionally cache using Redis.

Readme

@kth/cortina-block

This package exposes an express middleware, that fetches som predefined blocks from Cortina CMS.
The blocks are then stored in res.locals.blocks, for use in Handlebars or similar.
Blocks can optionaly be cached in Redis.

Installation

npm install @kth/cortina-block

Usage

import { cortinaMiddleware } from '@kth/cortina-block'

apply middleware

server.use(
  '',
  cortinaMiddleware({
    blockApiUrl,
    blocksConfig,
    redisConfig,
  })
)

Default blocks that will be fetched can be found in config.ts. If you want to fetch other blocks or override the id of the default blocks, provide the optional blocksConfig.

Options

  • blockApiUrl is required. Should point to the Cortina block API endpoint.
  • memoryCache is optional. Defaults to "true" unless redisConfig is provided. Stores blocks in memory for 10 minutes.
  • redisConfig is optional. An object parsed from kth-node-configuration, containing host and port. If provided, blocks will be cached in redis.
  • redisKey is optional. Use unique keys of multiple apps share the same redis.
  • supportedLanguages is optional. If app only uses a subset of the supported languages. Default is ['sv', 'en'].
  • blocksConfig is optional. It's a plain object containing Cortina block IDs. It can be used both to replace existing id's, and to add new blocks.
    const blocksConfig = {
      footer: '1.123456', // Replaces existing block
      studentMegaMenu: '1.1066510', // Adds a new block
    }

Changes after style 10

Blocks title, image and secondaryMenu are no longer used by the apps.
That also means that a bunch of config is no longer needed.

Upgrade from @kth/cortina-block 6

  • Config headers is no longer used.
  • Config localeText is no longer used.
  • Config resourceUrl is no longer used.
  • Config siteName is no longer used.
  • Config useStyle10 is no longer used.

Upgrade from wrapper in @kth/kth-node-web-common

  • Config addBlocks has been renamed to blocksConfig.
  • Config blockUrl has been renamed to blockApiUrl.
  • Config blockVersion is no longer used.
  • Config globalLink is no longer used.
  • Config hostUrl is no longer used.
  • Config proxyPrefixPath is no longer used.
  • Config useStyle10 is no longer used.

Returned blocks

All fetched blocks will be avalible on res.locals.blocks.

{
  megaMenu: "\n\n\n\n  <nav class=\"b…\n     </nav>\n\n  \n\n",
  footer: "\n\n\n  <div class=\"blo…  </div>\n  </div>\n\n\n",
  search: "\n\n\n  <div class=\"blo…aded=!0);</script>\n\n\n",
  etc..
}