From 63862a02d6e3b83578408ed56c58a75fc4e9cc66 Mon Sep 17 00:00:00 2001 From: belopash Date: Thu, 10 Oct 2024 14:15:36 +0500 Subject: [PATCH] feat: add cors config --- src/schema.ts | 19 +++++++++++++++++-- src/types.ts | 12 ++++++++++++ yarn.lock | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/schema.ts b/src/schema.ts index e8512f7..ed38193 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -1,6 +1,11 @@ import { extendedJoi as Joi } from './joi'; import { RPC_ENDPOINT_NAMES } from './rpc_networks'; -import { ManifestProcessor, ManifestValue } from './types'; +import { + ManifestDeploymentConfig, + ManifestDeploymentCors, + ManifestProcessor, + ManifestValue, +} from './types'; export const SECRET_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/; export const SQUID_NAME_PATTERN = /^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$/; @@ -91,7 +96,17 @@ export const manifestSchema = Joi.object({ cmd: Joi.array().items(cmdSchema.required()).min(1), }).allow(null), - deploy: Joi.object({ + deploy: Joi.object({ + cors: Joi.object({ + enabled: Joi.boolean().default(true), + allow_origin: Joi.array().items(Joi.string()).single(), + allow_methods: Joi.array().items(Joi.string()).single(), + allow_headers: Joi.array().items(Joi.string()).single(), + expose_headers: Joi.array().items(Joi.string()).single(), + allow_credentials: Joi.boolean(), + max_age: Joi.number().integer().positive(), + }), + addons: Joi.object({ postgres: Joi.object({ version: Joi.string().valid('14').default('14'), diff --git a/src/types.ts b/src/types.ts index eb7ed81..0c4e1a3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,12 +10,24 @@ export type ManifestProcessor = { env?: Record; }; +export type ManifestDeploymentCors = { + enabled: boolean; + allow_origin?: string[]; + allow_methods?: string[]; + allow_headers?: string[]; + expose_headers?: string[]; + allow_credentials?: boolean; + max_age?: number; +}; + export type ManifestDeploymentConfig = { /** * @deprecated */ secrets?: string[]; + cors?: ManifestDeploymentCors; + env?: Record; addons?: { postgres?: { diff --git a/yarn.lock b/yarn.lock index a80a0d7..ddee059 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2622,7 +2622,7 @@ joi-to-json@^4.2.1: lodash "^4.17.21" semver-compare "^1.0.0" -joi@^17.13.3: +joi@17.13.3: version "17.13.3" resolved "https://registry.yarnpkg.com/joi/-/joi-17.13.3.tgz#0f5cc1169c999b30d344366d384b12d92558bcec" integrity sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==