# siso

> siso is a routing utility allowing to map a path to a value

Latest version **9.0.1** (published 2026-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install siso
pnpm add siso
yarn add siso
bun add siso
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 9.0.1 |
| Published | 2026-04-08 |
| First published | 2016-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=24.14.0 |
| Dependencies | 2 |
| Unpacked size | 101.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Nicolas Froidure |
| Maintainers | nfroidure |
| Keywords | path, router, value |

## Links

- npm: https://www.npmjs.com/package/siso
- Repository: https://github.com/nfroidure/siso
- Homepage: https://github.com/nfroidure/siso#readme
- Issues: https://github.com/nfroidure/siso/issues
- Funding: https://github.com/sponsors/nfroidure
- npm.io page: https://npm.io/package/siso

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.4.3
- [yerror](https://npm.io/package/yerror.md) ^11.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 9.0.1 (latest) — 2026-04-08
- 9.0.0 — 2026-04-07
- 8.0.0 — 2026-03-27
- 7.0.0 — 2025-01-29
- 6.0.2 — 2024-02-24
- 6.0.1 — 2023-08-16
- 6.0.0 — 2023-08-12
- 5.0.2 — 2023-01-05
- 5.0.1 — 2022-09-01
- 5.0.0 — 2022-06-06
- 4.1.0 — 2022-06-06
- 4.0.5 — 2022-05-25
- 4.0.4 — 2021-04-09
- 4.0.3 — 2020-09-14
- 4.0.2 — 2020-05-17
- … 20 more at https://npm.io/package/siso/versions

## README

[//]: # ( )
[//]: # (This file is automatically generated by a `metapak`)
[//]: # (module. Do not change it  except between the)
[//]: # (`content:start/end` flags, your changes would)
[//]: # (be overridden.)
[//]: # ( )
# siso
> siso is a routing utility allowing to map a path to a value

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/siso/blob/main/LICENSE)
[![Coverage Status](https://coveralls.io/repos/github/nfroidure/siso/badge.svg?branch=main)](https://coveralls.io/github/nfroidure/siso?branch=main)


[//]: # (::contents:start)

`siso` stands for "Shit In Shit Out". It allows to build routers without
embedding a framework and falling into the gorilla banana problem ;).

It also matches the French "ciseau" word pronunciation which means "chisel".

Siso, works only for fixed length paths nodes which makes it fast. It also do no
define the values validation and just takes a function returning a boolean to
test the value.

If you plan to use it with OpenAPI, you have to know that the parameters
definitions do not match the whole OpenAPI variants yet. It can only be used
with the `simple` style variant and unique primitive values.

## Usage

The `siso` concept is pretty simple. You associate paths patterns to values,
then you pass a path in and get values and parameters out. And that's it, fair
enough ;).

`siso` does not decide which separator is used for your paths so that you can
use it for any routing concern.

```js
import { Siso } from siso;

const siso = new Siso();

// Associate the '/v1/users' path to the 'user.list' value
siso.register([
  'v1',
  'users',
], 'user.list');

// Associate the '/v1/users/:id' path to the 'user.detail' value
siso.register([
  'v1',
  'users',
  {
    name: 'id',
    type: 'number',
    validate: (str) => /^[0-9]+$/.test(str),
  },
], 'user.detail');

// Find a value for /v1/users/12
siso.find(['v1', 'users', '12']);
// Returns: ['user.detail', {id: 12}]
```

Note that you can provide any value for a given path. It may be a function, an
array, an object or a string depending of your needs.

Despite its simplicity, `siso` is very opinionated since it won't allow you to
define several values for the same path pattern and will throw if such situation
happens.

It is very different from the kind of routing systems you probably used before.
Frameworks like Express would allow registering several middlewares for the same
path, for instance.

My opinion is that it is a bad thing. Every route should have a single handler
and higher order functions should be used instead. That way, you have the
overhaul workflow of each route in their own controllers. No magic, no need to
guess what happens before/after the route handler.
[Read my blog post on this concern](http://insertafter.com/en/blog/no_more_middlewares.html).

`siso` is just a building block, if you need a higher level way to deal with
routers see [whook](https://github.com/nfroidure/whook).

[//]: # (::contents:end)

# API
<a name="Siso"></a>

## Siso
Siso

**Kind**: global class  

* [Siso](#Siso)
    * [new Siso()](#new_Siso_new)
    * [.register(pathNodes, value)](#Siso+register) ⇒ <code>void</code>
    * [.find(pathNodes)](#Siso+find) ⇒ <code>void</code>

<a name="new_Siso_new"></a>

### new Siso()
Create a new Siso instance

**Returns**: [<code>Siso</code>](#Siso) - The Siso instance  
**Example**  
```js
import { Siso } from 'siso';

const siso = new Siso();
```
<a name="Siso+register"></a>

### siso.register(pathNodes, value) ⇒ <code>void</code>
Register a value for given path nodes

**Kind**: instance method of [<code>Siso</code>](#Siso)  

| Param | Type | Description |
| --- | --- | --- |
| pathNodes | <code>Array</code> | The various nodes of the path |
| value | <code>any</code> | The value registered for the given path nodes |

**Example**  
```js
import { Siso } from 'siso';

const siso = new Siso();

// Path nodes may be simple strings
siso.register(['v1', 'users'], 'user.list');

// Or dynamic nodes with a name and its corresponding validation function
siso.register([
  'v1',
  'users',
  { name: 'id', validate: (str) => /[a-f0-9]{24}/.test(str), type: 'string' },
], 'user.details');
```
<a name="Siso+find"></a>

### siso.find(pathNodes) ⇒ <code>void</code>
Find the value for the given path

**Kind**: instance method of [<code>Siso</code>](#Siso)  

| Param | Type | Description |
| --- | --- | --- |
| pathNodes | <code>Array</code> | The path nodes for which to look for a value |

**Example**  
```js
import { Siso } from 'siso';

const siso = new Siso();

siso.register([
  'v1',
  'users',
  { name: 'userId', pattern: /[a-f0-9]{24}/, type: 'string' },
], 'anotherValue');

siso.find(['v1', 'users', 'abbacacaabbacacaabbacaca']);
// ['anotherValue', { userId: 'abbacacaabbacacaabbacaca' }]
```

# Authors
- [Nicolas Froidure](http://insertafter.com/en/index.html)

# License
[MIT](https://github.com/nfroidure/siso/blob/main/LICENSE)

---
_Source: https://npm.io/package/siso · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
