-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from dolittle-entropy/multi-tenant-resources
Changing how we deal with resources
- Loading branch information
Showing
55 changed files
with
1,258 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Context | ||
|
||
As part of every web request coming into the system, there is an object that is set up that | ||
can be retrieved anywhere as part of the request. This holds the following: | ||
|
||
```typescript | ||
{ | ||
userId: string; | ||
tenantId: TenantId; | ||
cookies: string; | ||
} | ||
``` | ||
|
||
To access it, all you need to do is use the `getCurrentContext()` function from the context. | ||
|
||
```typescript | ||
import { getCurrentContext } from '@dolittle/vanir-backend/dist/web'; | ||
|
||
|
||
const context = getCurrentContext(); | ||
``` | ||
|
||
## Express Middleware | ||
|
||
The setting of this context is done through an express middleware. | ||
It looks at the HTTP header and sets up the context for the current request coming in. | ||
The default setup gets set up with this, but if you have your own setup and want to leverage | ||
this functionality - you can do so through the following: | ||
|
||
```typescript | ||
import express from 'express'; | ||
import { ContextMiddleware } from '@dolittle/vanir-backend/dist/web'; | ||
|
||
const app = express(); | ||
app.use(ContextMiddleware); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# TypeScript Backend | ||
|
||
## Table of contents | ||
|
||
| Title | Description | | ||
| ----- | ----------- | | ||
| [Anatomy](./anatomy-of-a-backend.md) | The anatomy of a TypeScript based backend | | ||
| [IoC](./ioc.md) | How to leverage the configured IoC container | | ||
| [Resources](./resources.md) | How to use the resource system in your backend | | ||
| [MongoDB](./mongodb.md) | How to use MongoDB in your backend | | ||
| [GraphQL](./graphql.md) | How to use GraphQL in your backend | | ||
| [Context](./context.md) | The context that is for the current web request | | ||
| [Logging](./logging.md) | How to use structured logging in your backend | | ||
| [Debugging](./debugging.md) | How to use debug your solution | | ||
| [Shared Projects](./shared-projects.md) | What are the shared projects from the template? | | ||
| [WebPack](./webpack.md) | How webpack works for your backend | |
Oops, something went wrong.