@candlerip/shared3 0.0.63 → 0.0.64

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candlerip/shared3",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -4,6 +4,7 @@ export declare const ENVIRONMENT_VARIABLE: {
4
4
  readonly APP_PORT: "number";
5
5
  readonly AUTHENTICATION_AUDIENCE: "string";
6
6
  readonly AUTHENTICATION_DOMAIN: "string";
7
+ readonly BACKEND_URL: "string";
7
8
  readonly CACHE_ENABLED: "boolean";
8
9
  readonly CACHE_SERVICE_PORT: "number";
9
10
  readonly DATABASE_URL: "string";
@@ -4,6 +4,7 @@ export const ENVIRONMENT_VARIABLE = {
4
4
  APP_PORT: 'number',
5
5
  AUTHENTICATION_AUDIENCE: 'string',
6
6
  AUTHENTICATION_DOMAIN: 'string',
7
+ BACKEND_URL: 'string',
7
8
  CACHE_ENABLED: 'boolean',
8
9
  CACHE_SERVICE_PORT: 'number',
9
10
  DATABASE_URL: 'string',
@@ -1,5 +1,5 @@
1
1
  export declare const ENVIRONMENT_VARIABLES: {
2
- readonly app: readonly ["APP_PORT", "DATABASE_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL", "S3_IMAGES_BUCKET_NAME"];
2
+ readonly app: readonly ["APP_PORT", "BACKEND_URL", "DATABASE_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL", "S3_IMAGES_BUCKET_NAME"];
3
3
  readonly 'cache-service': readonly ["CACHE_ENABLED", "CACHE_SERVICE_PORT", "DATABASE_URL", "NODE_ENV", "RABBITMQ_URL", "REDIS_PWD", "REDIS_URL"];
4
4
  readonly images: readonly ["NODE_ENV", "S3_IMAGES_BUCKET_NAME"];
5
5
  readonly 'images-init': readonly ["FRONTEND_URL", "NODE_ENV", "S3_IMAGES_BUCKET_NAME"];
@@ -1,5 +1,5 @@
1
1
  export const ENVIRONMENT_VARIABLES = {
2
- app: ['APP_PORT', 'DATABASE_URL', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL', 'S3_IMAGES_BUCKET_NAME'],
2
+ app: ['APP_PORT', 'BACKEND_URL', 'DATABASE_URL', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL', 'S3_IMAGES_BUCKET_NAME'],
3
3
  'cache-service': ['CACHE_ENABLED', 'CACHE_SERVICE_PORT', 'DATABASE_URL', 'NODE_ENV', 'RABBITMQ_URL', 'REDIS_PWD', 'REDIS_URL'],
4
4
  images: ['NODE_ENV', 'S3_IMAGES_BUCKET_NAME'],
5
5
  'images-init': ['FRONTEND_URL', 'NODE_ENV', 'S3_IMAGES_BUCKET_NAME'],
@@ -2,6 +2,9 @@ import { ProjectSingleton } from '../../../../project/index.js';
2
2
  export const customErrorWorker = (info) => {
3
3
  let _info = info;
4
4
  const serializeInfo = (info) => {
5
+ if (!info) {
6
+ return;
7
+ }
5
8
  if (info?.err) {
6
9
  info.err = JSON.stringify(info.err);
7
10
  }
@@ -1 +1 @@
1
- export declare const PAGES: readonly ["homePage", "contactPage"];
1
+ export declare const PAGES: readonly ["homePage", "contactPage", "helpPage", "termsAndConditionsPage"];
@@ -1 +1 @@
1
- export const PAGES = ['homePage', 'contactPage'];
1
+ export const PAGES = ['homePage', 'contactPage', 'helpPage', 'termsAndConditionsPage'];
@@ -1,4 +1,5 @@
1
1
  export * from './array/index.js';
2
+ export * from './object/index.js';
2
3
  export * from './string/index.js';
3
4
  export * from './type/index.js';
4
5
  export * from './type-guards/index.js';
package/src/type/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './array/index.js';
2
+ export * from './object/index.js';
2
3
  export * from './string/index.js';
3
4
  export * from './type/index.js';
4
5
  export * from './type-guards/index.js';
@@ -0,0 +1 @@
1
+ export * from './utils/index.js';
@@ -0,0 +1 @@
1
+ export * from './utils/index.js';
@@ -0,0 +1,2 @@
1
+ import { AddPrefixToObjectProps } from './types.js';
2
+ export declare const addPrefixToObjectProps: AddPrefixToObjectProps;
@@ -0,0 +1 @@
1
+ export const addPrefixToObjectProps = (obj, prefix) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [`${prefix}-${key}`, value]));
@@ -0,0 +1 @@
1
+ export type AddPrefixToObjectProps = (obj: Record<string, string>, prefix: string) => Record<string, string>;
@@ -0,0 +1 @@
1
+ export * from './add-prefix-to-object-props/index.js';
@@ -0,0 +1 @@
1
+ export * from './add-prefix-to-object-props/index.js';
@@ -1 +1,2 @@
1
1
  export * from './type-guards/index.js';
2
+ export * from './validators/index.js';
@@ -1 +1,2 @@
1
1
  export * from './type-guards/index.js';
2
+ export * from './validators/index.js';
@@ -0,0 +1 @@
1
+ export * from './validate-string/index.js';
@@ -0,0 +1 @@
1
+ export * from './validate-string/index.js';
@@ -0,0 +1,2 @@
1
+ import { ValidateString } from './types.js';
2
+ export declare const validateString: ValidateString;
@@ -0,0 +1,19 @@
1
+ import { customErrorWorker } from '../../../../error/index.js';
2
+ import { isString } from '../../type-guards/index.js';
3
+ export const validateString = (data, name, regexp) => {
4
+ const { composeCustomError } = customErrorWorker({ data, name, regexp: JSON.stringify(regexp) });
5
+ if (!data) {
6
+ return composeCustomError(`Missing ${name}`);
7
+ }
8
+ if (!isString(data)) {
9
+ return composeCustomError(`${name} not string`);
10
+ }
11
+ if (regexp) {
12
+ if (!regexp.test(data)) {
13
+ return composeCustomError(`Invalid ${name}`);
14
+ }
15
+ }
16
+ return {
17
+ data,
18
+ };
19
+ };
@@ -0,0 +1,6 @@
1
+ import { CustomError } from '../../../../error/index.js';
2
+ export type ValidateString = (data: unknown, name: string, regexp?: RegExp) => {
3
+ data: string;
4
+ } | {
5
+ customError: CustomError;
6
+ };