Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix outdated content in the Preparing to Production topic #2086

Merged
merged 4 commits into from
Oct 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 15 additions & 24 deletions docs/preparing-to-production.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,26 @@ An application is built for production using the **build** script, and run in th

An example **config.prod.js** file:

<!-- prettier-ignore-start -->

[embedmd]:# (../examples/js/hacker-news/config.prod.js /^/ /\n$/)
```js
// config.prod.js
const prodConfig = {
port: 3000,
mode: 'production',
readModelConnectors: {
HackerNews: {
module: '@resolve-js/readmodel-lite',
options: {}
}
options: {},
},
},
jwtCookie: {
name: 'jwt',
maxAge: 31536000000
}
maxAge: 31536000000,
},
}

export default prodConfig
```

<!-- prettier-ignore-end -->

## Configuring Adapters

Before you move your app into production, specify all required [adapters](adapters.md) in the production config.
Expand All @@ -44,34 +40,27 @@ Depending on your requirements, you may want to specify storage adapters for eve

The code below demonstrates how to set up a storage adapter on the example of an in-memory Read Model storage:

<!-- prettier-ignore-start -->

[embedmd]:# (../examples/js/hacker-news/config.prod.js /readModelConnectors/ /\},/)
```js
readModelConnectors: {
// config.prod.js
const prodConfig = {
readModelConnectors: {
HackerNews: {
module: '@resolve-js/readmodel-lite',
options: {}
}
options: {},
},
},
...
}
```

<!-- prettier-ignore-end -->

In addition to storage adapters, you can specify adapters that define how your application communicates with underlying APIs. For example, use the API handler adapters, to define how your application handles API requests.
You can also provide a bus adapter and subscribe adapter to define how your application sends events and subscribes to events.

## Using Environment Variables

Use the **declareRuntimeEnv** function from the **@resolve-js/scripts** library to bind a configuration setting value to an environment variable:

```js
// config.prod.js
import { declareRuntimeEnv } from '@resolve-js/scripts'
export default {
subscribeAdapter: {
module: '@resolve-js/subscribe-mqtt',
options: {},
},
readModelsConnectors: {
HackerNews: {
module: '@resolve-js/readmodel-postgresql',
Expand All @@ -85,7 +74,9 @@ export default {
},
},
},
...
}
export default prodConfig
```

This approach is useful when you need to assign settings that should not be included in application sources (e.g., authentication credentials or secret keys) or settings that should be defined by a server instance.