make route prefixes have a single place where they are defined (#3624)
This is for maintainabilty of the paths. It's hard to track down all the places where a route is being referenced. This helps unify them so that it's easily searchable in the codebase. This came up during the readonly room refactor and being able to find the way a particular route was wired through the codebase. ### Change Type <!-- ❗ Please select a 'Scope' label ❗️ --> - [x] `sdk` — Changes the tldraw SDK - [ ] `dotcom` — Changes the tldraw.com web app - [ ] `docs` — Changes to the documentation, examples, or templates. - [ ] `vs code` — Changes to the vscode plugin - [ ] `internal` — Does not affect user-facing stuff <!-- ❗ Please select a 'Type' label ❗️ --> - [ ] `bugfix` — Bug fix - [ ] `feature` — New feature - [ ] `improvement` — Improving existing features - [x] `chore` — Updating dependencies, other boring stuff - [ ] `galaxy brain` — Architectural changes - [ ] `tests` — Changes to any test code - [ ] `tools` — Changes to infrastructure, CI, internal scripts, debugging tools, etc. - [ ] `dunno` — I don't know
This commit is contained in:
parent
de55259c92
commit
c9af23c921
13 changed files with 85 additions and 35 deletions
|
@ -1,4 +1,12 @@
|
|||
export { ROOM_OPEN_MODE, RoomOpenModeToPath, type RoomOpenMode } from './routes'
|
||||
export {
|
||||
READ_ONLY_LEGACY_PREFIX,
|
||||
READ_ONLY_PREFIX,
|
||||
ROOM_OPEN_MODE,
|
||||
ROOM_PREFIX,
|
||||
RoomOpenModeToPath,
|
||||
SNAPSHOT_PREFIX,
|
||||
type RoomOpenMode,
|
||||
} from './routes'
|
||||
export type {
|
||||
CreateRoomRequestBody,
|
||||
CreateSnapshotRequestBody,
|
||||
|
|
|
@ -6,9 +6,18 @@ export const ROOM_OPEN_MODE = {
|
|||
} as const
|
||||
export type RoomOpenMode = (typeof ROOM_OPEN_MODE)[keyof typeof ROOM_OPEN_MODE]
|
||||
|
||||
/** @public */
|
||||
export const READ_ONLY_PREFIX = 'ro'
|
||||
/** @public */
|
||||
export const READ_ONLY_LEGACY_PREFIX = 'v'
|
||||
/** @public */
|
||||
export const ROOM_PREFIX = 'r'
|
||||
/** @public */
|
||||
export const SNAPSHOT_PREFIX = 's'
|
||||
|
||||
/** @public */
|
||||
export const RoomOpenModeToPath: Record<RoomOpenMode, string> = {
|
||||
[ROOM_OPEN_MODE.READ_ONLY]: 'ro',
|
||||
[ROOM_OPEN_MODE.READ_ONLY_LEGACY]: 'v',
|
||||
[ROOM_OPEN_MODE.READ_WRITE]: 'r',
|
||||
[ROOM_OPEN_MODE.READ_ONLY]: READ_ONLY_PREFIX,
|
||||
[ROOM_OPEN_MODE.READ_ONLY_LEGACY]: READ_ONLY_LEGACY_PREFIX,
|
||||
[ROOM_OPEN_MODE.READ_WRITE]: ROOM_PREFIX,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue