Skip to content

Commit

Permalink
refactor: disable middleware call
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Apr 25, 2024
1 parent 17113d0 commit 8c6dfea
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 277 deletions.
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { config } from 'dotenv'

import NextBundleAnalyzer from '@next/bundle-analyzer'

import pkg from './package.json' assert { type: 'json' }
import pkg from './package.json' with { type: 'json' }

process.title = 'Shiro (NextJS)'

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,6 @@
"object.values": "npm:@nolyfill/object.values@latest",
"string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@latest"
}
}
},
"packageManager": "pnpm@9.0.6+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3"
}
45 changes: 24 additions & 21 deletions src/app/(app)/notes/[id]/api.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import { cache } from 'react'
import { headers } from 'next/dist/client/components/headers'

import { REQUEST_QUERY } from '~/constants/system'
import { attachServerFetch, getAuthFromCookie } from '~/lib/attach-fetch'
import { getQueryClient } from '~/lib/query-client.server'
import { requestErrorHandler } from '~/lib/request.server'
import { queries } from '~/queries/definition'

export const getData = cache(async (params: { id: string }) => {
attachServerFetch()
export const getData = cache(
async (params: {
id: string

const header = headers()
const searchParams = new URLSearchParams(header.get(REQUEST_QUERY) || '')
const id = params.id
const token = searchParams.get('token')
const query = queries.note.byNid(
id,
searchParams.get('password') || undefined,
token ? `${token}` : undefined,
)
token?: string
password?: string
}) => {
attachServerFetch()

const data = await getQueryClient()
.fetchQuery({
...query,
staleTime: getAuthFromCookie() ? 0 : undefined,
})
.catch(requestErrorHandler)
return data
})
const { id, password, token } = params

const query = queries.note.byNid(
id,
password,
token ? `${token}` : undefined,
)

const data = await getQueryClient()
.fetchQuery({
...query,
staleTime: getAuthFromCookie() ? 0 : undefined,
})
.catch(requestErrorHandler)
return data
},
)
167 changes: 0 additions & 167 deletions src/app/(app)/notes/[id]/layout.tsx

This file was deleted.

Loading

0 comments on commit 8c6dfea

Please sign in to comment.