diff --git a/docs/getting-started/configuration.mdx b/docs/getting-started/configuration.mdx index 225beb33..249d76e1 100644 --- a/docs/getting-started/configuration.mdx +++ b/docs/getting-started/configuration.mdx @@ -478,7 +478,7 @@ await Config.loadAll(Path.stubs('config')) If you are using the [slim](https://athenna.io/docs/getting-started/installation#project-structure) project structure, or you are building your own project -structure, you are not going to have the config directory +structure, you are not going to have the `config` directory in your project root path. You will have two options now: @@ -493,7 +493,7 @@ The [slim](https://athenna.io/docs/getting-started/installation#project-structur project structure is using the second option above to specify to Athenna that the configuration files will be inside of `src/config` directory. Check the examples -above how this implementation works. +bellow to see how this implementation works. ::: @@ -505,7 +505,7 @@ defined. The `directories` property is an object that maps the directory base path that the [`Path`](https://athenna.io/docs/digging-deeper/helpers#path) -class will use to resolve your application paths: +helper will use to resolve your application paths: ```typescript import { Path } from '@athenna/common' diff --git a/docs/rest-api-application/rate-limiting.mdx b/docs/rest-api-application/rate-limiting.mdx index db04ac0c..53630aa4 100644 --- a/docs/rest-api-application/rate-limiting.mdx +++ b/docs/rest-api-application/rate-limiting.mdx @@ -1,6 +1,6 @@ --- title: Rate Limiting -sidebar_position: 7 +sidebar_position: 6 description: See how to create rate limiting rules for Athenna REST API application. tags: - REST API Application diff --git a/docs/rest-api-application/security-with-helmet.mdx b/docs/rest-api-application/security-with-helmet.mdx index 9892d178..3fd8e0a8 100644 --- a/docs/rest-api-application/security-with-helmet.mdx +++ b/docs/rest-api-application/security-with-helmet.mdx @@ -1,6 +1,6 @@ --- title: Security with Helmet -sidebar_position: 9 +sidebar_position: 8 description: See how to improve the security of your REST API with Helmet in Athenna. tags: - REST API Application diff --git a/docs/rest-api-application/swagger-documentation.mdx b/docs/rest-api-application/swagger-documentation.mdx index abc501e9..09706051 100644 --- a/docs/rest-api-application/swagger-documentation.mdx +++ b/docs/rest-api-application/swagger-documentation.mdx @@ -1,6 +1,6 @@ --- title: Swagger Documentation -sidebar_position: 6 +sidebar_position: 9 description: See how to create the Swagger documentation for Athenna REST API application. tags: - REST API Application diff --git a/docs/rest-api-application/tracing-requests.mdx b/docs/rest-api-application/tracing-requests.mdx index fd704b61..98498aea 100644 --- a/docs/rest-api-application/tracing-requests.mdx +++ b/docs/rest-api-application/tracing-requests.mdx @@ -1,6 +1,6 @@ --- title: Tracing Requests -sidebar_position: 8 +sidebar_position: 7 description: Understand how to trace requests in your REST API application of Athenna. tags: - REST API Application diff --git a/docs/the-basics/helpers.mdx b/docs/the-basics/helpers.mdx index 5861eda8..587cf2eb 100644 --- a/docs/the-basics/helpers.mdx +++ b/docs/the-basics/helpers.mdx @@ -21,14 +21,36 @@ them in your own applications if you find them convenient. ## Available helpers +- [`Clean`](/docs/the-basics/helpers#clean) - Remove falsy values +from different data structures. +- [`Color`](/docs/the-basics/helpers#color) - The UI Kit of Athenna +command line applications. +- [`Exec`](/docs/the-basics/helpers#exec) - Simple helpers that executes +some operation, like executing a command in a child process. +- [`FakeApi`](/docs/the-basics/helpers#fakeapi) - Create a fake REST API +using `json` files to map the routes and their returns (similiar to [WireMock](https://wiremock.org/)). - [`File`](/docs/the-basics/helpers#file) - Create, copy, move, delete and get information about files. - [`Folder`](/docs/the-basics/helpers#folder) - Create, copy, move, delete and get information about folders. -### `File` +### `Clean` + +Coming soon + +### `Color` + +Coming soon + +### `Exec` + +Coming soon + +### `FakeApi` + +Coming soon -Use the `File` class to create an instance of a file, it existing or not. +### `File` #### `File.load()` & `File.loadSync()` @@ -339,4 +361,184 @@ const file = await File.createFileOfSize('fake.js', 1024 * 1024 * 100) 👈 ### `Folder` -Coming soon +#### `Folder.load()` & `Folder.loadSync()` + +Creates the folder if it does not exist and also load the folder information: + +```typescript +import { Folder } from '@athenna/common' + +const existent = new Folder(Path.storage('existent')) +const nonExistent = new Folder('./nonExistent') + +// Load the folder info with sub folders and with file contents. +await existent.load({ withSub: true, withContent: true }) 👈 + +// Create and load the folder info without the +// content (be careful when loading big files). +nonExistent.loadSync() 👈 +``` + +After loading process, the folder will contain new informations: + +- createdAt - The date when the folder was created. +- accessedAt - The date when the folder was last accessed. +- modifiedAt - The date when the folder was last modified. +- folderSize - The size of the folder in MB. + +#### `Folder.copy()` & `Folder.copySync()` + +Create a copy of the folder in other location or with other name: + +```typescript +import { Folder } from '@athenna/common' + +const copiedFolder = folder.copySync('./copy-of-folder') +const copiedFolder = await folder.copy(Path.storage('copy-of-folder')) +``` + +To copy the folder and load the sub folders and the content of the +copy set the `withSub` and `withContent` as `true`: + +```typescript +import { Folder } from '@athenna/common' + +const copiedFolder = await folder.copy(Path.storage('copy-of-folder'), { + withSub: true, 👈 + withContent: true 👈 +}) +``` + +When copying the folder you can set the `mockedValues` to `true` to copy the +files with fake names: + +```typescript +import { Folder } from '@athenna/common' + +const copiedFolder = await folder.copy(Path.storage('copy-of-file'), { + mockedValues: true 👈 +}) +``` + +#### `Folder.move()` & `Folder.moveSync()` + +Move the folder to other location: + +```typescript +import { Folder } from '@athenna/common' + +const movedFolder = folder.moveSync('./move-of-folder') 👈 +const movedFolder = await folder.move(Path.storage('move-of-folder')) 👈 +``` + +To move the folder and load the sub folders and the content of the +move set the `withSub` and `withContent` as `true`: + +```typescript +import { Folder } from '@athenna/common' + +const movedFolder = await folder.move(Path.storage('move-of-folder'), { + withSub: true, 👈 + withContent: true 👈 +}) +``` + +When moving the folder you can set the `mockedValues` to `true` to move the +files with fake names: + +```typescript +import { Folder } from '@athenna/common' + +const movedFolder = await folder.move(Path.storage('file-path'), { + mockedValues: true 👈 +}) +``` + +#### `Folder.remove()` & `Folder.removeSync()` + +Delete a folder from the folder system: + +```typescript +import { Folder } from '@athenna/common' + +folder.removeSync() 👈 +await folder.remove() 👈 +``` + +#### `Folder.toJSON()` + +Get the informations of the folder as JSON: + +```typescript +const infos = folder.toJSON() 👈 +``` + +#### `Folder.getFilesByPattern()` + +Get all the files of a folder using a glob pattern: + +```typescript +const files = folder.getFilesByPattern('**/*.js') 👈 +``` + +#### `Folder.getFoldersByPattern()` + +Get all the folders of a folder using a glob pattern: + +```typescript +const folders = folder.getFoldersByPattern('**/*') 👈 +``` + +#### `Folder::safeRemove()` + +Call for a delete operation without worrying about exceptions because the folder +does not exist: + +```typescript +import { Folder } from '@athenna/common' + +await Folder.safeRemove(Path.storage('folder')) 👈 +await Folder.safeRemove(Path.storage('not-found')) 👈 // Will not throw +``` + +#### `Folder::exists()` & `Folder::existsSync()` + +Verify if a folder exists or not: + +```typescript +if (Folder.existsSync('app')) { + // do something +} + +if (await Folder.exists('app')) { + // do something +} +``` + +#### `Folder::isFolder()` & `Folder::isFolderSync()` + +Verify if a folder is a valid folder or not: + +```typescript +if (Folder.isFolderSync('app')) { + // do something +} + +if (await Folder.isFolder('app')) { + // do something +} +``` + +#### `Folder::size()` & `Folder::sizeSync()` + +Get the size of the folder in MB: + +```typescript +if (Folder.sizeSync('app') === 100) { + // do something +} + +if (await Folder.size('app') === 100) { + // do something +} +``` diff --git a/static/css/markdown.css b/static/css/markdown.css index 446c6f72..9dc71d9d 100644 --- a/static/css/markdown.css +++ b/static/css/markdown.css @@ -1,25 +1,31 @@ .markdown code { - color: #ff80bf !important; + color: #ff80bf; } .markdown a { color: #939300 !important; } +a code { + color: #939300 !important; +} + .markdown a:hover { - color: #ff80bf !important; + color: #ff80bf; } [data-theme='dark'] .markdown a { color: #ffff80 !important; } +[data-theme='dark'] a code { + color: #ffff80 !important; +} + [data-theme='dark'] .markdown a:hover { - color: #ff80bf !important; + color: #ff80bf; } .markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { font-weight: 800 !important; } - -