Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/api/src/routes/v1_files/$wildcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { HonoEnv } from "../../types";
import { createRoute, z } from "@hono/zod-openapi";
import { dedent } from "@luxass/utils";
import { createGlobMatcher, isValidGlobPattern } from "@ucdjs-internal/shared";
import { DEFAULT_USER_AGENT, UCD_FILE_STAT_TYPE_HEADER } from "@ucdjs/env";
import { DEFAULT_USER_AGENT, UCD_STAT_TYPE_HEADER } from "@ucdjs/env";
import { FileEntryListSchema } from "@ucdjs/schemas";
import { cache } from "hono/cache";
import { HTML_EXTENSIONS, MAX_AGE_ONE_WEEK_SECONDS } from "../../constants";
Expand Down Expand Up @@ -123,7 +123,7 @@ export const WILDCARD_ROUTE = createRoute({
200: {
description: "Response from Unicode.org",
headers: {
[UCD_FILE_STAT_TYPE_HEADER]: {
[UCD_STAT_TYPE_HEADER]: {
description: "The type of the file or directory",
schema: {
type: "string",
Expand Down Expand Up @@ -228,7 +228,7 @@ export const METADATA_WILDCARD_ROUTE = createRoute({
200: {
description: "Response from Unicode.org",
headers: {
[UCD_FILE_STAT_TYPE_HEADER]: {
[UCD_STAT_TYPE_HEADER]: {
description: "The type of the file or directory",
schema: {
type: "string",
Expand Down Expand Up @@ -344,7 +344,7 @@ export function registerWildcardRoute(router: OpenAPIHono<HonoEnv>) {
...baseHeaders,

// Custom STAT Headers
[UCD_FILE_STAT_TYPE_HEADER]: "directory",
[UCD_STAT_TYPE_HEADER]: "directory",
});
}

Expand All @@ -359,7 +359,7 @@ export function registerWildcardRoute(router: OpenAPIHono<HonoEnv>) {
...baseHeaders,

// Custom STAT Headers
[UCD_FILE_STAT_TYPE_HEADER]: "file",
[UCD_STAT_TYPE_HEADER]: "file",
};

const cd = response.headers.get("Content-Disposition");
Expand Down
4 changes: 2 additions & 2 deletions apps/api/test/routes/v1_files/$wildcard.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpResponse, mockFetch, RawResponse } from "#test-utils/msw";
import { UCD_FILE_STAT_TYPE_HEADER } from "@ucdjs/env";
import { UCD_STAT_TYPE_HEADER } from "@ucdjs/env";
import { generateAutoIndexHtml } from "apache-autoindex-parse/test-utils";
import { env } from "cloudflare:workers";
import { describe, expect, it } from "vitest";
Expand Down Expand Up @@ -475,7 +475,7 @@ describe("v1_files", () => {
expectSuccess(response);
expectContentType(response, "application/json");
expectCacheHeaders(response);
expect(response.headers.get(UCD_FILE_STAT_TYPE_HEADER)).toBe("directory");
expect(response.headers.get(UCD_STAT_TYPE_HEADER)).toBe("directory");
expect(response.headers.get("content-length")).toBeDefined();
expect(response.headers.get("last-modified")).toBeDefined();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cmd/files/info.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CLIArguments } from "../../cli-utils";
import type { CLIFilesCmdOptions } from "./root";
import { customFetch } from "@ucdjs-internal/shared";
import { UCD_FILE_STAT_TYPE_HEADER, UCDJS_API_BASE_URL } from "@ucdjs/env";
import { UCD_STAT_TYPE_HEADER, UCDJS_API_BASE_URL } from "@ucdjs/env";
import { bold, dim, green, red } from "farver/fast";
import { printHelp } from "../../cli-utils";
import { output } from "../../output";
Expand Down Expand Up @@ -95,7 +95,7 @@ export async function runFilesInfo({ path, flags }: CLIFilesInfoCmdOptions) {
const headers = result.response.headers;
const metadata: FileMetadata = {
path: path || "",
type: (headers.get(UCD_FILE_STAT_TYPE_HEADER) as "file" | "directory") || "file",
type: (headers.get(UCD_STAT_TYPE_HEADER) as "file" | "directory") || "file",
contentType: headers.get("Content-Type") || undefined,
lastModified: headers.get("Last-Modified") || undefined,
contentLength: headers.get("Content-Length") || undefined,
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/test/cmd/files/info.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ConsoleOutputCapture } from "../../__test-utils";
import { mockStoreApi } from "#test-utils/mock-store";
import { HttpResponse } from "#test-utils/msw";
import { UCD_FILE_STAT_TYPE_HEADER } from "@ucdjs/env";
import { UCD_STAT_TYPE_HEADER } from "@ucdjs/env";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { runCLI } from "../../../src/cli-utils";
import { captureConsoleOutput } from "../../__test-utils";
Expand Down Expand Up @@ -32,7 +32,7 @@ describe("files info command", () => {
return new HttpResponse(null, {
status: 200,
headers: {
[UCD_FILE_STAT_TYPE_HEADER]: "file",
[UCD_STAT_TYPE_HEADER]: "file",
"Content-Type": "text/plain",
"Last-Modified": "Wed, 18 Sep 2024 12:00:00 GMT",
"Content-Length": "12345",
Expand All @@ -56,7 +56,7 @@ describe("files info command", () => {
return new HttpResponse(null, {
status: 200,
headers: {
[UCD_FILE_STAT_TYPE_HEADER]: "directory",
[UCD_STAT_TYPE_HEADER]: "directory",
"Content-Type": "application/json",
"Last-Modified": "Wed, 18 Sep 2024 12:00:00 GMT",
},
Expand All @@ -78,7 +78,7 @@ describe("files info command", () => {
return new HttpResponse(null, {
status: 200,
headers: {
[UCD_FILE_STAT_TYPE_HEADER]: "file",
[UCD_STAT_TYPE_HEADER]: "file",
"Content-Type": "text/plain",
"Last-Modified": "Wed, 18 Sep 2024 12:00:00 GMT",
"Content-Length": "12345",
Expand Down Expand Up @@ -123,7 +123,7 @@ describe("files info command", () => {
return new HttpResponse(null, {
status: 200,
headers: {
[UCD_FILE_STAT_TYPE_HEADER]: "directory",
[UCD_STAT_TYPE_HEADER]: "directory",
"Content-Type": "application/json",
},
});
Expand Down
11 changes: 8 additions & 3 deletions packages/env/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
*
* @example
* ```typescript
* import { UCD_FILE_STAT_TYPE_HEADER } from "@ucdjs/env";
* import { UCD_STAT_TYPE_HEADER, UCD_STAT_SIZE_HEADER } from "@ucdjs/env";
*
* headers[UCD_FILE_STAT_TYPE_HEADER] = "file";
* headers[UCD_STAT_TYPE_HEADER] = "file";
* headers[UCD_STAT_SIZE_HEADER] = "1024";
* ```
*/

export const UCD_FILE_STAT_TYPE_HEADER = "UCD-File-Stat-Type";
export const UCD_STAT_TYPE_HEADER = "X-UCD-Stat-Type";
export const UCD_STAT_SIZE_HEADER = "X-UCD-Stat-Size";
export const UCD_STAT_CHILDREN_HEADER = "X-UCD-Stat-Children";
export const UCD_STAT_CHILDREN_FILES_HEADER = "X-UCD-Stat-Children-Files";
export const UCD_STAT_CHILDREN_DIRS_HEADER = "X-UCD-Stat-Children-Dirs";
9 changes: 8 additions & 1 deletion packages/env/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export { UCD_FILE_STAT_TYPE_HEADER } from "./constants";
export {
UCD_STAT_CHILDREN_DIRS_HEADER,
UCD_STAT_CHILDREN_FILES_HEADER,
UCD_STAT_CHILDREN_HEADER,
UCD_STAT_SIZE_HEADER,
UCD_STAT_TYPE_HEADER,
} from "./constants";

export { DEFAULT_USER_AGENT, UCDJS_API_BASE_URL } from "./env-constants";
export { requiredEnv } from "./required-env";
Loading