snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s

This commit is contained in:
upstream-mirror
2026-09-16 01:13:08 +05:00
commit 3a013ccdfe
3570 changed files with 490194 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
export interface Todo {
id: string
text: string
createdAt: number
}
export const todos: Array<Todo> = [
{
id: crypto.randomUUID(),
text: 'Buy groceries',
createdAt: Date.now() - 3000,
},
{
id: crypto.randomUUID(),
text: 'Walk the dog',
createdAt: Date.now() - 2000,
},
{
id: crypto.randomUUID(),
text: 'Read a book',
createdAt: Date.now() - 1000,
},
]
export async function getTodos(): Promise<Array<Todo>> {
await new Promise((resolve) => setTimeout(resolve, 200))
return todos
}

View File

@@ -0,0 +1,46 @@
import { NextResponse } from 'next/server'
import { todos, getTodos, type Todo } from './data'
export async function GET() {
return NextResponse.json(await getTodos())
}
export async function POST(request: Request) {
let body: unknown
try {
body = await request.json()
} catch {
return NextResponse.json({ error: 'text is required' }, { status: 400 })
}
const text =
body !== null &&
typeof body === 'object' &&
'text' in body &&
typeof (body as { text: unknown }).text === 'string'
? (body as { text: string }).text.trim()
: ''
if (!text) {
return NextResponse.json({ error: 'text is required' }, { status: 400 })
}
await new Promise((resolve) => setTimeout(resolve, 500))
if (Math.random() < 0.3) {
return NextResponse.json(
{ error: 'Server error — please try again' },
{ status: 500 },
)
}
const newTodo: Todo = {
id: crypto.randomUUID(),
text,
createdAt: Date.now(),
}
todos.push(newTodo)
return NextResponse.json(newTodo, { status: 201 })
}