Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cors support for api resource #206

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
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
@@ -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;
@@ -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 {
53 changes: 52 additions & 1 deletion src/gen/proto/deploy/v1/deploy_pb.js
Original file line number Diff line number Diff line change
@@ -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) {
@@ -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;
@@ -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
);
}
};


@@ -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;
};





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
@@ -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;
@@ -312,6 +365,7 @@ export namespace ApiResource {
export type AsObject = {
securityDefinitionsMap: Array<[string, ApiSecurityDefinition.AsObject]>,
securityMap: Array<[string, ApiScopes.AsObject]>,
cors?: ApiCorsDefinition.AsObject,
}
}

Loading