Skip to content

Commit 79f00bc

Browse files
clean code
1 parent b2ef589 commit 79f00bc

File tree

12 files changed

+5
-24
lines changed

12 files changed

+5
-24
lines changed

server/api/admin/blog/post-details/[slug].post.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ export default defineEventHandler(async (req) => {
1717
const httpBody = await readBody(req)
1818
const { title, image, tags, body } = httpBody
1919

20-
console.log('slug', slug)
21-
console.log('body', body)
22-
2320
validateBody(body)
2421
insertOrUpdatePost(slug, title, image, tags || [], body)
2522

server/api/admin/image/upload.post.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ export default defineEventHandler(async (event) => {
2929
.join('.')
3030
.replace(/[^a-zA-Z0-9]/g, '-')
3131

32+
const format = array.pop()
33+
3234
const fileSuffix = generateSessionId(6).toLowerCase()
33-
const fileKey = `${fileName}-${fileSuffix}`.toLowerCase()
35+
const fileKey = `${fileName}-${fileSuffix}.${format}`.toLowerCase()
3436

3537
const buffer = Buffer.from(file.data)
3638

server/api/blog/post-details/[slug].get.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { db } from '~/server/utils/mongo'
33
import { getFullCocktailBySlug } from '~/server/utils/cocktail/details'
44
import { getCocktailsBySlugs } from '~~/server/utils/cocktail/list'
55

6-
const imageDomain = useRuntimeConfig().public.imageDomain
7-
86
async function getBlogPost(slug) {
97
return db.collection('blog').findOne({ slug: slug })
108
}

server/api/blog/post-list.get.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { defineEventHandler } from 'h3'
22
import { db } from '~/server/utils/mongo'
33

4-
const imageDomain = useRuntimeConfig().public.imageDomain
54

65
async function getAllPostList() {
76
return db

server/api/glassware/[slug].get.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { defineEventHandler } from 'h3'
22
import { db } from '~/server/utils/mongo'
33

4-
const imageDomain = useRuntimeConfig().public.imageDomain
5-
64
const formats = ['webp', 'jpg']
75

86
const buildOgImage = (slug) => {

server/api/goods/[slug].get.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { defineEventHandler } from 'h3'
22
import { db } from '~/server/utils/mongo'
33

4-
const imageDomain = useRuntimeConfig().public.imageDomain
5-
64
const formats = ['webp', 'jpg']
75

86
const buildOgImage = (slug) => {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { getBlogImageBucket } from '~/server/utils/mongo'
22

33
export default defineEventHandler(async (event) => {
4-
const slug = event.context.params.slug
4+
const name = event.context.params.name
55

66
const bucket = await getBlogImageBucket()
7-
const readStream = bucket.openDownloadStreamByName(slug)
7+
const readStream = bucket.openDownloadStreamByName(name)
88

99
setResponseHeaders(event, {
1010
'Content-Type': 'image/jpeg',

server/api/tools/[slug].get.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { defineEventHandler } from 'h3'
22
import { db } from '~/server/utils/mongo'
33

4-
const imageDomain = useRuntimeConfig().public.imageDomain
5-
64
const formats = ['webp', 'jpg']
75

86
const buildOgImage = (slug) => {

server/utils/cocktail/details.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { db } from '~/server/utils/mongo'
22

3-
const imageDomain = useRuntimeConfig().public.imageDomain
4-
53
const formats = ['webp', 'jpg']
64

75
const buildOgImage = (slug) => {

server/utils/cocktail/list.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { db } from '~/server/utils/mongo'
22

3-
const imageDomain = useRuntimeConfig().imageDomain
4-
53
const formats = ['webp', 'jpg']
64

75
const buildCocktailInListImage = (slug) => {

0 commit comments

Comments
 (0)