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 cacheTable = useCache()
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
if (process.env.NODE_ENV === "production" && cacheTable) {
|
if (cacheTable) {
|
||||||
if (process.env.INIT_TABLE !== "false") await cacheTable.init()
|
if (process.env.INIT_TABLE !== "false") await cacheTable.init()
|
||||||
const cache = await cacheTable.get(id)
|
const cache = await cacheTable.get(id)
|
||||||
if (cache) {
|
if (cache) {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
import process from "node:process"
|
||||||
import { Cache } from "#/database/cache"
|
import { Cache } from "#/database/cache"
|
||||||
|
|
||||||
export function useCache() {
|
export function useCache() {
|
||||||
try {
|
try {
|
||||||
const db = useDatabase()
|
const db = useDatabase()
|
||||||
if (db) return new Cache(db)
|
if (db && process.env.NODE_ENV === "production") return new Cache(db)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error("failed to init database ", e)
|
logger.error("failed to init database ", e)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ 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("/api/me")) throw createError({ statusCode: 506, message: "Server not configured" })
|
if (url.pathname.startsWith("/api/me")) throw createError({ statusCode: 506, message: "Server not configured" })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user