Skip to content

Commit

Permalink
applied lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
unnoq committed Dec 27, 2024
1 parent f706023 commit ffb4aa8
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 35 deletions.
11 changes: 5 additions & 6 deletions apps/content/examples/contract.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import type { InferContractRouterInputs, InferContractRouterOutputs } from '@orpc/contract'
import { oc } from '@orpc/contract'
import { ORPCError, os } from '@orpc/server'
import { oz, ZodCoercer } from '@orpc/zod'
import { z } from 'zod'

// Implement the contract

import { ORPCError, os } from '@orpc/server'

// Define your contract first
// This contract can replace server router in most-case

Expand Down Expand Up @@ -63,6 +60,8 @@ export const contract = oc.router({
export type Inputs = InferContractRouterInputs<typeof contract>
export type Outputs = InferContractRouterOutputs<typeof contract>

// Implement the contract

export type Context = { user?: { id: string } }
export const base = os.context<Context>()
export const pub /** os with ... */ = base.contract(contract) // Ensure every implement must be match contract
Expand Down Expand Up @@ -114,11 +113,11 @@ export const router = pub.router({
},
})

// Modern runtime that support fetch api like deno, bun, cloudflare workers, even node can used
import { createServer } from 'node:http'
// Expose apis to the internet with fetch handler
import { OpenAPIServerlessHandler } from '@orpc/openapi/fetch'
import { CompositeHandler, ORPCHandler } from '@orpc/server/fetch'
// Modern runtime that support fetch api like deno, bun, cloudflare workers, even node can used
import { createServer } from 'node:http'
import { createServerAdapter } from '@whatwg-node/server'

const openapiHandler = new OpenAPIServerlessHandler(router, {
Expand Down
4 changes: 1 addition & 3 deletions apps/content/examples/open-api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { generateOpenAPI } from '@orpc/openapi'
import { router } from 'examples/server'

// or generate from contract
import { contract } from 'examples/contract'
import { router } from 'examples/server'

export const specFromServerRouter = generateOpenAPI({
router,
Expand Down
4 changes: 2 additions & 2 deletions apps/content/examples/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ export const router = pub.router({
export type Inputs = InferRouterInputs<typeof router>
export type Outputs = InferRouterOutputs<typeof router>

// Modern runtime that support fetch api like deno, bun, cloudflare workers, even node can used
import { createServer } from 'node:http'
// Expose apis to the internet with fetch handler
import { OpenAPIServerlessHandler } from '@orpc/openapi/fetch'
import { CompositeHandler, ORPCHandler } from '@orpc/server/fetch'
// Modern runtime that support fetch api like deno, bun, cloudflare workers, even node can used
import { createServer } from 'node:http'
import { createServerAdapter } from '@whatwg-node/server'

const openapiHandler = new OpenAPIServerlessHandler(router, {
Expand Down
6 changes: 3 additions & 3 deletions packages/openapi/src/fetch/openapi-procedure-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export class OpenAPIProcedureMatcher {
const path = match[0][1]
const params = paramStash
? mapValues<number, string, string>(
match[1] as ParamIndexMap, // if paramStash is defined, then match[1] is ParamIndexMap
v => paramStash[v]!,
)
match[1] as ParamIndexMap, // if paramStash is defined, then match[1] is ParamIndexMap
v => paramStash[v]!,
)
: match[1] as Params // if paramStash is undefined, then match[1] is Params

const { default: maybeProcedure } = await unlazy(getRouterChild(this.router, ...path))
Expand Down
18 changes: 9 additions & 9 deletions packages/openapi/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ export async function generateOpenAPI(
...inputSchema,
properties: inputSchema.properties
? Object.entries(inputSchema.properties).reduce(
(acc, [key, value]) => {
if (key !== name) {
acc[key] = value
}

return acc
},
{} as Record<string, JSONSchema>,
)
(acc, [key, value]) => {
if (key !== name) {
acc[key] = value
}

return acc
},
{} as Record<string, JSONSchema>,
)
: undefined,
required: inputSchema.required?.filter(v => v !== name),
examples: inputSchema.examples?.map((example) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/react-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export function createORPCUtils<T extends RouterClient<any>>(
// for sure root is not procedure, so do not it procedure utils on root
const procedureUtils = path.length
? createProcedureUtils({
client,
queryClient: options.contextValue.queryClient,
path,
})
client,
queryClient: options.contextValue.queryClient,
path,
})
: {}

return new Proxy(
Expand Down
10 changes: 5 additions & 5 deletions packages/server/src/router-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export function createRouterClient<

const procedureCaller = isLazy(options.router)
? createProcedureClient({
...options,
procedure: createLazyProcedureFormAnyLazy(options.router),
context: options.context,
path: options.path,
})
...options,
procedure: createLazyProcedureFormAnyLazy(options.router),
context: options.context,
path: options.path,
})
: {}

const recursive = new Proxy(procedureCaller, {
Expand Down
2 changes: 1 addition & 1 deletion playgrounds/nuxt/lib/orpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { router } from '~/server/router'
import { createORPCFetchClient } from '@orpc/client'
import { createORPCVueQueryUtils } from '@orpc/vue-query'
import type { router } from '~/server/router'

export const client = createORPCFetchClient<typeof router>({
baseURL: 'http://localhost:3000/api',
Expand Down
4 changes: 2 additions & 2 deletions playgrounds/nuxt/plugins/vue-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import type {
DehydratedState,
VueQueryPluginOptions,
} from '@tanstack/vue-query'
// Nuxt 3 app aliases
import { defineNuxtPlugin, useState } from '#imports'
import {
dehydrate,
hydrate,
QueryClient,
VueQueryPlugin,
} from '@tanstack/vue-query'
// Nuxt 3 app aliases
import { defineNuxtPlugin, useState } from '#imports'

export default defineNuxtPlugin((nuxt) => {
const vueQueryState = useState<DehydratedState | null>('vue-query')
Expand Down

0 comments on commit ffb4aa8

Please sign in to comment.