mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-31 10:58:04 +08:00
chore: minor changes
This commit is contained in:
parent
4badad88e1
commit
36739cf619
@ -20,7 +20,7 @@ export default defineEventHandler(async (event): Promise<SourceResponse> => {
|
||||
|
||||
const cacheTable = useCache()
|
||||
const now = Date.now()
|
||||
if (process.env.NODE_ENV === "production" && cacheTable) {
|
||||
if (cacheTable) {
|
||||
if (process.env.INIT_TABLE !== "false") await cacheTable.init()
|
||||
const cache = await cacheTable.get(id)
|
||||
if (cache) {
|
||||
|
@ -1,9 +1,10 @@
|
||||
import process from "node:process"
|
||||
import { Cache } from "#/database/cache"
|
||||
|
||||
export function useCache() {
|
||||
try {
|
||||
const db = useDatabase()
|
||||
if (db) return new Cache(db)
|
||||
if (db && process.env.NODE_ENV === "production") return new Cache(db)
|
||||
} catch (e) {
|
||||
logger.error("failed to init database ", e)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import { jwtVerify } from "jose"
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const url = getRequestURL(event)
|
||||
console.log(url.pathname)
|
||||
if (["JWT_SECRET", "G_CLIENT_ID", "G_CLIENT_SECRET"].find(k => !process.env[k])) {
|
||||
event.context.disabledLogin = true
|
||||
if (url.pathname.startsWith("/api/me")) throw createError({ statusCode: 506, message: "Server not configured" })
|
||||
|
Loading…
x
Reference in New Issue
Block a user