Skip to content

Commit

Permalink
feat: add cors config
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed Oct 10, 2024
1 parent 6274bd3 commit 63862a0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/schema.ts
Original file line number Diff line number Diff line change
@@ -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])?$/;
Expand Down Expand Up @@ -91,7 +96,17 @@ export const manifestSchema = Joi.object<ManifestValue>({
cmd: Joi.array().items(cmdSchema.required()).min(1),
}).allow(null),

deploy: Joi.object({
deploy: Joi.object<ManifestDeploymentConfig>({
cors: Joi.object<ManifestDeploymentCors>({
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'),
Expand Down
12 changes: 12 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,24 @@ export type ManifestProcessor = {
env?: Record<string, string>;
};

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<string, string>;
addons?: {
postgres?: {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2622,7 +2622,7 @@ joi-to-json@^4.2.1:
lodash "^4.17.21"
semver-compare "^1.0.0"

joi@^17.13.3:
[email protected]:
version "17.13.3"
resolved "https://registry.yarnpkg.com/joi/-/joi-17.13.3.tgz#0f5cc1169c999b30d344366d384b12d92558bcec"
integrity sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==
Expand Down

0 comments on commit 63862a0

Please sign in to comment.