Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete all regex like strings from StrictFileType in file checking #877

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/type-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export namespace ElysiaTypeOptions {

export type StrictFileType =
| 'image'
| 'image/*'
| 'image/jpeg'
| 'image/png'
| 'image/gif'
Expand All @@ -112,14 +111,12 @@ export namespace ElysiaTypeOptions {
| 'image/webp'
| 'image/avif'
| 'audio'
| 'audio/*'
| 'audio/aac'
| 'audio/mpeg'
| 'audio/x-ms-wma'
| 'audio/vnd.rn-realaudio'
| 'audio/x-wav'
| 'video'
| 'video/*'
| 'video/mpeg'
| 'video/mp4'
| 'video/quicktime'
Expand All @@ -128,15 +125,13 @@ export namespace ElysiaTypeOptions {
| 'video/x-flv'
| 'video/webm'
| 'text'
| 'text/*'
| 'text/css'
| 'text/csv'
| 'text/html'
| 'text/javascript'
| 'text/plain'
| 'text/xml'
| 'application'
| 'application/*'
| 'application/graphql'
| 'application/graphql-response+json'
| 'application/ogg'
Expand All @@ -150,7 +145,6 @@ export namespace ElysiaTypeOptions {
| 'application/xml'
| 'application/zip'
| 'font'
| 'font/*'
| 'font/woff2'
| 'font/woff'
| 'font/ttf'
Expand Down Expand Up @@ -318,8 +312,11 @@ type NonEmptyArray<T> = [T, ...T[]]

export type TEnumValue = number | string | null

export interface TUnionEnum<T extends NonEmptyArray<TEnumValue> | Readonly<NonEmptyArray<TEnumValue>> = [TEnumValue]>
extends TSchema {
export interface TUnionEnum<
T extends
| NonEmptyArray<TEnumValue>
| Readonly<NonEmptyArray<TEnumValue>> = [TEnumValue]
> extends TSchema {
type?: 'number' | 'string' | 'null'
[Kind]: 'UnionEnum'
static: T[number]
Expand Down Expand Up @@ -593,7 +590,11 @@ export const ElysiaType = {
return v
},
// based on https://github.com/elysiajs/elysia/issues/512#issuecomment-1980134955
UnionEnum: <const T extends NonEmptyArray<TEnumValue> | Readonly<NonEmptyArray<TEnumValue>>>(
UnionEnum: <
const T extends
| NonEmptyArray<TEnumValue>
| Readonly<NonEmptyArray<TEnumValue>>
>(
values: T,
options: SchemaOptions = {}
) => {
Expand Down