Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuspoehls committed Jan 21, 2022
1 parent 9522963 commit 0bae455
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
5 changes: 2 additions & 3 deletions application.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ You’ll find bootstrapping files for HTTP and console applications inside of th


## IoC Container
Supercharge’s `Application` class is also an IoC container used to manage class dependencies. This allows apps to follow the concept of dependency injection. Well, dependency injection is a funky term that basically describes “injecting” dependencies into a class.

Injecting dependencies instead of letting classes resolve them on their own has the benefit of controlling the dependencies instead of relying on existing setups. Controlling dependencies is especially helpful during testing.
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.

👉 [IoC Container docs](/docs/service-container)

## Start a Web Application
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:
Expand Down
3 changes: 2 additions & 1 deletion navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module.exports = {
// Development: 'development',
Deployment: 'deployment',
// Bootstrappers: 'bootstrappers'
'Service Providers': 'service-providers'
'Service Container': 'service-container',
'Service Providers': 'service-providers',
}
},

Expand Down
44 changes: 44 additions & 0 deletions service-providers.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,53 @@
# Service Providers


- [Introduction](#introduction)
- [Creating Service Providers](#creating-service-providers)
- [The Register method](#the-register-method)
- [The Boot method](#the-boot-method)
- [Registering Providers](#registering-providers)



## Introduction
tba.


## Creating Service Providers
All service providers should extends the `ServiceProvider` class provided by `@supercharge/support`. The main methods you can implement in your service provider are `register` and `boot`:

```ts
import { ServiceProvider } from '@supercharge/support'
import { MarkdownRenderer } from './markdown-renderer'

export class MarkdownServiceProvider extends ServiceProvider {
/**
* Register application services to the container.
*/
override register (): void {
this.app().singleton(MarkdownRenderer, () => {
return new MarkdownRenderer(this.app())
})
}

/**
* Boot application services.
*/
override async boot (): Promise<void> {
await this.app().make(MarkdownRenderer).boot()
}
}
```



### The Register Method
tba.


### The Boot Method
tba.


## Registering Providers
tba.

0 comments on commit 0bae455

Please sign in to comment.