mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-02-02 21:27:53 +01:00
refactor: lint
This commit is contained in:
@@ -56,12 +56,12 @@ export function createTRPCHandler<Router extends AnyRouter>({
|
|||||||
res,
|
res,
|
||||||
} = event
|
} = event
|
||||||
|
|
||||||
const $url = createURL(req.url)
|
const $url = createURL(req.url!)
|
||||||
|
|
||||||
const httpResponse = await resolveHTTPResponse({
|
const httpResponse = await resolveHTTPResponse({
|
||||||
router,
|
router,
|
||||||
req: {
|
req: {
|
||||||
method: req.method,
|
method: req.method!,
|
||||||
headers: req.headers,
|
headers: req.headers,
|
||||||
body: isMethod(event, 'GET') ? null : await useBody(event),
|
body: isMethod(event, 'GET') ? null : await useBody(event),
|
||||||
query: $url.searchParams,
|
query: $url.searchParams,
|
||||||
@@ -81,8 +81,8 @@ export function createTRPCHandler<Router extends AnyRouter>({
|
|||||||
|
|
||||||
res.statusCode = status
|
res.statusCode = status
|
||||||
|
|
||||||
Object.keys(headers).forEach((key) => {
|
headers && Object.keys(headers).forEach((key) => {
|
||||||
res.setHeader(key, headers[key])
|
res.setHeader(key, headers[key]!)
|
||||||
})
|
})
|
||||||
|
|
||||||
return body
|
return body
|
||||||
|
|||||||
@@ -31,14 +31,12 @@ export type TError = TRPCClientErrorLike<AppRouter>
|
|||||||
|
|
||||||
export type TQueryValues = inferProcedures<AppRouter['_def']['queries']>
|
export type TQueryValues = inferProcedures<AppRouter['_def']['queries']>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the key used for `useAsyncData` call
|
* Calculates the key used for `useAsyncData` call
|
||||||
* @param pathAndInput
|
* @param pathAndInput
|
||||||
*/
|
*/
|
||||||
export function getQueryKey<
|
export function getQueryKey<
|
||||||
TPath extends keyof TQueryValues & string
|
TPath extends keyof TQueryValues & string,
|
||||||
>(pathAndInput: [path: TPath, ...args: inferHandlerInput<TQueries[TPath]>]) {
|
>(pathAndInput: [path: TPath, ...args: inferHandlerInput<TQueries[TPath]>]) {
|
||||||
return `${pathAndInput[0]}-${objectHash(pathAndInput[1] ? JSON.stringify(pathAndInput[1]) : '')}`
|
return `${pathAndInput[0]}-${objectHash(pathAndInput[1] ? JSON.stringify(pathAndInput[1]) : '')}`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user