chore: add proxy backend (#3126)

* feat(backends): add proxy backend

* feat: add proxy server initial commit

* fix: move from joi to @hapi/joi

* test: add joi validation tests

* feat: proxy server initial implementations

* test: add tests, fix build

* chore: update yarn.lock

* build: fix develop command

* fix(back-proxy): fix bugs

* test(backend-proxy): add cypress tests

* chore: cleanup

* chore: support node 10

* chore: code cleanup

* chore: run cypress on ubuntu 16.04

* test(e2e): fix proxy backend cypress tests

* chore: don't start proxy server on yarn develop
This commit is contained in:
Erez Rokah
2020-01-22 23:47:34 +02:00
committed by Shawn Erquhart
parent cf57da223d
commit 7e8084be87
38 changed files with 2895 additions and 106 deletions

View File

@ -15,6 +15,14 @@ export const parseContentKey = (contentKey: string) => {
return { collection: contentKey.substr(0, index), slug: contentKey.substr(index + 1) };
};
export const contentKeyFromBranch = (branch: string) => {
return branch.substring(`${CMS_BRANCH_PREFIX}/`.length);
};
export const branchFromContentKey = (contentKey: string) => {
return `${CMS_BRANCH_PREFIX}/${contentKey}`;
};
export interface FetchError extends Error {
status: number;
}

View File

@ -1,7 +1,9 @@
export const EDITORIAL_WORKFLOW_ERROR = 'EDITORIAL_WORKFLOW_ERROR';
export default class EditorialWorkflowError extends Error {
constructor(message, notUnderEditorialWorkflow) {
message: string;
notUnderEditorialWorkflow: boolean;
constructor(message: string, notUnderEditorialWorkflow: boolean) {
super(message);
this.message = message;
this.notUnderEditorialWorkflow = notUnderEditorialWorkflow;

View File

@ -84,6 +84,7 @@ export type Config = {
gateway_url?: string;
large_media_url?: string;
use_large_media_transforms_in_media_library?: boolean;
proxy_url?: string;
};
media_folder: string;
base_url?: string;

View File

@ -51,6 +51,8 @@ import {
PreviewState,
FetchError as FE,
parseContentKey,
branchFromContentKey,
contentKeyFromBranch,
} from './API';
import {
createPointerFile,
@ -132,6 +134,8 @@ export const NetlifyCmsLibUtil = {
getLargeMediaPatternsFromGitAttributesFile,
parsePointerFile,
getPointerFileForMediaFileObj,
branchFromContentKey,
contentKeyFromBranch,
};
export {
APIError,
@ -180,4 +184,6 @@ export {
getLargeMediaPatternsFromGitAttributesFile,
parsePointerFile,
getPointerFileForMediaFileObj,
branchFromContentKey,
contentKeyFromBranch,
};