Skip to content

Commit

Permalink
🔧 fix: accept pr
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom committed Jan 8, 2024
1 parent 2e8d521 commit b66b244
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: SaltyAom
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and Test

on:
push:
pull_request:

jobs:
build:
name: Build and test code
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install packages
run: bun install

- name: Build code
run: bun run build

- name: Test
run: bun run test
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.8.1 - 8 Jan 2024
Bug fix:
- [#41](https://github.com/elysiajs/eden/pull/41) params now optional for paramless routes in edenFetch
- [#39](https://github.com/elysiajs/eden/pull/39) transform entire object returned by execute

# 0.8.0 - 23 Dec 2023
Feature:
- Support Elysia 0.8
Expand Down
14 changes: 6 additions & 8 deletions example/client/src/treaty.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { edenTreaty, EdenTreaty } from '../../../src/treaty'
import type { Server } from '../../server'

export const client = edenTreaty<Server>('http://localhost:8080', {
fetcher: (url, options) => customFetcher(url, options)
})
export const client = edenTreaty<Server>('http://localhost:8080')

// const data2 = await client.products.nendoroid.skadi.get({
// $query: {
// username: 'A'
// }
// })
const { data } = await client.products.nendoroid.skadi.get({
$query: {
username: 'A'
}
})

// const data = await client.products.nendoroid.skadi.post({
// username: 'A'
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": "@elysiajs/eden",
"version": "0.8.0",
"version": "0.8.1",
"description": "Fully type-safe Elysia client",
"author": {
"name": "saltyAom",
Expand Down
6 changes: 3 additions & 3 deletions src/treaty/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Elysia, InputSchema } from 'elysia'

import { EdenFetchError } from '../errors'

import { composePath } from './utils'
import { composePath, isNumericString } from './utils'
import type { EdenTreaty } from './types'

export type { EdenTreaty } from './types'
Expand Down Expand Up @@ -123,7 +123,7 @@ export class EdenWS<Schema extends InputSchema<any> = InputSchema> {
} catch {
// Not Empty
}
else if (!Number.isNaN(+data)) data = +data
else if (isNumericString(data)) data = +data
else if (data === 'true') data = true
else if (data === 'false') data = false

Expand Down Expand Up @@ -328,7 +328,7 @@ const createProxy = (

default:
data = await response.text().then((data) => {
if (!Number.isNaN(+data)) return +data
if (!isNumericString(data)) return +data
if (data === 'true') return true
if (data === 'false') return false

Expand Down
3 changes: 3 additions & 0 deletions src/treaty/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ export const composePath = (

return `${domain}${path}?${q.slice(0, -1)}`
}

export const isNumericString = (message: string) =>
!Number.isNaN(parseInt(message))
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"jsx": "react",
"skipLibCheck": true
},
"include": ["./src/**/*"]
"include": ["./src/**/*"],
"exclude": ["test/**/*"]
}

0 comments on commit b66b244

Please sign in to comment.