Skip to content

Commit

Permalink
Merge pull request #89 from frouriojs/develop
Browse files Browse the repository at this point in the history
chore(release): 0.17.1
  • Loading branch information
solufa authored Oct 11, 2020
2 parents fb9c025 + ffab76c commit 65b16a4
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 23 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

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.17.1](https://github.com/frouriojs/frourio/compare/v0.17.0...v0.17.1) (2020-10-11)


### Bug Fixes

* optimize type definition of RequestParams ([4a810aa](https://github.com/frouriojs/frourio/commit/4a810aa5f277773dbce3b25a077c2f80e74ad07f))


### Documentation

* update README ([fb9c025](https://github.com/frouriojs/frourio/commit/fb9c025c24662039c825d5f23c2d7e1b86d395a7))

## [0.17.0](https://github.com/frouriojs/frourio/compare/v0.16.0...v0.17.0) (2020-10-09)


Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@

## Why frourio ?

Even if you write both the front and server in TypeScript, you can't statically type-check the API's sparsity.
Even if you write both the frontend and backend in TypeScript, you can't statically type-check the API's sparsity.

We are always forced to write "Two TypeScript".
We waste a lot of time on dynamic testing using the browser and Docker.
We waste a lot of time on dynamic testing using the browser and server.

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

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

<div align="center">
<img src="https://frouriojs.github.io/frourio/assets/images/architecture.png" width="1200" alt="Architecture of create-frourio-app" />
Expand Down Expand Up @@ -829,7 +829,7 @@ fastify.listen(3000)
## Dependency Injection
Frourio use [frouriojs/Velona](https://github.com/frouriojs/velona) for dependency injection.
Frourio use [frouriojs/velona](https://github.com/frouriojs/velona) for dependency injection.
`server/api/tasks/index.ts`
Expand Down Expand Up @@ -916,9 +916,7 @@ test('dependency injection into controller', async () => {
const limit = 3
const message = 'test message'
const res = await injectedController.get({
query: { limit, message },
body: undefined,
headers: undefined
query: { limit, message }
})
expect(res.body).toHaveLength(limit)
Expand Down
4 changes: 1 addition & 3 deletions __test__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ test('controller dependency injection', async () => {

await expect(
injectedController.get({
query: { id, requiredNum: 1, requiredNumArr: [0], disable: 'true' },
body: undefined,
headers: undefined
query: { id, requiredNum: 1, requiredNumArr: [0], disable: 'true' }
})
).resolves.toHaveProperty('body', { id: +id })
expect(val).toBe(+id)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frourio",
"version": "0.17.0",
"version": "0.17.1",
"description": "Perfectly type-checkable REST framework for TypeScript",
"author": "Solufa <[email protected]>",
"license": "MIT",
Expand Down
8 changes: 6 additions & 2 deletions servers/all/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ type BlobToFile<T extends AspidaMethodParams> = T['reqFormat'] extends FormData
}
: T['reqBody']

type RequestParams<T extends AspidaMethodParams> = {
type RequestParams<T extends AspidaMethodParams> = Pick<{
query: T['query']
body: BlobToFile<T>
headers: T['reqHeaders']
}
}, {
query: Required<T>['query'] extends {} | null ? 'query' : never
body: Required<T>['reqBody'] extends {} | null ? 'body' : never
headers: Required<T>['reqHeaders'] extends {} | null ? 'headers' : never
}['query' | 'body' | 'headers']>

export type ServerMethods<T extends AspidaMethods, U extends ServerValues> = {
[K in keyof T]: (
Expand Down
8 changes: 6 additions & 2 deletions servers/minimum/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ type ServerValues = {
user?: any
}

type RequestParams<T extends AspidaMethodParams> = {
type RequestParams<T extends AspidaMethodParams> = Pick<{
query: T['query']
body: T['reqBody']
headers: T['reqHeaders']
}
}, {
query: Required<T>['query'] extends {} | null ? 'query' : never
body: Required<T>['reqBody'] extends {} | null ? 'body' : never
headers: Required<T>['reqHeaders'] extends {} | null ? 'headers' : never
}['query' | 'body' | 'headers']>

export type ServerMethods<T extends AspidaMethods, U extends ServerValues> = {
[K in keyof T]: (
Expand Down
8 changes: 6 additions & 2 deletions servers/noMulter/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ type ServerValues = {
user?: any
}

type RequestParams<T extends AspidaMethodParams> = {
type RequestParams<T extends AspidaMethodParams> = Pick<{
query: T['query']
body: T['reqBody']
headers: T['reqHeaders']
}
}, {
query: Required<T>['query'] extends {} | null ? 'query' : never
body: Required<T>['reqBody'] extends {} | null ? 'body' : never
headers: Required<T>['reqHeaders'] extends {} | null ? 'headers' : never
}['query' | 'body' | 'headers']>

export type ServerMethods<T extends AspidaMethods, U extends ServerValues> = {
[K in keyof T]: (
Expand Down
8 changes: 6 additions & 2 deletions servers/noTypedParams/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ type BlobToFile<T extends AspidaMethodParams> = T['reqFormat'] extends FormData
}
: T['reqBody']

type RequestParams<T extends AspidaMethodParams> = {
type RequestParams<T extends AspidaMethodParams> = Pick<{
query: T['query']
body: BlobToFile<T>
headers: T['reqHeaders']
}
}, {
query: Required<T>['query'] extends {} | null ? 'query' : never
body: Required<T>['reqBody'] extends {} | null ? 'body' : never
headers: Required<T>['reqHeaders'] extends {} | null ? 'headers' : never
}['query' | 'body' | 'headers']>

export type ServerMethods<T extends AspidaMethods, U extends ServerValues> = {
[K in keyof T]: (
Expand Down
8 changes: 6 additions & 2 deletions servers/noValidator/$server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ type BlobToFile<T extends AspidaMethodParams> = T['reqFormat'] extends FormData
}
: T['reqBody']

type RequestParams<T extends AspidaMethodParams> = {
type RequestParams<T extends AspidaMethodParams> = Pick<{
query: T['query']
body: BlobToFile<T>
headers: T['reqHeaders']
}
}, {
query: Required<T>['query'] extends {} | null ? 'query' : never
body: Required<T>['reqBody'] extends {} | null ? 'body' : never
headers: Required<T>['reqHeaders'] extends {} | null ? 'headers' : never
}['query' | 'body' | 'headers']>

export type ServerMethods<T extends AspidaMethods, U extends ServerValues> = {
[K in keyof T]: (
Expand Down
8 changes: 6 additions & 2 deletions src/buildServerFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ type BlobToFile<T extends AspidaMethodParams> = T['reqFormat'] extends FormData
`
: ''
}
type RequestParams<T extends AspidaMethodParams> = {
type RequestParams<T extends AspidaMethodParams> = Pick<{
query: T['query']
body: ${hasMultipart ? 'BlobToFile<T>' : "T['reqBody']"}
headers: T['reqHeaders']
}
}, {
query: Required<T>['query'] extends {} | null ? 'query' : never
body: Required<T>['reqBody'] extends {} | null ? 'body' : never
headers: Required<T>['reqHeaders'] extends {} | null ? 'headers' : never
}['query' | 'body' | 'headers']>
export type ServerMethods<T extends AspidaMethods, U extends ServerValues> = {
[K in keyof T]: (
Expand Down

0 comments on commit 65b16a4

Please sign in to comment.