update
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
import { Meilisearch, type SearchResponse } from 'meilisearch'
|
||||
|
||||
const MAX_HITS_PER_PAGE = 100
|
||||
|
||||
export async function createSearch({
|
||||
query,
|
||||
filter = undefined,
|
||||
index,
|
||||
page,
|
||||
hitsPerPage,
|
||||
sort,
|
||||
env
|
||||
}: {
|
||||
query?: string
|
||||
filter?: string
|
||||
index: string
|
||||
page?: number
|
||||
hitsPerPage: number
|
||||
sort: string[]
|
||||
env: Env
|
||||
}): Promise<SearchResponse> {
|
||||
@@ -21,6 +27,8 @@ export async function createSearch({
|
||||
return index_.search(query, {
|
||||
sort,
|
||||
filter,
|
||||
limit: 100
|
||||
page,
|
||||
hitsPerPage:
|
||||
hitsPerPage > MAX_HITS_PER_PAGE ? MAX_HITS_PER_PAGE : hitsPerPage
|
||||
})
|
||||
}
|
||||
|
||||
@@ -31,9 +31,15 @@ export function request({
|
||||
const requestId = context.get(requestIdContext) as string
|
||||
const user = context.get(userContext) as User
|
||||
const url_ = new URL(url, context.cloudflare.env.API_URL)
|
||||
const headers = new Headers(
|
||||
Object.assign({ Authorization: `Bearer ${user.accessToken}` }, _headers)
|
||||
)
|
||||
const headers = new Headers({
|
||||
Authorization: `Bearer ${user.accessToken}`
|
||||
})
|
||||
|
||||
if (_headers instanceof Headers) {
|
||||
_headers.forEach((value, key) => headers.set(key, value))
|
||||
} else {
|
||||
Object.entries(_headers).forEach(([key, value]) => headers.set(key, value))
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[${new Date().toISOString()}] [${requestId}] ${method} ${url_.toString()}`
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { clsx, type ClassValue } from 'clsx'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
export function initials(s: string): string {
|
||||
const initials = s
|
||||
.split(' ')
|
||||
.map((word) => word.charAt(0).toUpperCase()) as string[]
|
||||
|
||||
if (initials.length == 0) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const first = initials[0]
|
||||
const last = initials[initials.length - 1]
|
||||
return first + last
|
||||
}
|
||||
@@ -138,7 +138,10 @@ function Course({ id, name, access_period, cert, draft }: Course) {
|
||||
|
||||
<CardHeader className="z-1 relative">
|
||||
<CardTitle className="text-xl/6">
|
||||
{name} {draft ? <>(rascunho)</> : null}
|
||||
{name}{' '}
|
||||
{draft ? (
|
||||
<span className="text-muted-foreground">(rascunho)</span>
|
||||
) : null}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user