Skip to content

Commit d52c0b1

Browse files
committed
🎉 release: 1.1.25
1 parent 6811268 commit d52c0b1

File tree

5 files changed

+51
-14
lines changed

5 files changed

+51
-14
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 1.1.25 - 14 Nov 2024
2+
Bug fix:
3+
- [#908](https://github.com/elysiajs/elysia/pull/908) boolean-string converted to string
4+
- [#905](https://github.com/elysiajs/elysia/pull/905) avoid response normailization side effects
5+
6+
Change:
7+
- don't minify identifiers in bun bundle
8+
19
# 1.1.24 - 31 Oct 2024
210
Security:
311
- [#891](https://github.com/elysiajs/elysia/pull/891) Upgrade Cookie to 0.7.x to fix CVE-2024-47764

build.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const tsupConfig: Options = {
66
splitting: false,
77
sourcemap: false,
88
clean: true,
9-
bundle: true,
9+
bundle: true
1010
// outExtension() {
1111
// return {
1212
// js: '.js'
@@ -38,15 +38,19 @@ await $`tsc --project tsconfig.dts.json`
3838
await Bun.build({
3939
entrypoints: ['./src/index.ts'],
4040
outdir: './dist/bun',
41-
minify: true,
41+
minify: {
42+
whitespace: true,
43+
syntax: true,
44+
identifiers: false
45+
},
4246
target: 'bun',
4347
sourcemap: 'external',
4448
external: ['@sinclair/typebox']
4549
})
4650

4751
await Promise.all([
4852
$`cp dist/*.d.ts dist/cjs`,
49-
$`cp dist/ws/*.d.ts dist/cjs/ws/`,
53+
$`cp dist/ws/*.d.ts dist/cjs/ws/`
5054
])
5155

5256
await $`cp dist/index*.d.ts dist/bun`

bun.lockb

0 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "elysia",
33
"description": "Ergonomic Framework for Human",
4-
"version": "1.1.24",
4+
"version": "1.1.25",
55
"author": {
66
"name": "saltyAom",
77
"url": "https://github.com/SaltyAom",

src/utils.ts

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import type { BunFile } from 'bun'
2-
import { Kind, TransformKind, type TSchema } from '@sinclair/typebox'
2+
import {
3+
Kind,
4+
TAnySchema,
5+
TransformKind,
6+
type TSchema
7+
} from '@sinclair/typebox'
38
import { Value } from '@sinclair/typebox/value'
49
import { TypeCheck, TypeCompiler } from '@sinclair/typebox/compiler'
510

@@ -534,6 +539,21 @@ const _replaceSchemaType = (
534539
return schema
535540
}
536541

542+
const createCleaner = (schema: TAnySchema) => (value: unknown) => {
543+
if (typeof value === 'object')
544+
try {
545+
return Value.Clean(schema, structuredClone(value))
546+
} catch {
547+
try {
548+
return Value.Clean(schema, value)
549+
} catch {
550+
return value
551+
}
552+
}
553+
554+
return value
555+
}
556+
537557
export const getSchemaValidator = <T extends TSchema | string | undefined>(
538558
s: T,
539559
{
@@ -583,16 +603,10 @@ export const getSchemaValidator = <T extends TSchema | string | undefined>(
583603
}
584604
}
585605

586-
// console.dir(schema, {
587-
// depth: null
588-
// })
589-
590606
// @ts-ignore
591607
if (schema.type === 'object' && 'additionalProperties' in schema === false)
592608
schema.additionalProperties = additionalProperties
593609

594-
const cleaner = (value: unknown) => Value.Clean(schema, value)
595-
596610
if (dynamic) {
597611
const validator = {
598612
schema,
@@ -609,7 +623,7 @@ export const getSchemaValidator = <T extends TSchema | string | undefined>(
609623

610624
if (normalize && schema.additionalProperties === false)
611625
// @ts-ignore
612-
validator.Clean = cleaner
626+
validator.Clean = createCleaner(schema)
613627

614628
// @ts-ignore
615629
if (schema.config) {
@@ -715,7 +729,18 @@ export const getResponseSchemaValidator = (
715729

716730
const compile = (schema: TSchema, references?: TSchema[]) => {
717731
const cleaner = (value: unknown) => {
718-
return Value.Clean(schema, structuredClone(value))
732+
if (typeof value === 'object')
733+
try {
734+
return Value.Clean(schema, structuredClone(value))
735+
} catch {
736+
try {
737+
return Value.Clean(schema, value)
738+
} catch {
739+
return value
740+
}
741+
}
742+
743+
return value
719744
}
720745

721746
if (dynamic)
@@ -735,7 +760,7 @@ export const getResponseSchemaValidator = (
735760

736761
if (normalize && schema.additionalProperties === false)
737762
// @ts-ignore
738-
compiledValidator.Clean = cleaner
763+
compiledValidator.Clean = createCleaner(schema)
739764

740765
return compiledValidator
741766
}

0 commit comments

Comments
 (0)