-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BC-7960 - Move config api to tldraw server (#105)
- Loading branch information
1 parent
a58ee01
commit dba0f3f
Showing
12 changed files
with
142 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,49 @@ | ||
// remove this code by BC-7906 | ||
// set CONFIG_PATH to /api/tldraw/config/public | ||
// remove line 7 and 8 in ngnix.conf.template | ||
import { HttpStatusCode } from "../../types/StatusCodeEnums"; | ||
import { setErrorData } from "../../utils/errorData"; | ||
import { redirectToErrorPage } from "../../utils/redirectUtils"; | ||
|
||
const getConfigOptions = async (): Promise<{ | ||
CONFIG_PATH: string; | ||
}> => { | ||
const connectionOptions = { | ||
CONFIG_PATH: configApiUrl(), | ||
}; | ||
|
||
if (import.meta.env.PROD) { | ||
try { | ||
const response = await fetch("/tldraw-client-runtime.config.json"); | ||
|
||
if (!response.ok) { | ||
throw new Error(`${response.status} - ${response.statusText}`); | ||
} | ||
|
||
const data: { CONFIG_PATH: string } = await response.json(); | ||
connectionOptions.CONFIG_PATH = data.CONFIG_PATH; | ||
} catch (error) { | ||
setErrorData(HttpStatusCode.InternalServerError, "error.500"); | ||
redirectToErrorPage(); | ||
} | ||
} | ||
|
||
return connectionOptions; | ||
}; | ||
|
||
const configApiUrl = () => { | ||
const configApiUrl = import.meta.env.VITE_SERVER_TLDRAW_2_ENABLED | ||
? `/api/tldraw/config/public` | ||
: `/api/v3/config/public`; | ||
|
||
return configApiUrl; | ||
}; | ||
|
||
export const API = { | ||
FILE_UPLOAD: "/api/v3/file/upload/school/SCHOOLID/boardnodes/CONTEXTID", | ||
FILE_DELETE: "/api/v3/file/delete/FILERECORD_ID", | ||
FILE_RESTORE: "/api/v3/file/restore/FILERECORD_ID", | ||
LOGIN_REDIRECT: "/login?redirect=/tldraw?parentId=PARENTID", | ||
USER_DATA: `/api/v3/user/me`, | ||
ENV_CONFIG: `/api/v3/config/public`, | ||
CONFIG_PATH: await getConfigOptions().then((options) => options.CONFIG_PATH), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export type Envs = { | ||
FEATURE_TLDRAW_ENABLED: boolean; | ||
TLDRAW__ASSETS_ENABLED: boolean; | ||
TLDRAW__ASSETS_MAX_SIZE: number; | ||
TLDRAW__ASSETS_MAX_SIZE_BYTES: number; | ||
TLDRAW__ASSETS_ALLOWED_MIME_TYPES_LIST: string[]; | ||
TLDRAW__WEBSOCKET_URL: string; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.