Skip to content

Commit 631c5e1

Browse files
committed
refactor(server): refactor structure and implement to Hono framework
- Updated cache utility to use new type definitions from hono-types. - Added TestCacheImpl for testing purposes, providing a simple in-memory cache implementation. - Removed outdated integration tests and replaced them with a more modular test setup using Hono. - Created a new Hono app factory to initialize the application with middleware and services. - Introduced middleware for lazy initialization of dependencies, JWT handling, and request timing. - Defined types for Hono context and variables to improve type safety across the application. - Implemented error handling and 404 responses in the Hono app. - Updated test API client to align with the new Hono structure and provide type-safe API calls.
1 parent ac0d6c7 commit 631c5e1

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

server/src/utils/s3.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AwsClient } from "aws4fetch";
2+
import { path_join } from "./path";
23

34
export function createS3Client(env: Env): AwsClient {
45
const accessKeyId = env.S3_ACCESS_KEY_ID;
@@ -20,7 +21,17 @@ export async function putObject(
2021
) {
2122
const endpoint = env.S3_ENDPOINT;
2223
const bucket = env.S3_BUCKET;
23-
const url = `${endpoint}/${bucket}/${key}`;
24+
const forcePathStyle = env.S3_FORCE_PATH_STYLE === 'true';
25+
26+
// Construct URL based on path-style or virtual-hosted style
27+
let url: string;
28+
if (forcePathStyle) {
29+
url = path_join(endpoint, bucket, key);
30+
} else {
31+
// Virtual-hosted style: https://bucket.endpoint/key
32+
const urlObj = new URL(endpoint);
33+
url = `${urlObj.protocol}//${bucket}.${urlObj.host}/${key}`;
34+
}
2435

2536
const headers: Record<string, string> = {};
2637
if (contentType) {

0 commit comments

Comments
 (0)