Skip to content

Commit

Permalink
Merge pull request #290 from frouriojs/develop
Browse files Browse the repository at this point in the history
fix: remove unused props from validatorsToSchema
  • Loading branch information
solufa authored Apr 3, 2023
2 parents b42f4d6 + 333cfaf commit 834e3e1
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 151 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.32.0](https://github.com/frouriojs/frourio/compare/v0.31.1...v0.32.0) (2023-04-04)

### Features

- update [email protected] and [email protected] (https://github.com/frouriojs/frourio/pull/290)

### Bug Fixes

- remove unused props from validatorsToSchema (https://github.com/frouriojs/frourio/pull/269)

## [0.31.1](https://github.com/frouriojs/frourio/compare/v0.31.0...v0.31.1) (2022-12-09)

### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ We are always forced to write "Two TypeScript".
We waste a lot of time on dynamic testing using the browser and server.

<div align="center">
<img src="https://frourio.com/img/TwoTS.svg" width="1200" alt="Why frourio ?" />
<img src="https://frouriojs.github.io/frourio/assets/images/TwoTS.svg" width="1200" alt="Why frourio ?" />
</div>
<br />
<br />

Frourio is a framework for developing web apps quickly and safely in **"One TypeScript"**.

<div align="center">
<img src="https://frourio.com/img/OneTS.svg" width="1200" alt="Architecture of create-frourio-app" />
<img src="https://frouriojs.github.io/frourio/assets/images/OneTS.svg" width="1200" alt="Architecture of create-frourio-app" />
</div>
<br />
<br />
Expand Down
1 change: 1 addition & 0 deletions docs/assets/images/OneTS.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/assets/images/TwoTS.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/assets/images/architecture.png
Binary file not shown.
Binary file removed docs/assets/images/problem.png
Binary file not shown.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,37 @@
"dependencies": {
"aspida": "^1.11.0",
"velona": "^0.7.0",
"zod": "^3.19.1"
"zod": "^3.21.4"
},
"devDependencies": {
"@aspida/axios": "^1.11.0",
"@aspida/node-fetch": "^1.11.0",
"@fastify/multipart": "^7.3.0",
"@fastify/multipart": "^7.5.0",
"@types/busboy": "^1.3.0",
"@types/jest": "^29.2.3",
"@types/node-fetch": "^2.5.10",
"@types/rimraf": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"axios": "^0.26.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.1",
"eslint": "^8.27.0",
"eslint": "^8.37.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",
"fastify": "^4.10.2",
"fastify": "^4.15.0",
"jest": "^29.3.1",
"node-fetch": "^2.6.1",
"prettier": "^2.7.1",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
"typescript": "^5.0.3"
}
}
9 changes: 4 additions & 5 deletions servers/all/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export type ServerHooks<R extends Record<string, unknown> = {}> = {
}

export type ServerMethodHandler<T extends AspidaMethodParams, U extends Record<string, unknown> = {}> = ServerHandler<T, U> | ServerHandlerPromise<T, U> | {
validators?: Partial<{ [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}>
validators?: { [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}
schemas?: { response?: { [V in HttpStatusOk]?: Schema }}
hooks?: ServerHooks<U>
handler: ServerHandler<T, U> | ServerHandlerPromise<T, U>
Expand Down Expand Up @@ -235,10 +235,9 @@ const validatorCompiler: FastifySchemaCompiler<FastifySchema> = ({ schema }) =>
return result.success ? { value: result.data } : { error: result.error }
}

const validatorsToSchema = (validator?: { query?: unknown; body?: unknown; headers?: unknown }): FastifySchema => ({
querystring: validator?.query,
body: validator?.body,
headers: validator?.headers
const validatorsToSchema = ({ query, ...validators }: { query?: unknown; body?: unknown; headers?: unknown }): FastifySchema => ({
...(query ? { querystring: query } : {}),
...validators
})

const methodToHandler = (
Expand Down
2 changes: 1 addition & 1 deletion servers/minimum/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export type ServerHooks<R extends Record<string, unknown> = {}> = {
}

export type ServerMethodHandler<T extends AspidaMethodParams, U extends Record<string, unknown> = {}> = ServerHandler<T, U> | ServerHandlerPromise<T, U> | {
validators?: Partial<{ [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}>
validators?: { [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}
schemas?: { response?: { [V in HttpStatusOk]?: Schema }}
hooks?: ServerHooks<U>
handler: ServerHandler<T, U> | ServerHandlerPromise<T, U>
Expand Down
2 changes: 1 addition & 1 deletion servers/noMulter/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export type ServerHooks<R extends Record<string, unknown> = {}> = {
}

export type ServerMethodHandler<T extends AspidaMethodParams, U extends Record<string, unknown> = {}> = ServerHandler<T, U> | ServerHandlerPromise<T, U> | {
validators?: Partial<{ [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}>
validators?: { [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}
schemas?: { response?: { [V in HttpStatusOk]?: Schema }}
hooks?: ServerHooks<U>
handler: ServerHandler<T, U> | ServerHandlerPromise<T, U>
Expand Down
2 changes: 1 addition & 1 deletion servers/noTypedParams/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export type ServerHooks<R extends Record<string, unknown> = {}> = {
}

export type ServerMethodHandler<T extends AspidaMethodParams, U extends Record<string, unknown> = {}> = ServerHandler<T, U> | ServerHandlerPromise<T, U> | {
validators?: Partial<{ [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}>
validators?: { [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}
schemas?: { response?: { [V in HttpStatusOk]?: Schema }}
hooks?: ServerHooks<U>
handler: ServerHandler<T, U> | ServerHandlerPromise<T, U>
Expand Down
9 changes: 4 additions & 5 deletions servers/noValidator/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export type ServerHooks<R extends Record<string, unknown> = {}> = {
}

export type ServerMethodHandler<T extends AspidaMethodParams, U extends Record<string, unknown> = {}> = ServerHandler<T, U> | ServerHandlerPromise<T, U> | {
validators?: Partial<{ [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}>
validators?: { [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}
schemas?: { response?: { [V in HttpStatusOk]?: Schema }}
hooks?: ServerHooks<U>
handler: ServerHandler<T, U> | ServerHandlerPromise<T, U>
Expand Down Expand Up @@ -135,10 +135,9 @@ const validatorCompiler: FastifySchemaCompiler<FastifySchema> = ({ schema }) =>
return result.success ? { value: result.data } : { error: result.error }
}

const validatorsToSchema = (validator?: { query?: unknown; body?: unknown; headers?: unknown }): FastifySchema => ({
querystring: validator?.query,
body: validator?.body,
headers: validator?.headers
const validatorsToSchema = ({ query, ...validators }: { query?: unknown; body?: unknown; headers?: unknown }): FastifySchema => ({
...(query ? { querystring: query } : {}),
...validators
})

const methodToHandler = (
Expand Down
9 changes: 4 additions & 5 deletions src/buildServerFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export type ServerHooks<R extends Record<string, unknown> = {}> = {
}
export type ServerMethodHandler<T extends AspidaMethodParams, U extends Record<string, unknown> = {}> = ServerHandler<T, U> | ServerHandlerPromise<T, U> | {
validators?: Partial<{ [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}>
validators?: { [Key in keyof RequestParams<T>]?: z.ZodType<RequestParams<T>[Key]>}
schemas?: { response?: { [V in HttpStatusOk]?: Schema }}
hooks?: ServerHooks<U>
handler: ServerHandler<T, U> | ServerHandlerPromise<T, U>
Expand Down Expand Up @@ -329,10 +329,9 @@ const validatorCompiler: FastifySchemaCompiler<FastifySchema> = ({ schema }) =>
hasValidatorsToSchema
? `
const validatorsToSchema = (validator?: { query?: unknown; body?: unknown; headers?: unknown }): FastifySchema => ({
querystring: validator?.query,
body: validator?.body,
headers: validator?.headers
const validatorsToSchema = ({ query, ...validators }: { query?: unknown; body?: unknown; headers?: unknown }): FastifySchema => ({
...(query ? { querystring: query } : {}),
...validators
})`
: ''
}
Expand Down
Loading

0 comments on commit 834e3e1

Please sign in to comment.