Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@elysiajs/websocket

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elysiajs/websocket - npm Package Compare versions

Comparing version 0.0.0-experimental.8 to 0.1.0-rc.1

dist/cjs/index.js

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 0.1.0-rc.1 - 6 Dec 2022
Improvement:
- Support for Elysia 0.1.0-rc.1 onward
# 0.0.0-experimental.7 - 24 Nov 2022

@@ -2,0 +6,0 @@ Feature:

31

package.json
{
"name": "@elysiajs/websocket",
"version": "0.0.0-experimental.8",
"version": "0.1.0-rc.1",
"description": "Plugin for Elysia that add support for websocket",

@@ -10,7 +10,9 @@ "author": {

},
"main": "build/index.js",
"module": "build/es/index.js",
"esnext": "build/es/index.js",
"types": "src/index.ts",
"typings": "src/index.ts",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/index.js",
"node": "./dist/index.js",
"default": "./dist/index.js"
},
"types": "./dist/index.d.ts",
"keywords": [

@@ -28,21 +30,18 @@ "elysia",

"scripts": {
"dev": "nodemon --config nodemon.json",
"dev": "bun run --hot example/index.ts",
"test": "bun wiptest",
"build": "npm run build:main && npm run build:es",
"build:main": "swc src --config-file .cjs.swcrc -d build",
"build:es": "swc src --config-file .es.swcrc -d build/es",
"build": "rimraf dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"release": "npm run build && npm run test && npm publish --access public"
},
"peerDependencies": {
"elysia": ">= 0.0.0-experimental.56"
"elysia": ">= 0.1.0-rc.1"
},
"devDependencies": {
"@sinclair/typebox": "0.25.8",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.3.11",
"@sinclair/typebox": "0.25.10",
"@types/node": "^18.11.7",
"bun-types": "^0.2.2",
"eslint": "^8.26.0",
"elysia": "0.0.0-experimental.56",
"nodemon": "^2.0.20",
"elysia": "^0.1.0-rc.1",
"typescript": "^4.8.4"

@@ -49,0 +48,0 @@ },

import type { WebSocketHandler } from 'bun'
import { Elysia, getPath, type Context } from 'elysia'
import { Router } from 'elysia/src/router'
import { createValidationError, getSchemaValidator } from 'elysia/src/utils'
import {
Elysia,
getPath,
Router,
createValidationError,
getSchemaValidator,
type Context
} from 'elysia'
import { nanoid } from 'nanoid'

@@ -66,6 +70,6 @@

if (
(
!(
ws.data as ElysiaWebSocket['data']
).message?.Check(message) === false
)
).message?.Check(message)
) {
return void ws.send(

@@ -77,4 +81,5 @@ createValidationError(

message
).message
).cause as string
)
}

@@ -145,3 +150,3 @@ route.message(ws, message)

schema: {
header: options.schema?.header,
headers: options.schema?.headers,
params: options.schema?.params,

@@ -148,0 +153,0 @@ query: options.schema?.query

import type { ServerWebSocket, WebSocketHandler } from 'bun'
import type { Context, TypedSchema, HookHandler, UnwrapSchema } from 'elysia'
import type { Router } from 'elysia/src/router'
import type {
ExtractKWPath,
Context,
TypedSchema,
HookHandler,
UnwrapSchema,
Router
} from 'elysia'
import type {
ExtractPath,
TypedRoute,
TypedSchemaToRoute,
WithArray
} from 'elysia/src/types'
} from 'elysia/dist/types'

@@ -24,4 +29,4 @@ import type { Static, TSchema } from '@sinclair/typebox'

body: never
header: UnwrapSchema<Schema['header']> extends Record<string, any>
? UnwrapSchema<Schema['header']>
headers: UnwrapSchema<Schema['headers']> extends Record<string, any>
? UnwrapSchema<Schema['headers']>
: undefined

@@ -39,3 +44,3 @@ query: UnwrapSchema<Schema['query']> extends Record<string, any>

body: undefined
header: Schema['header']
headers: Schema['headers']
query: Schema['query']

@@ -51,6 +56,6 @@ params: Schema['params']

Context<
ExtractKWPath<Path> extends never
ExtractPath<Path> extends never
? WebSocketSchemaToRoute<Schema>
: Omit<WebSocketSchemaToRoute<Schema>, 'params'> & {
params: Record<ExtractKWPath<Path>, string>
params: Record<ExtractPath<Path>, string>
}

@@ -83,3 +88,3 @@ > & {

> & {
params: Record<ExtractKWPath<Path>, string>
params: Record<ExtractPath<Path>, string>
}

@@ -86,0 +91,0 @@ >

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc