Skip to content

Commit

Permalink
fix(nuxt3): store image
Browse files Browse the repository at this point in the history
  • Loading branch information
LarchLiu committed May 18, 2023
1 parent a7cfc8a commit f229392
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions server/nuxt3/server/api/webcard.post.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// server/api/webcard.ts

import { errorMessage, storageInfo } from '@starnexus/core'
import type { IDataStorage, IImageStorage, SavedImage, TStorage, WebInfoData } from '@starnexus/core'
import type { IDataStorage, IImageStorage, TStorage, WebInfoData } from '@starnexus/core'

export default eventHandler(async (event) => {
try {
Expand All @@ -13,15 +13,15 @@ export default eventHandler(async (event) => {
dataCfg,
savedData,
} = await readBody(event)
let imgRes: SavedImage
// let imgRes: SavedImage
const imgStorage = new (storageInfo[imgType.type as TStorage][imgType.name])(imgCfg) as IImageStorage
const dataStorage = new (storageInfo[dataType.type as TStorage][dataType.name])(dataCfg) as IDataStorage
const res = await createWebCard(webData as WebInfoData)
const imgQuery = await imgStorage.query(res.imgPath)
if (imgQuery.url)
imgRes = await imgStorage.update(res)
else
imgRes = await imgStorage.create(res)
// const imgQuery = await imgStorage.query(res.imgPath)
// if (imgQuery.url)
// imgRes = await imgStorage.update(res)
// else
const imgRes = await imgStorage.create(res)

const updateRes = await dataStorage.updateOgImage(savedData, imgRes.url)
return updateRes
Expand Down
2 changes: 1 addition & 1 deletion server/nuxt3/server/plugins/loadFonts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default defineNitroPlugin(async (nitroApp) => {
export default defineNitroPlugin(async (_nitroApp) => {
await initBasicFonts()
})
2 changes: 1 addition & 1 deletion server/nuxt3/server/plugins/tgBot.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default defineNitroPlugin(async (nitroApp) => {
export default defineNitroPlugin(async (_nitroApp) => {
await initEnv()
})

1 comment on commit f229392

@vercel
Copy link

@vercel vercel bot commented on f229392 May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

star-nexus – ./

star-nexus-larchliu.vercel.app
star-nexus-git-main-larchliu.vercel.app
star-nexus.vercel.app

Please sign in to comment.