mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 11:19:14 +08:00
chore!: bump up vite-plugin-with-nitro
This commit is contained in:
parent
9aed36201a
commit
ff79054692
10
package.json
10
package.json
@ -32,12 +32,13 @@
|
|||||||
"@tanstack/react-router": "^1.64.0",
|
"@tanstack/react-router": "^1.64.0",
|
||||||
"@tsndr/cloudflare-worker-jwt": "^3.1.2",
|
"@tsndr/cloudflare-worker-jwt": "^3.1.2",
|
||||||
"@unocss/reset": "^0.63.4",
|
"@unocss/reset": "^0.63.4",
|
||||||
|
"better-sqlite3": "^11.3.0",
|
||||||
"cheerio": "^1.0.0",
|
"cheerio": "^1.0.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"consola": "^3.2.3",
|
"consola": "^3.2.3",
|
||||||
"cookie-es": "^1.2.2",
|
"cookie-es": "^1.2.2",
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "1.11.13",
|
||||||
"db0": "npm:@ourongxing/db0@0.1.6",
|
"db0": "^0.2.1",
|
||||||
"defu": "^6.1.4",
|
"defu": "^6.1.4",
|
||||||
"fast-xml-parser": "^4.5.0",
|
"fast-xml-parser": "^4.5.0",
|
||||||
"framer-motion": "^11.11.8",
|
"framer-motion": "^11.11.8",
|
||||||
@ -46,7 +47,6 @@
|
|||||||
"jose": "^5.9.4",
|
"jose": "^5.9.4",
|
||||||
"jotai": "^2.10.0",
|
"jotai": "^2.10.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"libsql": "^0.4.6",
|
|
||||||
"md5": "^2.3.0",
|
"md5": "^2.3.0",
|
||||||
"ofetch": "^1.4.1",
|
"ofetch": "^1.4.1",
|
||||||
"overlayscrollbars": "^2.10.0",
|
"overlayscrollbars": "^2.10.0",
|
||||||
@ -79,7 +79,6 @@
|
|||||||
"lint-staged": "^15.2.10",
|
"lint-staged": "^15.2.10",
|
||||||
"mlly": "^1.7.2",
|
"mlly": "^1.7.2",
|
||||||
"mockdate": "^3.0.5",
|
"mockdate": "^3.0.5",
|
||||||
"nitropack": "^2.9.7",
|
|
||||||
"simple-git-hooks": "^2.11.1",
|
"simple-git-hooks": "^2.11.1",
|
||||||
"tsx": "^4.19.1",
|
"tsx": "^4.19.1",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.6.3",
|
||||||
@ -87,7 +86,7 @@
|
|||||||
"unocss": "^0.63.4",
|
"unocss": "^0.63.4",
|
||||||
"unplugin-auto-import": "^0.18.3",
|
"unplugin-auto-import": "^0.18.3",
|
||||||
"vite": "^5.4.8",
|
"vite": "^5.4.8",
|
||||||
"vite-plugin-with-nitro": "0.0.0-beta.7",
|
"vite-plugin-with-nitro": "0.0.2",
|
||||||
"vite-tsconfig-paths": "^5.0.1",
|
"vite-tsconfig-paths": "^5.0.1",
|
||||||
"vitest": "^2.1.2",
|
"vitest": "^2.1.2",
|
||||||
"wrangler": "^3.80.3"
|
"wrangler": "^3.80.3"
|
||||||
@ -99,8 +98,7 @@
|
|||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "1.11.13",
|
||||||
"db0": "npm:@ourongxing/db0@0.1.6",
|
"picomatch": "^4.0.0"
|
||||||
"nitropack": "^2.9.7"
|
|
||||||
},
|
},
|
||||||
"simple-git-hooks": {
|
"simple-git-hooks": {
|
||||||
"pre-commit": "npx lint-staged"
|
"pre-commit": "npx lint-staged"
|
||||||
|
1622
pnpm-lock.yaml
generated
1622
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@ import { TTL } from "@shared/consts"
|
|||||||
import type { SourceID, SourceResponse } from "@shared/types"
|
import type { SourceID, SourceResponse } from "@shared/types"
|
||||||
import { sources } from "@shared/sources"
|
import { sources } from "@shared/sources"
|
||||||
import { sourcesFn } from "#/sources"
|
import { sourcesFn } from "#/sources"
|
||||||
import { Cache } from "#/database/cache"
|
import { useCache } from "#/hooks/useCache"
|
||||||
|
|
||||||
export default defineEventHandler(async (event): Promise<SourceResponse> => {
|
export default defineEventHandler(async (event): Promise<SourceResponse> => {
|
||||||
try {
|
try {
|
||||||
@ -18,8 +18,7 @@ export default defineEventHandler(async (event): Promise<SourceResponse> => {
|
|||||||
if (isValid(id)) throw new Error("Invalid source id")
|
if (isValid(id)) throw new Error("Invalid source id")
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = useDatabase()
|
const cacheTable = useCache()
|
||||||
const cacheTable = db ? new Cache(db) : undefined
|
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
if (cacheTable) {
|
if (cacheTable) {
|
||||||
if (process.env.INIT_TABLE !== "false") await cacheTable.init()
|
if (process.env.INIT_TABLE !== "false") await cacheTable.init()
|
||||||
@ -59,7 +58,10 @@ export default defineEventHandler(async (event): Promise<SourceResponse> => {
|
|||||||
|
|
||||||
const data = await sourcesFn[id]()
|
const data = await sourcesFn[id]()
|
||||||
logger.success(`fetch ${id} latest`)
|
logger.success(`fetch ${id} latest`)
|
||||||
if (cacheTable) event.waitUntil(cacheTable.set(id, data))
|
if (cacheTable) {
|
||||||
|
if (event.context.waitUntil) event.context.waitUntil(cacheTable.set(id, data))
|
||||||
|
else await cacheTable.set(id, data)
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
status: "success",
|
status: "success",
|
||||||
updatedTime: now,
|
updatedTime: now,
|
10
server/hooks/useCache.ts
Normal file
10
server/hooks/useCache.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Cache } from "#/database/cache"
|
||||||
|
|
||||||
|
export function useCache() {
|
||||||
|
try {
|
||||||
|
const db = useDatabase()
|
||||||
|
if (db) return new Cache(db)
|
||||||
|
} catch (e) {
|
||||||
|
logger.error("failed to init database ", e)
|
||||||
|
}
|
||||||
|
}
|
@ -3,11 +3,12 @@ import { jwtVerify } from "jose"
|
|||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const url = getRequestURL(event)
|
const url = getRequestURL(event)
|
||||||
|
console.log(url.pathname)
|
||||||
if (["JWT_SECRET", "G_CLIENT_ID", "G_CLIENT_SECRET"].find(k => !process.env[k])) {
|
if (["JWT_SECRET", "G_CLIENT_ID", "G_CLIENT_SECRET"].find(k => !process.env[k])) {
|
||||||
event.context.disabledLogin = true
|
event.context.disabledLogin = true
|
||||||
if (url.pathname.startsWith("/me")) throw createError({ statusCode: 506, message: "Server not configured" })
|
if (url.pathname.startsWith("/me")) throw createError({ statusCode: 506, message: "Server not configured" })
|
||||||
} else {
|
} else {
|
||||||
if (/^\/(?:me|s)\//.test(url.pathname)) {
|
if (/^\/api\/(?:me|s)\//.test(url.pathname)) {
|
||||||
const token = getHeader(event, "Authorization")
|
const token = getHeader(event, "Authorization")
|
||||||
if (token && process.env.JWT_SECRET) {
|
if (token && process.env.JWT_SECRET) {
|
||||||
try {
|
try {
|
||||||
|
11
vercel.json
11
vercel.json
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"rewrites": [
|
|
||||||
{
|
|
||||||
"source": "/:path((?!api).*)",
|
|
||||||
"destination": "/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"github": {
|
|
||||||
"silent": true
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user