Skip to content

Commit 732c237

Browse files
committed
refac: rearrange files
1 parent 89e0332 commit 732c237

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+97
-90
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Cargo.lock
55
bin/
66
pkg/
77
wasm-pack.log
8-
worker/
98
node_modules/
109
.cargo-ok
1110

frontend/components/DecryptPaste.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Button, CircularProgress, Link, Tooltip } from "@heroui/react"
66
import { CheckIcon, CopyIcon, DownloadIcon, HomeIcon } from "./icons.js"
77

88
import "../style.css"
9-
import { parseFilenameFromContentDisposition, parsePath } from "../../src/shared.js"
9+
import { parseFilenameFromContentDisposition, parsePath } from "../../shared/parsers.js"
1010
import { formatSize } from "../utils/utils.js"
1111
import { DarkMode, DarkModeToggle, defaultDarkMode, shouldBeDark } from "./DarkModeToggle.js"
1212
import binaryExtensions from "binary-extensions"

frontend/components/PasteBin.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import React, { useEffect, useState } from "react"
22

33
import { Button, Link } from "@heroui/react"
44

5-
import { PasteResponse, parsePath, parseFilenameFromContentDisposition } from "../../src/shared.js"
5+
import { PasteResponse } from "../../shared/interfaces.js"
6+
import { parsePath, parseFilenameFromContentDisposition } from "../../shared/parsers.js"
67

78
import { DarkModeToggle, DarkMode, defaultDarkMode, shouldBeDark } from "./DarkModeToggle.js"
89
import { ErrorModal, ErrorState } from "./ErrorModal.js"

frontend/components/UploadedPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Card, CardBody, CardHeader, CardProps, Divider, Skeleton, Snippet } from "@heroui/react"
22
import React from "react"
3-
import { PasteResponse } from "../../src/shared.js"
3+
import { PasteResponse } from "../../shared/interfaces.js"
44

55
interface UploadedPanelProps extends CardProps {
66
pasteResponse: PasteResponse | null

frontend/test/crypto.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect } from "vitest"
22
import { encrypt, decrypt, genKey, encodeKey, decodeKey } from "../utils/encryption.js"
3-
import { genRandStr } from "../../src/common.js"
3+
import { genRandStr } from "../../worker/common.js"
44

55
function randArray(len: number): Uint8Array {
66
const arr = new Uint8Array(len)

frontend/test/index.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ afterAll(() => {
3535

3636
import "@testing-library/jest-dom/vitest"
3737
import { userEvent } from "@testing-library/user-event"
38-
import { PasteResponse } from "../../src/shared.js"
38+
import { PasteResponse } from "../../shared/interfaces.js"
3939
import { setupServer } from "msw/node"
4040
import { http, HttpResponse } from "msw"
4141

frontend/utils/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { NAME_REGEX, parseExpiration, parseExpirationReadable, PASSWD_SEP } from "../../src/shared.js"
1+
import { NAME_REGEX, PASSWD_SEP } from "../../shared/constants.js"
2+
import { parseExpiration, parseExpirationReadable } from "../../shared/parsers.js"
23

34
export const BaseUrl = DEPLOY_URL
45
export const APIUrl = API_URL

shared/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const CHAR_GEN = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678"
2+
export const NAME_REGEX = /^[a-zA-Z0-9+_\-[\]*$@,;]{3,}$/
3+
export const PASTE_NAME_LEN = 4
4+
export const PRIVATE_PASTE_NAME_LEN = 24
5+
export const DEFAULT_PASSWD_LEN = 24
6+
export const MAX_PASSWD_LEN = 128
7+
export const MIN_PASSWD_LEN = 8
8+
export const MAX_URL_REDIRECT_LEN = 2000
9+
export const PASSWD_SEP = ":"

shared/interfaces.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This file contains things shared with frontend
2+
3+
export type PasteLocation = "KV" | "R2"
4+
5+
export type PasteResponse = {
6+
url: string
7+
suggestedUrl?: string
8+
manageUrl: string
9+
expirationSeconds: number
10+
expireAt: string
11+
}
12+
13+
export type MetaResponse = {
14+
lastModifiedAt: string
15+
createdAt: string
16+
expireAt: string
17+
sizeBytes: number
18+
location: PasteLocation
19+
filename?: string
20+
encryptionScheme?: string
21+
}
22+
23+
export type MPUCreateResponse = {
24+
name: string
25+
key: string
26+
uploadId: string
27+
}

src/shared.ts renamed to shared/parsers.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
1-
// This file contains things shared with frontend
2-
3-
export type PasteLocation = "KV" | "R2"
4-
5-
export type PasteResponse = {
6-
url: string
7-
suggestedUrl?: string
8-
manageUrl: string
9-
expirationSeconds: number
10-
expireAt: string
11-
}
12-
13-
export type MetaResponse = {
14-
lastModifiedAt: string
15-
createdAt: string
16-
expireAt: string
17-
sizeBytes: number
18-
location: PasteLocation
19-
filename?: string
20-
encryptionScheme?: string
21-
}
22-
23-
export type MPUCreateResponse = {
24-
name: string
25-
key: string
26-
uploadId: string
27-
}
28-
29-
export const CHAR_GEN = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678"
30-
export const NAME_REGEX = /^[a-zA-Z0-9+_\-[\]*$@,;]{3,}$/
31-
export const PASTE_NAME_LEN = 4
32-
export const PRIVATE_PASTE_NAME_LEN = 24
33-
export const DEFAULT_PASSWD_LEN = 24
34-
export const MAX_PASSWD_LEN = 128
35-
export const MIN_PASSWD_LEN = 8
36-
export const MAX_URL_REDIRECT_LEN = 2000
37-
export const PASSWD_SEP = ":"
1+
import { PASSWD_SEP } from "./constants.js"
382

393
export function parseSize(sizeStr: string): number | null {
404
sizeStr = sizeStr.trim()

0 commit comments

Comments
 (0)