Skip to content

Commit

Permalink
feat(docs): change route file path
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Aug 14, 2023
1 parent 634d0f6 commit 12862b9
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 62 deletions.
16 changes: 8 additions & 8 deletions docs/architecture-concepts/application-lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ 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 `Path.bootstrap('main.ts')`.
The entry point of an Athenna application is the `Path.bootstrap('main.js')`.
The first action taken by Athenna itself is to create an instance of the
application and then boot it.

Expand Down Expand Up @@ -140,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 `Path.routes('http.ts')` file. These bootstraps
be run before reading your `Path.routes('http.js')` 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 @@ -168,7 +168,7 @@ implementation code.

:::

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

```typescript
Expand All @@ -181,14 +181,14 @@ await ignite.httpServer({ kernelPath: '#app/http/CustomKernel' })

### Routes

The `Path.routes('http.ts')` file is the entrypoint for all your http requests.
The `Path.routes('http.js')` 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 `Path.routes('http.ts')` file.
`Route` class instance used inside `Path.routes('http.js')` 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 @@ -275,8 +275,8 @@ kernel implementation taking a look at [ConsoleKernel](https://github.com/Athenn

:::

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

```typescript
import { Ignite } from '@athenna/core'
Expand All @@ -290,7 +290,7 @@ await ignite.artisan({ kernelPath: '#app/http/CustomKernel' })

### Execution

The `Path.routes('console.ts')` and the `commands` property of `.athennarc.json` file
The `Path.routes('console.js')` 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
`Path.routes('http.ts')` file:
`Path.routes('http.js')` file:

```typescript
import { Route } from '@athenna/http'
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture-concepts/service-providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ The following environments are available by default in Athenna at this moment:
- repl
- console

You could also create your own environments. In your `bootstrap/main.ts` file
You could also create your own environments. In your `Path.bootstrap('main.js')` file
you can add an `environments` option when calling `Ignite.load` method:

```typescript
Expand Down
8 changes: 4 additions & 4 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 `Path.config('app.ts')` configuration
The `debug` option in your `Path.config('app.js')` 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 `Path.config('logging.ts')` file to log
`exception` channel of your `Path.config('logging.js')` file to log
all exceptions that happens in your application.

:::tip

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

Expand Down Expand Up @@ -159,7 +159,7 @@ export class Handler extends ConsoleExceptionHandler {
Now you need to register your exception handler when
bootstrapping your application:

```typescript title="bootstrap/main.ts"
```typescript filename="Path.bootstrap('main.js')"
await ignite.artisan(process.argv, {
displayName: 'Athenna',
exceptionHandlerPath: '#app/console/exceptions/Handler', 👈
Expand Down
6 changes: 3 additions & 3 deletions docs/digging-deeper/graceful-shutdown.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ Node.js supports registering as many as signals event
listeners you want, this means that you can use the default
`SIGINT` and `SIGTERM` listeners of Athenna and also create
your own. We recommend doing this implementation in the bootstrap
file of your like application, like `bootstrap/main.ts`:
file of your like application:

```typescript
```typescript filename="Path.bootstrap('main.js')"
import { Ignite } from '@athenna/core'

const ignite = await new Ignite().load(import.meta.url)
Expand All @@ -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 `Path.config('app.ts')`
the `signals` property in the `Path.config('app.js')`
file:

```typescript
Expand Down
4 changes: 2 additions & 2 deletions docs/digging-deeper/repl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ run the Artisan command:
:::info

When running this command, Athenna will use the
`Path.bootstrap('repl.ts')` file to execute your session.
`Path.bootstrap('repl.js')` file to execute your session.

:::

Expand Down Expand Up @@ -72,7 +72,7 @@ commands available.

You can pre-import modules in your REPL session to avoid keep
importing them everytime inside your REPL session. You can do that
in your `Path.bootstrap('repl.ts')` file:
in your `Path.bootstrap('repl.js')` file:

```typescript
import { Ignite } from '@athenna/core'
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/athennarc-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ create customized ones for each environement (`.athennarc.dev.json`,
`.athennarc.prod.json`). To do that you need to set the new
path to `Ignite.load()` method:

```typescript filename="bootstrap/dev.ts"
```typescript filename="Path.bootstrap('dev.js')"
import { Ignite } from '@athenna/core'

const ignite = await new Ignite().load(import.meta.url, {
Expand Down
12 changes: 6 additions & 6 deletions docs/getting-started/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ console.log(Env('APP_URL')) // "http://localhost:3000"
You can also change the name and the path of your `.env` file.
To do that you need to set the new path to `Ignite.load()` method:

```typescript filename="bootstrap/dev.ts"
```typescript filename="Path.bootstrap('dev.js')"
import { Ignite } from '@athenna/core'

const ignite = await new Ignite().load(import.meta.url, {
Expand Down Expand Up @@ -361,7 +361,7 @@ Config.set('app.name', builders.functionCall('Env', ['MY_APP_NAME']))
await Config.rewrite('app')
```

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

```typescript
export default {
Expand Down Expand Up @@ -445,7 +445,7 @@ file path:
import { Path } from '@athenna/common'
import { Config } from '@athenna/config'

await Config.load(Path.stubs('config/test.ts'))
await Config.load(Path.stubs('config/test.js'))

console.log(Config.get('test')) // { ... }
```
Expand All @@ -459,7 +459,7 @@ is not defined:
import { Path } from '@athenna/common'
import { Config } from '@athenna/config'

await Config.safeLoad(Path.stubs('config/app.ts'))
await Config.safeLoad(Path.stubs('config/app.js'))
```

#### `Config.loadAll()`
Expand Down Expand Up @@ -559,7 +559,7 @@ your environment it could become one. To avoid reloading configuration
files in these situations, you can set the `loadConfigSafe` option as `true`
in `Ignite.load()` method:

```typescript filename="bootstrap/main.ts"
```typescript filename="Path.bootstrap('main.js')"
import { Ignite } from '@athenna/core'

const ignite = await new Ignite().load(import.meta.url, {
Expand All @@ -571,7 +571,7 @@ await ignite.httpServer()

## Debug mode

The `debug` option in your `Path.config('app.ts')` configuration
The `debug` option in your `Path.config('app.js')` 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
8 changes: 4 additions & 4 deletions docs/getting-started/directory-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ command.
If your test file name does not end with `Test`, it will
be ignored and the test class will not run. But, you can
customize this behavior in the configure function of [Japa](https://japa.dev/docs)
inside your `bootstrap/test.ts` file.
inside your `Path.bootstrap('test.js')` file.

:::

Expand All @@ -144,16 +144,16 @@ create the project:
There are some files in your project that are crucial to
keep in certain places. Let's analyze some of them:

- The `bootstrap/main.ts` file is the entry point of the
- The `Path.bootstrap('main.js')` file is the entry point of the
`./node artisan serve` command. Every time that you run this
command, Athenna will use this file to run your application.
- The `bootstrap/artisan.ts` file is the entry point of the
- The `Path.bootstrap('artisan.js')` file is the entry point of the
`./node artisan` script. You can check how this works in the
[node script file documentation section](https://athenna.io/docs/getting-started/node-script-file).
- 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 `Path.routes('http.ts')` file is where you are going to register
- The `Path.routes('http.js')` 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
2 changes: 1 addition & 1 deletion docs/getting-started/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ In your project root, run the following command:
- The `watch` flag is meant to watch the file system for
changes and restart your application automatically when
doing some change on it.
- The `serve` command will look up for your `bootstrap/main.js`
- The `serve` command will look up for your `Path.bootstrap('main.js')`
file to bootstrap your application with predefined configurations.
2 changes: 1 addition & 1 deletion docs/getting-started/node-script-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ when bootstrapping your application.
If you take a look at the content of the node script file,
you will see that we are using [sed](https://www.geeksforgeeks.org/sed-command-linux-set-2/)
command to replace the `artisan` argument with the path to
`bootstrap/artisan.ts` file.
`Path.bootstrap('main.js')` file.

This is a tricky implementation that will allow you to call
your artisan commands without the need to add the full path
Expand Down
12 changes: 6 additions & 6 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="Path.routes('http.ts')"
```typescript title="Path.routes('http.js')"
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 `Path.config('app.ts')` configuration
The `debug` option in your `Path.config('app.js')` 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 `Path.config('logging.ts')` file to log
`exception` channel of your `Path.config('logging.js')` file to log
all exceptions that happens in your application.

:::tip

You can change the driver and formatter of `exception`
channel inside `Path.config('logging.ts')` file. This way you can
channel inside `Path.config('logging.js')` 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 `Path.config('http.ts')` configuration file:
property in your `Path.config('http.js')` configuration file:

```typescript
export default {
Expand Down Expand Up @@ -182,7 +182,7 @@ export class Handler extends HttpExceptionHandler {
Now you need to register your exception handler when
bootstrapping your application:

```typescript title="bootstrap/main.ts"
```typescript filename="Path.bootstrap('main.js')"
await ignite.httpServer({
exceptionHandlerPath: '#app/http/exceptions/Handler', 👈
})
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 `Path.config('http.ts')` file are handled
property is true in your `Path.config('http.js')` 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 `Path.config('http.ts')`
`@fastify/rate-limit` supports can be set inside `Path.config('http.js')`
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 `Path.config('http.ts')`
option of your `rateLimit` configuration in `Path.config('http.js')`
and set different rules in your routes:

```typescript
Expand Down
27 changes: 25 additions & 2 deletions docs/rest-api-application/routing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,40 @@ 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 `Path.config('http.ts')`
`@fastify/cors` supports can be set inside `Path.config('http.js')`
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 `Path.config('http.ts')` file.
from your `Path.config('http.js')` file.

:::tip

For more information on CORS and CORS headers, please
consult the [MDN web documentation on CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).

:::

## Custom route file path

You can change the name and the path of your `Path.route('http.js')` file.
To do that you need to set the new path to `Ignite.httpServer()` method:

```typescript filename="Path.bootstrap('dev.js')"
import { Ignite } from '@athenna/core'

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

await ignite.httpServer({
routePath: './bootstrap/routes/http-dev.js' 👈
})
```

:::tip

Always remember that when using relative paths to set something
in Athenna, you need to use your project root path as reference,
just like in the example above.

:::
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 `Path.config('http.ts')` file in the `swagger.configurations`
supports can be set inside `Path.config('http.js')` file in the `swagger.configurations`
object. And all the configurations that `@fastify/swagger-ui`
supports can be set inside `Path.config('http.ts')` file in the `swagger.ui` object:
supports can be set inside `Path.config('http.js')` file in the `swagger.ui` object:

```typescript
export default {
Expand Down
Loading

0 comments on commit 12862b9

Please sign in to comment.