@elysiajs/websocket
Advanced tools
Comparing version 0.0.0-experimental.8 to 0.1.0-rc.1
@@ -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: |
{ | ||
"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 @@ > |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
822
49868
16
1