Skip to content

Commit

Permalink
chore: cleanup constants and configs for worker
Browse files Browse the repository at this point in the history
  • Loading branch information
dallen4 committed Dec 16, 2024
1 parent bf50a62 commit 0e5d6fd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
9 changes: 9 additions & 0 deletions worker/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export enum AppRouteParts {
// peerjs
PeerJsRoot = '/peerjs',
GenerateId = `/id`,

// vaults
VaultRoot = '/vault',
NameParam = '/:name',
Share = '/:name/share',
}

export enum AppRoutes {
Expand All @@ -35,4 +40,8 @@ export enum AppRoutes {
// peerjs paths
PeerJsRoot = AppRouteParts.PeerJsRoot,
PeerJsGenerateId = `${AppRouteParts.PeerJsRoot}${AppRouteParts.GenerateId}`,

// vault paths
VaultRoot = AppRouteParts.VaultRoot,
ShareVault = `${AppRouteParts.VaultRoot}${AppRouteParts.NameParam}${AppRouteParts.Share}`,
}
8 changes: 4 additions & 4 deletions worker/src/routers/drop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getCookie } from 'hono/cookie';
import { DropDetails } from '@shared/types/common';
import { AppRoutes } from '../constants';
import { AppRouteParts } from '../constants';
import { hono } from '../lib/http/core';
import { formatDropKey } from '@shared/lib/util';
import { DISABLE_CAPTCHA_COOKIE } from '@shared/config/http';
Expand All @@ -13,7 +13,7 @@ const dropIdSchema = z.object({ id: z.string() });

const dropRouter = hono()
.post(
AppRoutes.Root,
AppRouteParts.Root,
zValidator('json', dropIdSchema),
async (c) => {
const ipAddress = c.get('ipAddress');
Expand Down Expand Up @@ -52,7 +52,7 @@ const dropRouter = hono()
},
)
.get(
AppRoutes.Root,
AppRouteParts.Root,
zValidator('query', dropIdSchema),
async (c) => {
const { id: dropId } = c.req.valid('query');
Expand All @@ -71,7 +71,7 @@ const dropRouter = hono()
},
)
.delete(
AppRoutes.Root,
AppRouteParts.Root,
zValidator('json', dropIdSchema),
async (c) => {
const { id: dropId } = c.req.valid('json');
Expand Down
3 changes: 3 additions & 0 deletions worker/worker-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ interface Env {

UPSTASH_REDIS_REST_URL: string;
UPSTASH_REDIS_REST_TOKEN: string;

TURSO_ORGANIZATION: string;
TURSO_PLATFORM_API_TOKEN: string;
}
1 change: 1 addition & 0 deletions worker/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ routes = [

[vars]
DAILY_DROP_LIMIT = 5
TURSO_ORGANIZATION = "dallen4"

# ref: https://developers.cloudflare.com/workers/runtime-apis/kv
[[kv_namespaces]]
Expand Down

0 comments on commit 0e5d6fd

Please sign in to comment.