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 πŸ™

Β© 2024 – Pkg Stats / Ryan Hefner

@uswitch/koa-core

v2.0.6

Published

🎾 An example project showing the user of all core `@uswitch/koa` libraries

Downloads

6,095

Readme

License type language test style

Overview

Koa Core is a lerna monorepo housing all of uSwitch's koa packages.

This repo acts both as a helper library for wiring together the @uswitch/koa- packages as well as a master list of open sources koa libraries that we depend on.

This means we have a single point of truth for which packages we use and the versions we depend on.

npm install @uswitch/koa-core

Making changes

All of our koa libraries can be found in packages. Any changes should be made to them individually. Commits should ideally be namespaced to the package you're changing.

e.g. [access] Making changes to koa access or [core] Making changes to core.

Or, better yet, with emojis

  • 🎾 for core
  • πŸ‘Œ for access
  • πŸ•΅οΈβ€β™€οΈ for tracer
  • 🚦 for signal
  • 🌑️ for prometheus
  • ⏰ for timeout
  • 🀐 for zipkin

Once changes have been committed, we use lerna to manage the bumping and publishing.

# Make sure you're on a branch because of tag push permissions!!

npm run publish:packages

This will publish the individual libraries followed by performing updating dependencies and generating the documentation for core .

This publishes to both the NPM and Github Packages Registries

Node Version

You can see which version of node koa-core supports by looking in .nvmrc.

Packages

@uswitch packages

| Package | Version | Dependencies | Description | |--|--|--|--| | @uswitch/koa-access | npm | Dependency Status | πŸ‘Œ A Koa middleware for logging JSON access logs consistently, similar to morgan | | @uswitch/koa-cookie | npm | Dependency Status | πŸͺ Koa cookie parser middleware | | @uswitch/koa-prometheus | npm | Dependency Status | 🌑️ A configurable Prometheus data collector with Koa middleware | | @uswitch/koa-signal | npm | Dependency Status | 🚦 Hackable and configurable output rendering for loggers | | @uswitch/koa-timeout | npm | Dependency Status | ⏰ A Koa middleware to handle timeouts correctly | | @uswitch/koa-tracer | npm | Dependency Status | πŸ•΅οΈβ€β™€οΈ A koa.js middleware to add namespaced tracing throughout a requests lifecycle | | @uswitch/koa-zipkin | npm | Dependency Status | πŸ•΅οΈβ€β™€οΈ A koa.js middleware to add Zipkin tracing to requests |

koa packages

| Package | Version | Latest | |--|--|--| | koa | ^2.6.2 | npm | | koa-bodyparser | ^4.2.1 | npm | | koa-compose | ^4.1.0 | npm | | koa-helmet | ^4.0.0 | npm | | koa-requestid | ^2.0.1 | npm | | koa-router | ^7.4.0 | npm | | koa-static | ^5.0.0 | npm |

Library

koa-core can also be used as a boilerplate library to quickly set upo a new Koa server in the same was as the Koa library itself.

Usage

import Koa from '@uswitch/koa-core'

const { app, logger } = new Koa()
app.listen(3000, () => logger.info('Applications started on port 3000'))

Importing dependencies

All of the koa packages we have are available to import in your project via the following;

/* ES6 Import */
import koaLibrary from '@uswitch/koa-core/koa-library'

/* Require */
const koaLibrary = require('@uswitch/koa-core/koa-library')

See packages for a list of available koa libraries through koa-core.

Example

This project also comes with an Example server and some example routes which shows how we use the @uswitch/koa libraries.

npm install
NODE_ENV=development npm run example
NODE_ENV=production npm run example

This will start the server on port http://localhost:3000 and you can try hitting the following routes to see how it works;

curl http://localhost:3000/hello         // 200 string body
curl http://localhost:3000/hello/world

// Test different status codes
curl http://localhost:3000/status/200
curl http://localhost:3000/status/404
curl http://localhost:3000/status/503

// Test tracing errors as they happen
curl http://localhost:3000/error         // Fatal error
curl http://localhost:3000/multi-errors  // Multiple errors non fatal

// Test tracing behaviour
curl http://localhost:3000/trace/150     // Trace either side of 150ms async
curl http://localhost:3000/scope/name    // Trace message to scope NAME

// See all types of koa-signal message
curl http://localhost:3000/signal/all

// See how zipkin tracing works
curl http://locahost:3000/zipkin