@@ -2,16 +2,13 @@ import { Hono } from 'hono'
22import { validator } from 'hono/validator'
33import { isNil , isNotNil , isNumberString } from '@web-archive/shared/utils'
44import { z } from 'zod'
5- import { GetObjectCommand } from '@aws-sdk/client-s3'
65import type { HonoTypeUserInformation } from '~/constants/binding'
76import result from '~/utils/result'
87import { clearDeletedPage , deletePageById , getPageById , insertPage , queryAllPageIds , queryDeletedPage , queryPage , queryPageByUrl , queryRecentSavePage , restorePage , selectPageTotalCount , updatePage } from '~/model/page'
98import { getFolderById , restoreFolder } from '~/model/folder'
109import { getFileFromBucket , saveFileToBucket } from '~/utils/file'
1110import { updateShowcase } from '~/model/showcase'
1211import { updateBindPageByTagName } from '~/model/tag'
13- import type { TagBindRecord } from '~/model/tag'
14- import { S3_BUCKET_NAME } from '~/constants/config'
1512
1613const app = new Hono < HonoTypeUserInformation > ( )
1714
@@ -85,11 +82,7 @@ app.post(
8582 isShowcased,
8683 } )
8784 if ( isNotNil ( insertId ) ) {
88- const updateTagResult = await updateBindPageByTagName (
89- c . env . DB ,
90- bindTags . map ( tagName => ( { tagName, pageIds : [ Number ( insertId ) ] } ) ) ,
91- [ ] ,
92- )
85+ const updateTagResult = await updateBindPageByTagName ( c . env . DB , bindTags . map ( tagName => ( { tagName, pageIds : [ insertId ] } ) ) , [ ] )
9386 if ( updateTagResult )
9487 return c . json ( result . success ( null ) )
9588 }
@@ -375,18 +368,14 @@ app.get(
375368 return c . json ( result . error ( 500 , 'Page not found' ) )
376369 }
377370
378- const command = new GetObjectCommand ( {
379- Bucket : S3_BUCKET_NAME ,
380- Key : page . contentUrl ,
381- } )
382- const content = await c . env . BUCKET . send ( command )
383- if ( ! content . Body ) {
371+ const content = await c . env . BUCKET . get ( page . contentUrl )
372+ if ( ! content ) {
384373 return c . json ( result . error ( 500 , 'Page data not found' ) )
385374 }
386375
387376 c . res . headers . set ( 'cache-control' , 'private, max-age=604800' )
388377 return c . html (
389- await content . Body . transformToString ( ) ,
378+ await content . text ( ) ,
390379 )
391380 } ,
392381)
0 commit comments