Skip to content

Commit aca445a

Browse files
committed
add paths
1 parent ad683dd commit aca445a

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed

application.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ You’ll find bootstrapping files for HTTP and console applications inside of th
1111

1212

1313
## IoC Container
14-
Supercharge’s `Application` class is also an [IoC container](/docs/service-container) used to manage class dependencies. This allows apps to follow the concept of dependency injection.
14+
Supercharge’s `Application` class is also an [IoC container](/docs/service-container) used to manage class dependencies. This allows apps to follow the concept of dependency injection. Find more details about the service container in the related docs:
1515

16-
👉 [IoC Container docs](/docs/service-container)
16+
👉 [IoC Service Container docs](/docs/service-container)
1717

1818
## Start a Web Application
1919
The `server.ts` file in your root directory contains the logic to serve a Supercharge web app. It creates a new application and starts the HTTP server. Serving an HTTP server is as simple as invoking the `server.ts` file with Node.js to start a web application:
@@ -30,3 +30,76 @@ The `craft.ts` file in your application directory is the entry point to serve a
3030
ts-node craft.ts
3131
```
3232

33+
34+
## Application Paths
35+
You’ll find references to Supercharge’s `app` instance in most parts of the framework. And also within the documentation. The reason is that your `app` instance is the central place storing the base path to your application’s directory. Your base directory is the starting point to resolve paths to directories in your Supercharge application.
36+
37+
38+
### `App.basePath()`
39+
The `App.basePath` method returns the absolute path to your application’s root directory:
40+
41+
```ts
42+
const path = app.basePath()
43+
// /home/users/marcus/dev/supercharge/superchargejs.com
44+
```
45+
46+
47+
### `App.configPath()`
48+
The `App.configPath` method returns the absolute path to your application’s `config` directory. You can also generate an absolute path to a given file within the configuration directory:
49+
50+
```ts
51+
const path = app.configPath()
52+
// <base-path>/config
53+
54+
const path = app.configPath('app.ts')
55+
// <base-path>/config/app.ts
56+
```
57+
58+
59+
### `App.publicPath()`
60+
The `App.publicPath` method returns the absolute path to your application’s `public` directory. You can also generate an absolute path to a given file within the public directory:
61+
62+
```ts
63+
const path = app.publicPath()
64+
// <base-path>/public
65+
66+
const path = app.publicPath('js/app.js')
67+
// <base-path>/public/js/app.js
68+
```
69+
70+
71+
### `App.resourcePath()`
72+
The `App.resourcePath` method returns the absolute path to your application’s `resources` directory. You can also generate an absolute path to a given file within the resources directory:
73+
74+
```ts
75+
const path = app.resourcePath()
76+
// <base-path>/resources
77+
78+
const path = app.resourcePath('js/app.ts')
79+
// <base-path>/resource/js/app.ts
80+
```
81+
82+
83+
### `App.storagePath()`
84+
The `App.storagePath` method returns the absolute path to your application’s `storage` directory. You can also generate an absolute path to a given file within the storage directory:
85+
86+
```ts
87+
const path = app.storagePath()
88+
// <base-path>/storage
89+
90+
const path = app.storagePath('cache/sessions')
91+
// <base-path>/storage/cache/sessions
92+
```
93+
94+
95+
### `App.databasePath()`
96+
The `App.databasePath` method returns the absolute path to your application’s `database` directory. You can also generate an absolute path to a given file within the database directory:
97+
98+
```ts
99+
const path = app.databasePath()
100+
// <base-path>/database
101+
102+
const path = app.databasePath('migrations/create-users-table-20220124.ts')
103+
// <base-path>/database/migrations/create-users-table-20220124.ts
104+
```
105+

0 commit comments

Comments
 (0)