Sidewinder
Type Safe Micro Services for Node
Install / Use
/learn @sinclairzx81/SidewinderREADME
<img src="https://img.shields.io/npm/v/@sidewinder/async?label=%40sidewinder%2Fasync"> <img src="https://img.shields.io/npm/v/@sidewinder/buffer?label=%40sidewinder%2Fbuffer"> <img src="https://img.shields.io/npm/v/@sidewinder/channel?label=%40sidewinder%2Fchannel"> <img src="https://img.shields.io/npm/v/@sidewinder/client?label=%40sidewinder%2Fclient"> <img src="https://img.shields.io/npm/v/@sidewinder/config?label=%40sidewinder%2Fconfig"> <img src="https://img.shields.io/npm/v/@sidewinder/contract?label=%40sidewinder%2Fcontract"> <img src="https://img.shields.io/npm/v/@sidewinder/events?label=%40sidewinder%2Fevents"> <img src="https://img.shields.io/npm/v/@sidewinder/hash?label=%40sidewinder%2Fhash"> <img src="https://img.shields.io/npm/v/@sidewinder/mime?label=%40sidewinder%2Fmime"> <img src="https://img.shields.io/npm/v/@sidewinder/mongo?label=%40sidewinder%2Fmongo"> <img src="https://img.shields.io/npm/v/@sidewinder/path?label=%40sidewinder%2Fpath"> <img src="https://img.shields.io/npm/v/@sidewinder/platform?label=%40sidewinder%2Fplatform"> <img src="https://img.shields.io/npm/v/@sidewinder/query?label=%40sidewinder%2Fquery"> <img src="https://img.shields.io/npm/v/@sidewinder/redis?label=%40sidewinder%2Fredis"> <img src="https://img.shields.io/npm/v/@sidewinder/server?label=%40sidewinder%2Fserver"> <img src="https://img.shields.io/npm/v/@sidewinder/token?label=%40sidewinder%2Ftoken"> <img src="https://img.shields.io/npm/v/@sidewinder/type?label=%40sidewinder%2Ftype"> <img src="https://img.shields.io/npm/v/@sidewinder/validator?label=%40sidewinder%2Fvalidator"> <img src="https://img.shields.io/npm/v/@sidewinder/validator?label=%40sidewinder%2Fvalue"> <img src="https://img.shields.io/npm/v/@sidewinder/web?label=%40sidewinder%2Fweb">
Overview
Sidewinder is a strictly typed and runtime validated micro service framework built for Node and Browser environments. It is designed for web service architectures where each service needs to communicate with other services in complex ways and where challenges often arise verifying each service is communicating using strict communication contracts.
Sidewinder is developed primarily around a runtime type system based on JSON Schema. It encodes runtime type information into JavaScript directly then leverages the TypeScript language to statically infer associated static types at compile time. This approach enables distributed services to be statically checked with the TypeScript compiler, with the same runtime data assertions handled automatically by Sidewinder packages using standard JSON Schema validation.
License MIT
Contents
Packages
- Async
- Buffer
- Channel
- Client
- Config
- Contract
- Event
- Hash
- Mime
- Mongo
- Path
- Platform
- Query
- Redis
- Server
- Token
- Type
- Validator
- Value
- Web
Install
Sidewinder consists of a number of packages that target various facets of micro service development. Each package is orientated towards type safe interactions with services and common Node infrastructure.
# Runtime Type System
$ npm install @sidewinder/type # Json Schema Runtime Type Builder
$ npm install @sidewinder/validator # Json Schema Validator
# Service Packages
$ npm install @sidewinder/contract # Service Descriptions Contracts
$ npm install @sidewinder/client # Http and Web Socket Clients
$ npm install @sidewinder/server # Http and Web Socket Services and Hosting
# Database and Infrastructure
$ npm install @sidewinder/query # Query Filter Syntax for Mongo
$ npm install @sidewinder/mongo # Type Safe Mongo
$ npm install @sidewinder/redis # Type Safe Redis
# Application Messaging
$ npm install @sidewinder/async # Asynchronous Primitives
$ npm install @sidewinder/channel # Asynchronous Channels
$ npm install @sidewinder/events # Portable Event Emitter
# Hashing and Signing
$ npm install @sidewinder/hash # Hashing Functions
$ npm install @sidewinder/token # Type Safe Json Web Token
# Environment
$ npm install @sidewinder/buffer # Operations on type Uint8Array
$ npm install @sidewinder/config # Type Safe Configurations
$ npm install @sidewinder/path # File System Pathing Utility
$ npm install @sidewinder/platform # Runtime Environment Checks
<a name="TypeSafety"></a>
Static and Runtime Safe
Sidewinder provides both runtime and static type safety derived from Contract definitions encoded in JavaScript. It makes heavy use of TypeScript's type inference capabilities to statically infer Client and Service method signatures for defined Contracts; with data received over the network runtime checked to ensure it matches the expected parameter and return types defined for each method.
// ---------------------------------------------------------------------------
// Contract
// ---------------------------------------------------------------------------
const Contract = Type.Contract({
server: {
'add': Type.Function([Type.Number(), Type.Number()], Type.Number())
}
})
// ---------------------------------------------------------------------------
// Service
// ---------------------------------------------------------------------------
const service = new WebService(Contract)
service.method('add', (clientId, a, b) => {
// │ │ │
// │ │ └─── params (a: number, b: number)
// │ │
// │ └─── unique client identifier
// │
// └─── method name inferred from contract
//
//
// ┌─── return inferred as `number`
// │
return a + b
})
// ---------------------------------------------------------------------------
// Client
// ---------------------------------------------------------------------------
const client = new WebClient(Contract, 'http://....')
const result = await client.call('add', 1, 1)
// │ │ │
// │ │ └─── arguments as (method: string, a: number, b: number)
// │ │
// │ └─── method name inferred from contract
// │
// └─── result is `number`
<a name="ServicesAndClients"></a>
Services and Clients
[TypeScript Example Link](https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgFQJ5gKZwL5z-g-AMyghDgHIABAZ2ABMMB3YAO0agHoBjCVmKAENuMCgFgAUKEixEcABIQaMADRwA6hgBGAZQxQAbsG5ZcJMpVoNmbDpxr6D+8VPDR4STVoDCAG2AY-DiExKTk1HSMLOz6PP6BopKSnJxwALQZmVnZObl5+QWF+cmp3nwCwjAlJXBl-EIiNHCCUFgOhsZYbDD6RMJYjDTcUMBgMMB8TTAAFoLwg8PAWliCcA7wEERw3IK+voJavhg1RACurCITrE2C7M2scBBjV7twgbz0bADmcETQIHMAHRwHTWaIcOCnBxNOoVRpwGAQOA1Ay7BhzAZzVYOIIQJxQZpwVgYGBMaAAa2aTSYGD2VIRSOUc2Mu18qDgbCI+lq8SCNVu9BBjm5IBJ0wg9CabBQ6AwOkWY2ByCg7O4s1YX2+COmWDALUEop6UBud1aMFOUAeNRgsqafwJMywZwu40mcGWvggTAZHNYqP89AxPICQQFQsMIrFEpogOqEhS6SKSeTKdTWSSEl413gsIa8AAvDLMIDc5UABQISQEe0AmAALkoACsaHwKCoq-h2viG5WJCE8BRBPR6BQG2hiwAxc6XPhlgDa44wgIAcqcQMsoGWAJRqRcrtcb7cAXV3sv36-0253HZCFBopy0o6LS6nLqu873q4vm53z-Ph63E8-y-ADrz7fsKBAU5fCfPdXxnVgPzPEDL1-T8D1QoD0O-K923A29PgMWCz3g11EIXZCMJ-U9ixQn8sMonCtzAghsEkbAtwzBM0x43i+LSGo9A6Ew4wTISjBMJowFIIxGG2PhhhJLpwCOUV+GZN17Vqco8xjcMJKwQ1xUlGpWhMYAnEJLMegAD3
Related Skills
node-connect
347.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.6kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
