Skip to content

Commit

Permalink
refactor(docs): change paths to use Path helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Aug 14, 2023
1 parent 2f9e7b8 commit 1bb9376
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 42 deletions.
19 changes: 9 additions & 10 deletions docs/architecture-concepts/application-lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ application you are using. Meaning that no matter what is the type of
application you are using to build your solution, the explanation bellow
is valid for all of them.

The entry point of an Athenna application is the `bootstrap/main.ts`
file in the default project structure and `bin/main.ts` in slim project
structure. The first action taken by Athenna itself is to create an
instance of the application and then boot it.
The entry point of an Athenna application is the `Path.bootstrap('main.ts')`.
The first action taken by Athenna itself is to create an instance of the
application and then boot it.

## Loading the foundation

Expand Down Expand Up @@ -141,7 +140,7 @@ will be fired before executing your command.
### Kernel

The Kernel class is responsible by defining some bootstraps that will
be run before reading your `routes/http.ts` file. These bootstraps
be run before reading your `Path.routes('http.ts')` file. These bootstraps
configure error handling for requests, tracing and logging, detect the
application environment, and perform other tasks that need to be done
before the request is actually handled. Typically, these classes handle
Expand Down Expand Up @@ -169,27 +168,27 @@ implementation code.

:::

Then, you can register your `CustomKernel` in your `bootstrap/main.ts`
Then, you can register your `CustomKernel` in your `Path.bootstrap('main.ts')`
file:

```typescript
import { Ignite } from '@athenna/core'

const ignite = await new Ignite().load(import.meta.url)

await ignite.httpServer({ kernelPath: '#app/http/CustomKernel' })'
await ignite.httpServer({ kernelPath: '#app/http/CustomKernel' })
```

### Routes

The `routes/http.ts` file is the entrypoint for all your http requests.
The `Path.routes('http.ts')` file is the entrypoint for all your http requests.
This file is responsible to create a contract between your client and
your application. It Is in here that we define all our routes and the
handlers/controllers who will handle the client request.

One of the most important service providers in your application is the
`HttpRouteProvider`. This service provider adds in the container the
`Route` class instance used inside `routes/http.ts` file.
`Route` class instance used inside `Path.routes('http.ts')` file.

When the client request arrives, the server first executes all your
global middlewares, then it will execute all your route middlewares.
Expand Down Expand Up @@ -291,7 +290,7 @@ await ignite.artisan({ kernelPath: '#app/http/CustomKernel' })

### Execution

The `routes/console.ts` and the `commands` property of `.athennarc.json` file
The `Path.routes('console.ts')` and the `commands` property of `.athennarc.json` file
is where that we define all ours commands and the handlers who will handle
the terminal arguments.

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture-concepts/service-container.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ itself.
If you use the `@Service` annotation, you can instruct the container how he
should resolve that class, or use the default resolution configurations of the
annotation. For example, you may place the following code in your
`routes/http.ts` file:
`Path.routes('http.ts')` file:

```typescript
import { Route } from '@athenna/http'
Expand Down
6 changes: 3 additions & 3 deletions docs/cli-application/error-handling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bootstrap failure has been found in your application.

## Configuration

The `debug` option in your `config/app.ts` configuration
The `debug` option in your `Path.config('app.ts')` configuration
file determines how much information about an error is
actually displayed to the user. By default, this option is
set to respect the value of the `APP_DEBUG` environment
Expand All @@ -77,13 +77,13 @@ users.

Every error will be logged by default using the `console`
driver from `@athenna/logger`. By default, Athenna uses the
`exception` channel of your `config/logging.ts` file to log
`exception` channel of your `Path.config('logging.ts')` file to log
all exceptions that happens in your application.

:::tip

You can change the driver and formatter of `exception`
channel inside `config/logging.ts` file. This way you can
channel inside `Path.config('logging.ts')` file. This way you can
send all your error logs to another provider and with
a different formatter.

Expand Down
2 changes: 1 addition & 1 deletion docs/digging-deeper/graceful-shutdown.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ process.on('SIGTERM', () => {

If you wish to remove or change the default listeners of
Athenna, or also listen to new signals, you can create
the `signals` property in the `config/app.ts`
the `signals` property in the `Path.config('app.ts')`
file:

```typescript
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ Config.set('app.name', builders.functionCall('Env', ['MY_APP_NAME']))
await Config.rewrite('app')
```

The example above will produce the following code in `config/app.ts`:
The example above will produce the following code in `Path.config('app.ts')`:

```typescript
export default {
Expand Down Expand Up @@ -525,7 +525,7 @@ structure.

## Debug mode

The `debug` option in your `config/app.ts` configuration
The `debug` option in your `Path.config('app.ts')` configuration
file determines how much information about your application
is actually displayed to you and for who is going to consume
your application. By default, this option is set to respect
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/directory-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ command, Athenna will use this file to run your application.
- The `config` path is where you are going to set up your
configuration files. You can learn more about configuration
files at [the configuration documentation section](https://athenna.io/docs/getting-started/configuration).
- The `routes/http.ts` file is where you are going to register
- The `Path.routes('http.ts')` file is where you are going to register
your Http server routes.

Athenna is a framework with a lot of opinions, with predefined
Expand Down
10 changes: 5 additions & 5 deletions docs/rest-api-application/error-handling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This documentation will cover about error handling in the **REST API**
application, which means that only errors that happens inside
routes and bellow that will be handled:

```typescript title="routes/http.ts"
```typescript title="Path.routes('http.ts')"
import { Route } from '@athenna/http'

// If AppController.show throws, HttpExceptionHandler will handle it 👈
Expand All @@ -44,7 +44,7 @@ bootstrap failure has been found in your application.

## Configuration

The `debug` option in your `config/app.ts` configuration
The `debug` option in your `Path.config('app.ts')` configuration
file determines how much information about an error is
actually displayed to the user. By default, this option is
set to respect the value of the `APP_DEBUG` environment
Expand All @@ -59,13 +59,13 @@ users.

Every error will be logged by default using the `console`
driver from `@athenna/logger`. By default, Athenna uses the
`exception` channel of your `config/logging.ts` file to log
`exception` channel of your `Path.config('logging.ts')` file to log
all exceptions that happens in your application.

:::tip

You can change the driver and formatter of `exception`
channel inside `config/logging.ts` file. This way you can
channel inside `Path.config('logging.ts')` file. This way you can
send all your error logs to another provider and with
a different formatter.

Expand Down Expand Up @@ -121,7 +121,7 @@ export class PaymentRequiredException extends HttpException {
You can ignore an exception from being logged if its status
code or the code does not match your requirements. To do so
you can add the following configurations to the `logger`
property in your `config/http.ts` configuration file:
property in your `Path.config('http.ts')` configuration file:

```typescript
export default {
Expand Down
2 changes: 1 addition & 1 deletion docs/rest-api-application/middlewares.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Route.get('/welcome', () => {
:::info

The requests log created by Athenna when the `logger`
property is true in your `config/http.ts` file are handled
property is true in your `Path.config('http.ts')` file are handled
by a terminator middleware! You can see the code [here](https://github.com/AthennaIO/Http/blob/develop/src/kernels/HttpKernel.ts#L93).

:::
4 changes: 2 additions & 2 deletions docs/rest-api-application/rate-limiting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ a user can request your application in a given time-frame.

Athenna uses the [`@fastify/rate-limit`](https://github.com/fastify/fastify-rate-limit)
plugin inside `HttpKernel`. All the configurations that
`@fastify/rate-limit` supports can be set inside `config/http.js`
`@fastify/rate-limit` supports can be set inside `Path.config('http.ts')`
file in the `rateLimit` object:

```typescript
Expand All @@ -43,7 +43,7 @@ export default {

In Athenna you can set specific options of rate limit
for specific routes. You can also disable the `global`
option of your `rateLimit` configuration in `config/http.js`
option of your `rateLimit` configuration in `Path.config('http.ts')`
and set different rules in your routes:

```typescript
Expand Down
4 changes: 2 additions & 2 deletions docs/rest-api-application/routing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ which a browser should permit loading resources.

Athenna uses the [`@fastify/cors`](https://github.com/fastify/fastify-cors)
plugin inside `HttpKernel`. All the configurations that
`@fastify/cors` supports can be set inside `config/http.ts`
`@fastify/cors` supports can be set inside `Path.config('http.ts')`
file in the `cors` object.

Cors plugin is registered in your http application by
default, but you can remove it uninstalling `@fastify/cors`
from your application, or removing the `cors` object key
from your `config/http.ts` file.
from your `Path.config('http.ts')` file.

:::tip

Expand Down
4 changes: 2 additions & 2 deletions docs/rest-api-application/swagger.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ is the root of all awesomeness in Swagger.
Athenna uses the [`@fastify/swagger`](https://github.com/fastify/fastify-swagger)
and [`@fastify/swagger-ui`](https://github.com/fastify/fastify-swagger-ui)
plugins inside `HttpKernel`. All the configurations that `@fastify/swagger`
supports can be set inside `config/http.js` file in the `swagger.configurations`
supports can be set inside `Path.config('http.ts')` file in the `swagger.configurations`
object. And all the configurations that `@fastify/swagger-ui`
supports can be set inside `config/http.js` file in the `swagger.ui` object:
supports can be set inside `Path.config('http.ts')` file in the `swagger.ui` object:

```typescript
export default {
Expand Down
2 changes: 1 addition & 1 deletion docs/rest-api-application/tracing-requests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ identify bottlenecks and focus on improving performance.
Athenna uses the [`cls-rtracer`](https://github.com/puzpuzpuz/cls-rtracer)
plugin inside `HttpKernel`. All the configurations
that `cls-rtracer` supports can be set inside
`config/http.js` file in the `rTracer` object:
`Path.config('http.ts')` file in the `rTracer` object:

```typescript
export default {
Expand Down
18 changes: 9 additions & 9 deletions docs/the-basics/logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ the http requests that your application receives.
## Configuration

All the configuration options for your application's logging
behavior are housed in the `config/logging.ts` configuration
behavior are housed in the `Path.config('logging.ts')` configuration
file. This file allows you to configure your application's
log channels, so be sure to review each of the available
channels and their options. We'll review a few common options
Expand All @@ -39,7 +39,7 @@ Each log channel is powered by a "driver". The driver determines
how and where the log message is actually transported. The
following log channel drivers are available in every Athenna
application. An entry for most of these drivers is already
present in your application's `config/logging.ts` configuration
present in your application's `Path.config('logging.ts')` configuration
file, so be sure to review this file to become familiar with
its contents:

Expand All @@ -57,7 +57,7 @@ its contents:

Almost all channels doesn't need any additional configuration to
work. But some of than need a couple of changes in
`config/logging.ts` file to be able to use. They are `slack`,
`Path.config('logging.ts')` file to be able to use. They are `slack`,
`discord` and `telegram`.

#### Configuring the Slack channel
Expand Down Expand Up @@ -157,7 +157,7 @@ import { DriverFactory } from '@athenna/logger'
DriverFactory.createDriver('consoleLog', ConsoleLogDriver)
```

Finally, we can start using our new driver in channels of `config/logging.ts`:
Finally, we can start using our new driver in channels of `Path.config('logging.ts')`:

```typescript
channels: {
Expand Down Expand Up @@ -193,7 +193,7 @@ Log.fatal(message)
You may call any of these methods to log a message for the
corresponding level. By default, the message will be written
to the default log channel as configured by your
`config/logging.ts` configuration file:
`Path.config('logging.ts')` configuration file:

```typescript
import { WelcomeService } from '#app/services/WelcomeService'
Expand Down Expand Up @@ -233,7 +233,7 @@ example configuration that you might see in a production
application:

Take note of the `level` configuration option present in
`slack` channel of your `config/logging.ts` file:
`slack` channel of your `Path.config('logging.ts')` file:

```typescript
channels: {
Expand Down Expand Up @@ -321,7 +321,7 @@ Log.info(`${chalk.yellow.bold('Hello')} ${chalk.green.italic('World')}!`)

It is also possible to set runtime configurations when using
the `Log` facade. This way you will never be total
dependent from `config/logging.ts` configuration file. To
dependent from `Path.config('logging.ts')` configuration file. To
accomplish this, you may pass a configuration object to the
`config` method of Log facade and then call the `channel`
method again to set up the configurations for the specified
Expand All @@ -343,7 +343,7 @@ Each log channel is powered by a "formatter". The formatter
determines how the log message is actually formatted.
The following log channel formatters are available in every
Athenna application. An entry for most of these formatters is
already present in your application's `config/logging.ts`
already present in your application's `Path.config('logging.ts')`
configuration file, so be sure to review this file to become
familiar with its contents:

Expand Down Expand Up @@ -409,7 +409,7 @@ FormatterFactory.createFormatter('consoleLog', ConsoleLogFormatter)
```

Finally, we can start using our new formatter in channels
of `config/logging.ts`:
of `Path.config('logging.ts')`:

```typescript
channels: {
Expand Down
4 changes: 2 additions & 2 deletions docs/the-basics/views.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ allow you to easily log values, create "if" statements,
iterate over data, and more.

Once you have created a view file, eg: `resources/views/welcome.edge`,
you may register your view disk inside `config/view.ts` file:
you may register your view disk inside `Path.config('view.ts')` file:

```typescript
import { Path } from '@athenna/common'
Expand Down Expand Up @@ -184,7 +184,7 @@ time-consuming process, and hence it is recommended to cache
the compiled templates in production.

You can control the template caching using the `edge.cache`
property inside `config/view.ts` file. Just make sure to set
property inside `Path.config('view.ts')` file. Just make sure to set
the value to `true` in the production environment:

```typescript
Expand Down

0 comments on commit 1bb9376

Please sign in to comment.