Socket
Socket
Sign inDemoInstall

koa-fp-ts-router

Package Overview
Dependencies
44
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    koa-fp-ts-router

A Koa router middleware built on the top of fp-ts-routing


Version published
Weekly downloads
750
decreased by-32.19%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

koa-fp-ts-router

npm

A Koa router middleware built on the top of fp-ts-routing.

Installation

Note that these packages are peer dependencies of this library, which need to be installed separately.

Using npm

$ npm install koa-fp-ts-router

Using yarn

$ yarn add koa-fp-ts-router

Usage

import { end, lit, str } from 'fp-ts-routing';
import Koa from 'koa';
import { Router } from 'koa-fp-ts-router';

const app = new Koa();

// matches
const root = end; // `/`
const user = lit('users').then(str('id')).then(end); // `/users/:id`

// routes
const router = new Router();

router.get(root, function (ctx) {
  ctx.body = 'Hello, world!';
});

router.get(user, function (ctx) {
  ctx.body = `Hello, ${ctx.params.id}!`;
});

// Use the router middleware
app.use(router.routes());

app.listen(3000);

Keywords

FAQs

Last updated on 24 Aug 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc