@mxpicture/gcp-functions 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,8 +6,8 @@ class FunctionCollection {
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
7
  this.funcs = {};
8
8
  }
9
- add(name, func) {
10
- this.funcs[name] = func;
9
+ add(func, name) {
10
+ this.funcs[name ?? func.name] = func;
11
11
  return this;
12
12
  }
13
13
  build() {
@@ -4,7 +4,8 @@ exports.BaseFunction = void 0;
4
4
  const https_1 = require("firebase-functions/https");
5
5
  const ts_transformer_keys_1 = require("ts-transformer-keys");
6
6
  class BaseFunction {
7
- constructor(http) {
7
+ constructor(name, http) {
8
+ this.name = name;
8
9
  this.http = http;
9
10
  this.httpMethods = (0, ts_transformer_keys_1.keys)();
10
11
  }
@@ -6,8 +6,8 @@ class FunctionCollection {
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
7
  this.funcs = {};
8
8
  }
9
- add(name, func) {
10
- this.funcs[name] = func;
9
+ add(func, name) {
10
+ this.funcs[name ?? func.name] = func;
11
11
  return this;
12
12
  }
13
13
  build() {
@@ -4,7 +4,8 @@ exports.BaseFunction = void 0;
4
4
  const https_1 = require("firebase-functions/https");
5
5
  const ts_transformer_keys_1 = require("ts-transformer-keys");
6
6
  class BaseFunction {
7
- constructor(http) {
7
+ constructor(name, http) {
8
+ this.name = name;
8
9
  this.http = http;
9
10
  this.httpMethods = (0, ts_transformer_keys_1.keys)();
10
11
  }
@@ -5,7 +5,7 @@ export declare class FunctionCollection {
5
5
  [key: string]: BaseFunction<any>;
6
6
  };
7
7
  constructor();
8
- add<DTO extends DocumentData>(name: string, func: BaseFunction<DTO>): FunctionCollection;
8
+ add<DTO extends DocumentData>(func: BaseFunction<DTO>, name?: string): FunctionCollection;
9
9
  build(): {
10
10
  [key: string]: BaseFunction<any>;
11
11
  };
@@ -3,8 +3,9 @@ import { HttpHandlers } from "../types/types.httpHandler";
3
3
  import { DocumentData } from "../types/types.document";
4
4
  import { ApiRoutes } from "../types/types.apiRoutes";
5
5
  export declare class BaseFunction<DTO extends DocumentData> {
6
+ readonly name: string;
6
7
  protected http: HttpHandlers<ApiRoutes<DTO>>;
7
- protected readonly httpMethods: (keyof ApiRoutes<DTO>)[];
8
- constructor(http: HttpHandlers<ApiRoutes<DTO>>);
8
+ protected readonly httpMethods: string[];
9
+ constructor(name: string, http: HttpHandlers<ApiRoutes<DTO>>);
9
10
  createFunction(): HttpsFunction;
10
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/gcp-functions",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Utils for google cloud functions, publishing both CommonJS and ESM builds",
5
5
  "author": "MXPicture",
6
6
  "license": "MIT",