-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,862 additions
and
5,997 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.idea | ||
Build | ||
coverage | ||
node_modules | ||
docs/ | ||
coverage | ||
tsconfig.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v21.7.1 | ||
v22.4.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import esbuild from 'esbuild'; | ||
|
||
import pkg from '../package.json' with { type: 'json' }; | ||
|
||
const safePkg = pkg; | ||
const dependencies = safePkg.dependencies ? Object.keys(safePkg.dependencies) : undefined; | ||
const devDependencies = safePkg.devDependencies ? Object.keys(safePkg.devDependencies) : undefined; | ||
|
||
const external = [...(dependencies || []), ...(devDependencies || [])]; | ||
|
||
const options = { | ||
bundle: true, | ||
color: true, | ||
entryPoints: ['./Source/App.ts'], | ||
external, | ||
format: 'esm', | ||
keepNames: true, | ||
loader: { '.ts': 'ts' }, | ||
minify: true, | ||
outfile: './Build/App.js', | ||
platform: 'node', | ||
sourcemap: 'linked', | ||
treeShaking: true, | ||
tsconfig: './tsconfig.json', | ||
}; | ||
|
||
esbuild.build(options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export * from './Common/Errors'; | ||
export * from './Domain/Services/Data'; | ||
export * from './Domain/Services/Data/TransformerStrategies'; | ||
export * from './Domain/Services/Security'; | ||
export * from '@/Common/Error/Enum/index.js'; | ||
export * from '@/Common/Error/index.js'; | ||
export * from '@/Common/Interface/index.js'; | ||
export * from '@/Domain/Service/Data/index.js'; | ||
export * from '@/Domain/Service/Data/Interface/index.js'; | ||
export * from '@/Domain/Service/Data/TransformerStrategies/index.js'; | ||
export * from '@/Domain/Service/Security/index.js'; |
68 changes: 39 additions & 29 deletions
68
Source/Common/Errors/ErrorEntity.ts → Source/Common/Error/BasaltError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,82 @@ | ||
import { randomUUID } from 'crypto'; | ||
|
||
import type { IBasaltErrorOptions } from '@/Common/Interface/index.js'; | ||
|
||
/** | ||
* ErrorEntity is a class that represents an error entity with a unique identifier. | ||
* BasaltError is a class that represents an error entity with a unique identifier. | ||
*/ | ||
export class ErrorEntity extends Error { | ||
export class BasaltError extends Error { | ||
/** | ||
* The unique identifier of the error. | ||
* This identifier is used to track the error in the logs. | ||
* @readonly | ||
*/ | ||
private readonly _uuidError: string = randomUUID(); | ||
|
||
/** | ||
* The name of the error entity. | ||
* The date when the error was created. | ||
* @readonly | ||
*/ | ||
private readonly _name: string; | ||
private readonly _date: Date = new Date(); | ||
|
||
/** | ||
* The error code. | ||
* @readonly | ||
*/ | ||
private readonly _code: string; | ||
private readonly _code: number; | ||
/** | ||
* The error detail. | ||
* @readonly | ||
*/ | ||
private readonly _detail?: unknown; | ||
private readonly _detail: unknown; | ||
|
||
/** | ||
* Creates a new instance of the ErrorEntity class. | ||
* | ||
* @param code - The error code. | ||
* @param detail - The error detail. | ||
* @param basaltErrorOptions - The options to create the error entity. ({@link IBasaltErrorOptions}) | ||
*/ | ||
public constructor(code: string, detail?: unknown) { | ||
public constructor(basaltErrorOptions: Readonly<IBasaltErrorOptions>) { | ||
super(); | ||
this._name = this.constructor.name; | ||
this._code = code; | ||
this.message = code; | ||
this._detail = detail; | ||
this._code = basaltErrorOptions.code ?? 500; | ||
this.message = basaltErrorOptions.messageKey; | ||
this._detail = basaltErrorOptions.detail; | ||
if (Error.captureStackTrace) | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
|
||
/** | ||
* Gets the error code. | ||
* @returns The error code. | ||
* Gets the unique identifier of the error. | ||
* @readonly | ||
* @returns The unique identifier of the error. | ||
*/ | ||
public get code(): string { | ||
return this._code; | ||
public get uuidError(): string { | ||
return this._uuidError; | ||
} | ||
|
||
/** | ||
* Gets the error name. | ||
* @returns The error name. | ||
* Gets the date when the error was created. | ||
* @readonly | ||
* @returns The date when the error was created. | ||
*/ | ||
public override get name(): string { | ||
return this._name; | ||
public get date(): Date { | ||
return this._date; | ||
} | ||
|
||
/** | ||
* Gets the error detail. | ||
* @returns The error detail. | ||
* Gets the error code. | ||
* @readonly | ||
* @returns The error code. | ||
*/ | ||
public get detail(): unknown { | ||
return this._detail; | ||
public get code(): number { | ||
return this._code; | ||
} | ||
|
||
/** | ||
* Gets the unique identifier of the error. | ||
* @returns The unique identifier of the error. | ||
* Gets the error detail. | ||
* @readonly | ||
* @returns The error detail. | ||
*/ | ||
public get uuidError(): string { | ||
return this._uuidError; | ||
public get detail(): unknown { | ||
return this._detail; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* ServiceErrorKeys is an enum that contains the error codes for the Service layer | ||
*/ | ||
export enum ServiceErrorKeys { | ||
PASSWORD_EMPTY = 'error.domain.service.security.basaltPassword.passwordEmpty', | ||
PASSWORD_HASHING_FAILED = 'error.domain.service.security.basaltPassword.passwordHashingFailed', | ||
PASSWORD_VERIFICATION_FAILED = 'error.domain.service.security.basaltPassword.passwordVerificationFailed', | ||
DATA_NULL = 'error.domain.service.data.basaltData.dataNull', | ||
DATA_MUST_BE_PLAIN_OBJECT = 'error.domain.service.data.basaltData.dataMustBePlainObject', | ||
DATA_EMPTY_KEYS = 'error.domain.service.data.basaltData.dataEmptyKeys', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ServiceErrorKeys.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './BasaltError.js'; | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Represents the options for the Basalt error. | ||
*/ | ||
export interface IBasaltErrorOptions { | ||
/** | ||
* The error key. | ||
*/ | ||
messageKey: string; | ||
|
||
/** | ||
* The status code. | ||
*/ | ||
code?: number; | ||
|
||
/** | ||
* The error detail. | ||
*/ | ||
detail?: unknown; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './IBasaltErrorOptions.js'; |
Oops, something went wrong.