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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@navikt/leesah-game

v2.1.2

Published

JavaScript biblotek for å spille Leesah!

Readme

🇬🇧💂🍪☕️ You will find the english version down below.

Leesah JavaScript Norsk

Leesah-game er et hendelsedrevet applikasjonsutviklingspill som utfordrer spillerne til å bygge en hendelsedrevet applikasjon. Applikasjonen håndterer forskjellige typer oppgaver som den mottar som hendelser på en Kafka-basert hendelsestrøm. Oppgavene varierer fra veldig enkle til mer komplekse.

JavaScript-bibliotek for å spille Leesah!

Kom i gang

Det finnes to versjoner av Leesah-game! En hvor man lager en applikasjon som kjører på Nais, og en hvor man spiller lokalt direkte fra terminalen. Dette biblioteket kan brukes i begge versjoner, men denne dokumentasjonen dekker kun lokal spilling.

Sett opp lokalt miljø

For å kunne spille Leesah-game med JavaScript, anbefaler vi å ha Node versjon 22+ og NPM versjon 10+ installert.

Start med å opprette en katalog leesah-game.

For macOS/Linux

mkdir leesah-game
cd leesah-game
npm init -y

Installer biblioteket

Det er kun en avhengighet du trenger, og det er biblioteket leesah-game

npm install @navikt/leesah-game

Hent Kafkasertifikat

Sertifikater for å koble seg på Kafka ligger tilgjengelig på leesah.io/certs, passord får du utdelt.

På macOS/linux kan du også bruke kommandoen nedenfor:

curl -u leesah-game:<se presentasjon> -o leesah-certs.zip https://leesah.io/certs && unzip leesah-certs.zip

Du vil nå ende opp med filen leesah-certs.yaml i leesah-game-katalogen du lagde tidligere.

Eksempelkode

For å gjøre det enklere å komme i gang har vi et fungerende eksempel som svarer på spørsmålet om lagregistrering med et navn og en farge (hexkode). Opprett filen index.mjs og lim inn koden nedenfor. OBS: husk at filtypen må være *.mjs!

/**
 * 1. Hent ned sertifikater, og sikre deg at de ligger i filen leesah-certs.yaml
 * 2. Sett 'LAGNAVN' til ditt valgte lagnavn
 * 3. Sett 'HEXKODE' til din valgte farge
*/

import { lastKafka, publiserSvar, spørsmålFraHendelse } from "@navikt/leesah-game";

const ignorerteKategorier = [
    // "lagregistrering"
]

const LAGNAVN = "BYTT MEG";
const HEXKODE = "BYTT MEG";

async function kjør() {
    try {
        const { consumer } = await lastKafka(LAGNAVN, ignorerteKategorier)

        await consumer.run({
            eachMessage: async ({ message: hendelse }) => {
                const spørsmål = spørsmålFraHendelse(hendelse)
                if (spørsmål) {
                    // ### FRA HER SPILLES LEESAH! ###
                    if (spørsmål.kategori === 'lagregistrering') {
                        await publiserSvar(spørsmål, HEXKODE)
                    } else if (spørsmål.kategori === 'ping-pong') {
                        // Fortsett spillet nedover
                    }
                }
            }
        })
    } catch (e) {
        console.error(e)
    }
}

void kjør()

Kjør koden

Kjør koden din med:

node index.mjs

Leesah JavaScript English

Leesah-game is an event-driven application development game that challenges players to build an event-driven application. The application handles different types of tasks that it receives as events on a Kafka-based event stream. The tasks vary from very simple to more complex.

This is the JavaScript library to play Leesah!

Getting started

There are two versions of the the Leesah game! On is for local play, directly in the terminal. While the other is running on the Nais platform, and you learn how to be a developer in Nav and use Nais. This library is used by both versions, but the following documentation is just for local play.

Setting up local environment

To be able to use JavaScript to play Leesah-game, we recommend that you have Node version 22+ and NPM version 10+ installed.

Start by creating a folder with name leesah-game.

For macOS/Linux

mkdir leesah-game
cd leesah-game
npm init -y

Install the library

There is only one dependency you need to play, the library leesah-game

npm install @navikt/leesah-game

Fetch Kafka certificates

You need some certificates to connect to the Kafka cluster, which is available at leesah.io/certs. The username is always leesah-game, and the password will be distributed.

On macOS/Linux you can also use the one-liner below:

curl -u leesah-game:<see presentation> -o leesah-certs.zip https://leesah.io/certs && unzip leesah-certs.zip

You will now end up with leesah-certs.yaml in the leesah-game directory you made earlier.

Example code

To make it easy to start we have made a working example that answer the first question, team-registration, with a dummy name and color. All you need to do is update TEAM_NAME and HEX_CODE, and your ready to compete!

Create a file named index.mjs and paste the code below. OBS: the file has to be of type *.mjs!

/**
 * 1. Download the Kafka certificate, and make sure that you have a file called leesah-certs.yaml in the same directory as this file
 * 2. Set your own 'TEAM_NAME'
 * 3. Set your own 'HEX_CODE' as team color
*/

import { loadKafka, publishAnswer, questionFromEvent } from "@navikt/leesah-game";

const ignoredCategories = [
    // "team-registration"
]

const TEAM_NAME = "CHANGE ME";
const HEX_CODE = "CHANGE ME";

async function run() {
    try {
        const { consumer } = await loadKafka(TEAM_NAME, ignoredCategories)

        await consumer.run({
            eachMessage: async ({ message: event }) => {
                const question = questionFromEvent(event)
                if (question) {
                    // ### FROM THIS POINT YOU PLAY LEESAH! ###
                    if (question.category === 'team-registration') {
                        await publishAnswer(question, HEX_CODE)
                    } else if (question.category === 'ping-pong') {
                        // Continue the game below
                    }
                }
            }
        })
    } catch (e) {
        console.error(e)
    }
}

void run()

Run your code with

node index.mjs