diff options
| author | 2023-04-19 17:30:39 +0800 | |
|---|---|---|
| committer | 2023-04-19 17:30:39 +0800 | |
| commit | 3adc965dd09490b7efa1cce9f09b0a3b30970277 (patch) | |
| tree | f813abb07d7b003984aa74e3154752b6ffc3ccd5 /envshare/pages/api/v1/store.ts | |
| parent | c7c9ca6f0c8eddf6d34cd40779f3b2d9463f3a46 (diff) | |
| download | HydroRoll-3adc965dd09490b7efa1cce9f09b0a3b30970277.tar.gz HydroRoll-3adc965dd09490b7efa1cce9f09b0a3b30970277.zip | |
✨优化文档
Diffstat (limited to 'envshare/pages/api/v1/store.ts')
| -rw-r--r-- | envshare/pages/api/v1/store.ts | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/envshare/pages/api/v1/store.ts b/envshare/pages/api/v1/store.ts deleted file mode 100644 index c35e9b4..0000000 --- a/envshare/pages/api/v1/store.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; -import { Redis } from "@upstash/redis"; -import { generateId } from "pkg/id"; - -type Request = { - encrypted: string; - ttl?: number; - reads: number; - iv: string; -}; - -const redis = Redis.fromEnv(); -export default async function handler(req: NextRequest) { - const { encrypted, ttl, reads, iv } = (await req.json()) as Request; - - const id = generateId(); - const key = ["envshare", id].join(":"); - - const tx = redis.multi(); - - tx.hset(key, { - remainingReads: reads > 0 ? reads : null, - encrypted, - iv, - }); - if (ttl) { - tx.expire(key, ttl); - } - tx.incr("envshare:metrics:writes"); - - await tx.exec(); - - return NextResponse.json({ id }); -} - -export const config = { - runtime: "edge", -}; |
