Skip to content

Commit

Permalink
feat: cors api resource support
Browse files Browse the repository at this point in the history
  • Loading branch information
davemooreuws committed Oct 24, 2023
1 parent 92b7266 commit ccaff6d
Show file tree
Hide file tree
Showing 8 changed files with 741 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@typescript-eslint/parser": "^4.22.0",
"codecov": "^3.8.3",
"eslint": "^7.24.0",
"eslint-plugin-jsdoc": "^40.1.0",
"eslint-plugin-jsdoc": "^46.8.2",
"glob-run": "^0.1.7",
"grpc-tools": "^1.11.3",
"husky": "^6.0.0",
Expand Down
6 changes: 6 additions & 0 deletions src/gen/proto/deploy/v1/deploy_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,11 @@ export class Api extends jspb.Message {
getOpenapi(): string;
setOpenapi(value: string): void;

hasCors(): boolean;
clearCors(): void;
getCors(): proto_resource_v1_resource_pb.ApiCorsDefinition | undefined;
setCors(value?: proto_resource_v1_resource_pb.ApiCorsDefinition): void;

getDocumentCase(): Api.DocumentCase;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Api.AsObject;
Expand All @@ -529,6 +534,7 @@ export class Api extends jspb.Message {
export namespace Api {
export type AsObject = {
openapi: string,
cors?: proto_resource_v1_resource_pb.ApiCorsDefinition.AsObject,
}

export enum DocumentCase {
Expand Down
53 changes: 52 additions & 1 deletion src/gen/proto/deploy/v1/deploy_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4059,7 +4059,8 @@ proto.nitric.deploy.v1.Api.prototype.toObject = function(opt_includeInstance) {
*/
proto.nitric.deploy.v1.Api.toObject = function(includeInstance, msg) {
var f, obj = {
openapi: jspb.Message.getFieldWithDefault(msg, 1, "")
openapi: jspb.Message.getFieldWithDefault(msg, 1, ""),
cors: (f = msg.getCors()) && proto_resource_v1_resource_pb.ApiCorsDefinition.toObject(includeInstance, f)
};

if (includeInstance) {
Expand Down Expand Up @@ -4100,6 +4101,11 @@ proto.nitric.deploy.v1.Api.deserializeBinaryFromReader = function(msg, reader) {
var value = /** @type {string} */ (reader.readString());
msg.setOpenapi(value);
break;
case 2:
var value = new proto_resource_v1_resource_pb.ApiCorsDefinition;
reader.readMessage(value,proto_resource_v1_resource_pb.ApiCorsDefinition.deserializeBinaryFromReader);
msg.setCors(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -4136,6 +4142,14 @@ proto.nitric.deploy.v1.Api.serializeBinaryToWriter = function(message, writer) {
f
);
}
f = message.getCors();
if (f != null) {
writer.writeMessage(
2,
f,
proto_resource_v1_resource_pb.ApiCorsDefinition.serializeBinaryToWriter
);
}
};


Expand Down Expand Up @@ -4175,6 +4189,43 @@ proto.nitric.deploy.v1.Api.prototype.hasOpenapi = function() {
};


/**
* optional nitric.resource.v1.ApiCorsDefinition cors = 2;
* @return {?proto.nitric.resource.v1.ApiCorsDefinition}
*/
proto.nitric.deploy.v1.Api.prototype.getCors = function() {
return /** @type{?proto.nitric.resource.v1.ApiCorsDefinition} */ (
jspb.Message.getWrapperField(this, proto_resource_v1_resource_pb.ApiCorsDefinition, 2));
};


/**
* @param {?proto.nitric.resource.v1.ApiCorsDefinition|undefined} value
* @return {!proto.nitric.deploy.v1.Api} returns this
*/
proto.nitric.deploy.v1.Api.prototype.setCors = function(value) {
return jspb.Message.setWrapperField(this, 2, value);
};


/**
* Clears the message field making it undefined.
* @return {!proto.nitric.deploy.v1.Api} returns this
*/
proto.nitric.deploy.v1.Api.prototype.clearCors = function() {
return this.setCors(undefined);
};


/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.nitric.deploy.v1.Api.prototype.hasCors = function() {
return jspb.Message.getField(this, 2) != null;
};





Expand Down
54 changes: 54 additions & 0 deletions src/gen/proto/resource/v1/resource_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,64 @@ export namespace ApiScopes {
}
}

export class ApiCorsDefinition extends jspb.Message {
getAllowCredentials(): boolean;
setAllowCredentials(value: boolean): void;

clearAllowHeadersList(): void;
getAllowHeadersList(): Array<string>;
setAllowHeadersList(value: Array<string>): void;
addAllowHeaders(value: string, index?: number): string;

clearAllowMethodsList(): void;
getAllowMethodsList(): Array<string>;
setAllowMethodsList(value: Array<string>): void;
addAllowMethods(value: string, index?: number): string;

clearAllowOriginsList(): void;
getAllowOriginsList(): Array<string>;
setAllowOriginsList(value: Array<string>): void;
addAllowOrigins(value: string, index?: number): string;

clearExposeHeadersList(): void;
getExposeHeadersList(): Array<string>;
setExposeHeadersList(value: Array<string>): void;
addExposeHeaders(value: string, index?: number): string;

getMaxAge(): number;
setMaxAge(value: number): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ApiCorsDefinition.AsObject;
static toObject(includeInstance: boolean, msg: ApiCorsDefinition): ApiCorsDefinition.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ApiCorsDefinition, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ApiCorsDefinition;
static deserializeBinaryFromReader(message: ApiCorsDefinition, reader: jspb.BinaryReader): ApiCorsDefinition;
}

export namespace ApiCorsDefinition {
export type AsObject = {
allowCredentials: boolean,
allowHeadersList: Array<string>,
allowMethodsList: Array<string>,
allowOriginsList: Array<string>,
exposeHeadersList: Array<string>,
maxAge: number,
}
}

export class ApiResource extends jspb.Message {
getSecurityDefinitionsMap(): jspb.Map<string, ApiSecurityDefinition>;
clearSecurityDefinitionsMap(): void;
getSecurityMap(): jspb.Map<string, ApiScopes>;
clearSecurityMap(): void;
hasCors(): boolean;
clearCors(): void;
getCors(): ApiCorsDefinition | undefined;
setCors(value?: ApiCorsDefinition): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ApiResource.AsObject;
static toObject(includeInstance: boolean, msg: ApiResource): ApiResource.AsObject;
Expand All @@ -312,6 +365,7 @@ export namespace ApiResource {
export type AsObject = {
securityDefinitionsMap: Array<[string, ApiSecurityDefinition.AsObject]>,
securityMap: Array<[string, ApiScopes.AsObject]>,
cors?: ApiCorsDefinition.AsObject,
}
}

Expand Down
Loading

0 comments on commit ccaff6d

Please sign in to comment.