# node-socket.io-router

> Router class for socket.io

Latest version **1.1.3** (published 2018-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-socket.io-router
pnpm add node-socket.io-router
yarn add node-socket.io-router
bun add node-socket.io-router
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2018-07-17 |
| First published | 2018-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Gadzhiev Said |
| Maintainers | darkwar123 |
| Keywords | node |

## Links

- npm: https://www.npmjs.com/package/node-socket.io-router
- Repository: https://github.com/darkwar123/node-socket.io-router
- Homepage: https://github.com/darkwar123/node-socket.io-router#readme
- Issues: https://github.com/darkwar123/node-socket.io-router/issues
- npm.io page: https://npm.io/package/node-socket.io-router

## Dependencies (3)

- [async](https://npm.io/package/async.md) ^2.5.0
- [debug](https://npm.io/package/debug.md) ^2.6.8
- [array-flatten](https://npm.io/package/array-flatten.md) ^2.1.1

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2018-07-17

## README

# Router class for socket.io
Router class for socket.io as an express.Router class.
# Example
Example of the server-side code:
```javascript
const router = require('node-socket.io-router').Router();

router.use('/', function (req, res, next) {
    if(req.params.name){
        return next();
    }
    
    next(new MyErrorClass('You didn't attach your name'));//You should create your Class or use String, don't use Error class
}, function (req, res, next) {
    res.send('Hello Mr. ' + req.params.name);
})

const io = require('socket.io').listen(3000);
io.use(router.handle());
```
Example of the client-side code:
```javascript
var io = new io();

io.emit('/', {name: 'darkwar123'}, function (err, response) {
    if(err){
        return console.error(err.message); 
    }
    
    console.info(response);//Writes 'Hello Mr. darkwar123'
})
```

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