Skip to content

Commit

Permalink
Merge pull request #70 from AthennaIO/develop
Browse files Browse the repository at this point in the history
feat(is): add Is.Module() method
  • Loading branch information
jlenon7 authored Sep 7, 2023
2 parents a1de763 + c7f0099 commit 1ec0cc8
Show file tree
Hide file tree
Showing 47 changed files with 268 additions and 217 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/common",
"version": "4.9.2",
"version": "4.10.0",
"description": "The Athenna common helpers to use in any Node.js ESM project.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down Expand Up @@ -143,7 +143,7 @@
},
"prettier": {
"singleQuote": true,
"trailingComma": "all",
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "lf",
"semi": false,
Expand Down
2 changes: 1 addition & 1 deletion src/exceptions/InvalidNumberException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class InvalidNumberException extends Exception {
super({
code: 'E_INVALID_NUMBER',
help: 'Use a valid string number instead.',
message: `The number ${number} is not a valid string number.`,
message: `The number ${number} is not a valid string number.`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/InvalidUuidException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class InvalidUuidException extends Exception {
super({
code: 'E_INVALID_UUID',
help: 'Use a valid UUID instead.',
message: `The value ${value} is not a valid UUID.`,
message: `The value ${value} is not a valid UUID.`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/NodeCommandException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class NodeCommandException extends Exception {
super({
help,
code: 'E_NODE_EXEC',
message: `Error has occurred when executing the command "${command}"`,
message: `Error has occurred when executing the command "${command}"`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/NotFoundFileException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NotFoundFileException extends Exception {
super({
code: 'E_NOT_FOUND_FILE',
message: `The file ${filePath} doesnt exist.`,
help: 'Try using File.create method to create the file.',
help: 'Try using File.create method to create the file.'
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/NotFoundFolderException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NotFoundFolderException extends Exception {
super({
code: 'E_NOT_FOUND_FILE',
message: `The folder ${filePath} doesnt exist.`,
help: 'Try using Folder.create method to create the folder.',
help: 'Try using Folder.create method to create the folder.'
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/NotFoundResolveException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NotFoundResolveException extends Exception {
super({
code: 'E_NOT_FOUND_RESOLVE',
message: `The importa.meta.resolve function does not exist in import.meta object.`,
help: 'The resolve function is not defined because the --experimental-import-meta-resolve option in Node CLI is required when running your application. Try to set up this option when running your application.',
help: 'The resolve function is not defined because the --experimental-import-meta-resolve option in Node CLI is required when running your application. Try to set up this option when running your application.'
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/OrdinalNanException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class OrdinalNanException extends Exception {
super({
code: 'E_ORDINAL_NAN',
message: 'Cannot ordinal NaN or infinite numbers.',
help: 'Use a valid number instead of NaN or infinite.',
help: 'Use a valid number instead of NaN or infinite.'
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/RouteMatchException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class RouteMatchException extends Exception {
super({
code: 'E_ROUTE_MATCH',
message: `The route ${routeWithParams} does not match ${routeWithValues}`,
help: 'Please open an issue in https://github.com/AthennaIO/Common/issues',
help: 'Please open an issue in https://github.com/AthennaIO/Common/issues'
})
}
}
8 changes: 4 additions & 4 deletions src/helpers/Clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export class Clean {
options: {
removeEmpty?: boolean
recursive?: boolean
} = {},
} = {}
) {
options = Options.create(options, {
removeEmpty: false,
recursive: false,
recursive: false
})

return array
Expand Down Expand Up @@ -54,11 +54,11 @@ export class Clean {
options: {
removeEmpty?: boolean
recursive?: boolean
} = {},
} = {}
): T {
options = Options.create(options, {
removeEmpty: false,
recursive: false,
recursive: false
})

const cleanedObject: any = {}
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/Color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class Color {
return Color.chalk.reset(value).replace(
// eslint-disable-next-line no-control-regex
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
'',
''
)
}

Expand All @@ -242,7 +242,7 @@ export class Color {
* Paint by the http method.
*/
public static httpMethod(
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD',
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD'
): ChalkInstance {
return this[method]
}
Expand Down Expand Up @@ -276,7 +276,7 @@ export class Color {

matches.forEach(match => {
const [chalkMethodsInBrackets, chalkMethodsString] = match.match(
/\{(.*?)}/,
/\{(.*?)}/
) as any

const message = match
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/Exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Exception extends Error {
help: null,
stack: null,
name: this.constructor.name,
code: changeCase.constantCase(this.constructor.name),
code: changeCase.constantCase(this.constructor.name)
})

this.name = options.name
Expand Down Expand Up @@ -87,7 +87,7 @@ export class Exception extends Error {
hideErrorTitle: true,
hideMessage: false,
displayMainFrameOnly: false,
framesMaxLimit: 3,
framesMaxLimit: 3
})

const separator = Color.cyan('-----')
Expand All @@ -98,7 +98,7 @@ export class Exception extends Error {

if (this.help && this.help !== '') {
this.help = `${helpKey}\n\n ${Color.green(
Color.apply(this.help),
Color.apply(this.help)
)}\n\n ${separator}`
} else {
this.message = this.message.concat(`\n\n${separator}`)
Expand Down
16 changes: 8 additions & 8 deletions src/helpers/Exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class Exec {

public static async concurrently<T = any, R = any>(
array: T[],
callback: (value: T, index: number, array: T[]) => Promise<R>,
callback: (value: T, index: number, array: T[]) => Promise<R>
): Promise<R[]> {
return Promise.all(array.map(callback))
}
Expand All @@ -46,10 +46,10 @@ export class Exec {
*/
public static async command(
command: string,
options?: { ignoreErrors?: boolean },
options?: { ignoreErrors?: boolean }
): Promise<CommandOutput> {
options = Options.create(options, {
ignoreErrors: false,
ignoreErrors: false
})

const execOptions: ExecOptions = {}
Expand All @@ -66,7 +66,7 @@ export class Exec {
const result: CommandOutput = {
stdout: '',
stderr: '',
exitCode: 0,
exitCode: 0
}

exec(command, execOptions, (error, stdout, stderr) => {
Expand Down Expand Up @@ -129,12 +129,12 @@ export class Exec {
public static pagination<T = any>(
data: any[],
total: number,
pagination?: PaginationOptions,
pagination?: PaginationOptions
): PaginatedResponse<T> {
pagination = Options.create(pagination, {
page: 0,
limit: 10,
resourceUrl: '/',
resourceUrl: '/'
})

const totalPages = Math.ceil(total / pagination.limit)
Expand All @@ -144,7 +144,7 @@ export class Exec {
totalItems: total,
totalPages,
currentPage: pagination.page,
itemsPerPage: pagination.limit,
itemsPerPage: pagination.limit
}

let nextPage = 1
Expand All @@ -159,7 +159,7 @@ export class Exec {
first: `${pagination.resourceUrl}?limit=${meta.itemsPerPage}`,
previous: `${pagination.resourceUrl}?page=${previousPage}&limit=${meta.itemsPerPage}`,
next: `${pagination.resourceUrl}?page=${nextPage}&limit=${meta.itemsPerPage}`,
last: `${pagination.resourceUrl}?page=${totalPages}&limit=${meta.itemsPerPage}`,
last: `${pagination.resourceUrl}?page=${totalPages}&limit=${meta.itemsPerPage}`
}

return { meta, links, data }
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/FakeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class FakeApi {
*/
public static async start(
port = 8989,
folderPath = Path.resources('fake-api'),
folderPath = Path.resources('fake-api')
): Promise<void> {
if (folderPath) {
await this.registerFolder(folderPath)
Expand All @@ -92,7 +92,7 @@ export class FakeApi {
const files = new Folder(path).getFilesByPattern('**/*.json')

const promises = files.map(file =>
file.load().then(fileLoaded => this.registerFile(fileLoaded)),
file.load().then(fileLoaded => this.registerFile(fileLoaded))
)

await Promise.all(promises)
Expand Down Expand Up @@ -241,7 +241,7 @@ export class FakeApiBuilder {

return response.status(statusCode).headers(headers).send(body)
},
...options,
...options
})
}
}
Expand Down
Loading

0 comments on commit 1ec0cc8

Please sign in to comment.