Skip to content

Commit 85cc65e

Browse files
committed
docs: Add documentation for loadConfig
1 parent 5bc537d commit 85cc65e

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,40 @@ You have two options to connect to parse server.
3737
1. By providing a json config file
3838
2. By providing an env with the necessary values set.
3939

40+
`loadConfig(...)` checks provided config in the following order:
41+
42+
1. options.operation === "down" ==> Set Config from process.env ==> return:
43+
44+
```ts
45+
Config.initialize({
46+
publicServerURL: PARSE_SERVER_DOWN_SCHEMA_SERVER_URL,
47+
appId: PARSE_SERVER_DOWN_SCHEMA_APPID,
48+
masterKey: PARSE_SERVER_DOWN_SCHEMA_MASTERKEY,
49+
});
50+
```
51+
52+
2. options.operation === "up" ==> Set Config from process.env ==> return:
53+
54+
```ts
55+
Config.initialize({
56+
publicServerURL: PARSE_SERVER_UP_SCHEMA_SERVER_URL,
57+
appId: PARSE_SERVER_UP_SCHEMA_APPID,
58+
masterKey: PARSE_SERVER_UP_SCHEMA_MASTERKEY,
59+
});
60+
```
61+
62+
3. Check for default process.env variable and use these, then return:
63+
64+
```ts
65+
Config.initialize({
66+
publicServerURL: PARSE_SERVER_URL || PARSE_PUBLIC_SERVER_URL,
67+
appId: PARSE_SERVER_APPLICATION_ID,
68+
masterKey: PARSE_SERVER_MASTER_KEY,
69+
});
70+
```
71+
72+
4. Look for `parse-server.config.json` or provided config path.
73+
4074
### 1. Config files
4175

4276
By default the config file is expected to be in _./config/parse-server.config.json_
@@ -151,9 +185,12 @@ A GitHub workflow publishes the package automatically to npm.
151185
import { loadConfig, up, down, typescript } from "@openinc/parse-server-schema";
152186

153187
// load JSON file with config
154-
await loadConfig("./parse-server-config.json");
188+
loadConfig("./parse-server-config.json");
155189
// or load config from process.env
156-
await loadConfig();
190+
loadConfig();
191+
// when using distinct up and down servers
192+
loadConfig(undefined, { operation: "up" });
193+
loadConfig(undefined, { operation: "down" });
157194

158195
await up(schemaPath);
159196

0 commit comments

Comments
 (0)