chore: minor changes

This commit is contained in:
Ou 2024-10-23 03:11:20 +08:00
parent 4badad88e1
commit 36739cf619
3 changed files with 3 additions and 3 deletions

View File

@ -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) {

View File

@ -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)
}

View File

@ -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" })