UNPKG

@collight/dns-sd

Version:

A DNS Service Discovery implementation in modern TypeScript

71 lines (45 loc) 1.5 kB
# dns-sd [![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](https://gitlab.com/collight/dns-sd/-/blob/main/LICENSE.md) [![GitLab Pipeline Status](https://img.shields.io/gitlab/pipeline-status/collight/dns-sd?style=flat-square)](https://gitlab.com/collight/dns-sd/-/pipelines) [![NPM Version](https://img.shields.io/npm/v/@collight/dns-sd?style=flat-square)](https://www.npmjs.com/package/@collight/dns-sd) [![Doc](http://collight.gitlab.io/dns-sd/coverage.svg)](http://collight.gitlab.io/dns-sd) A DNS Service Discovery implementation in modern TypeScript This is a rewrite of the [bonjour-service](https://github.com/onlxltd/bonjour-service) library that fixes multiple issues and applies latest TypeScript best practice ## Installation ```bash pnpm i @collight/dns-sd ``` ## Usage ### Comprehensive demos ```bash pnpm i # demo/main.ts pnpm demo # demo/publish.ts pnpm demo:publish # demo/browse.ts pnpm demo:browse ``` ### Basic usage ```ts import { dnssd } from '@collight/dns-sd'; const dnssd = new DNSSD(); // advertise an HTTP server on port 3000 dnssd.publish({ name: 'My Web Server', type: 'http', port: 3000 }); // browse for all http services const browser = dnssd.startBrowser({ filter: { protocol: 'tcp', type: 'http' } }, s => { console.log('Found an HTTP server:', s); }); ``` ### API Docs http://collight.gitlab.io/dns-sd ## Development ```bash pnpm i pnpm format && pnpm lint pnpm build && pnpm test pnpm doc ``` ## License MIT