-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c88a56
commit 5fff14b
Showing
12 changed files
with
61 additions
and
51 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
46 changes: 24 additions & 22 deletions
46
packages/docs-site/src/components/homepage/config-example.ts
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 |
---|---|---|
@@ -1,39 +1,41 @@ | ||
import { | ||
DmnoBaseTypes, defineDmnoService, switchBy, configPath, pick, | ||
} from 'dmno'; | ||
import { EncryptedVaultDmnoPlugin, EncryptedVaultTypes } from '@dmno/encrypted-vault-plugin'; | ||
import { DmnoBaseTypes, defineDmnoService, switchBy, configPath, pick } from 'dmno'; | ||
import { OnePasswordDmnoPlugin, OnePasswordTypes } from '@dmno/1password-plugin'; | ||
|
||
// use a plugin to fetch secrets from a secure backend like 1Password | ||
// use plugins to fetch sensitive config from secure locations like 1Password | ||
const onePassSecrets = new OnePasswordDmnoPlugin('1pass', { token: configPath('OP_TOKEN') }); | ||
// or store them encrypted within your repo | ||
const vaultFileSecrets = new EncryptedVaultDmnoPlugin('vault', { key: configPath('DMNO_VAULT_KEY') }); | ||
|
||
export default defineDmnoService({ | ||
// re-use items defined in other services | ||
|
||
// more config specific to this service | ||
schema: { | ||
API_KEY: pick(), | ||
DB_URL: pick(), | ||
DMNO_ENV: pick(), | ||
DMNO_VAULT_KEY: { | ||
// re-use existing types with validation and docs info built-in | ||
extends: EncryptedVaultTypes.encryptionKey, | ||
}, | ||
OP_TOKEN: { | ||
extends: OnePasswordTypes.serviceAccountToken, | ||
APP_ENV: { | ||
// docs are built in, and flow into generated TypeScript types / IntelliSense | ||
description: 'our custom environment flag', | ||
extends: DmnoBaseTypes.enum(['development', 'preview', 'staging', 'production', 'test']), | ||
value: 'development', // default value | ||
}, | ||
SAAS_API_KEY: { | ||
// built-in types have validation helpers for many common needs | ||
extends: DmnoBaseTypes.string({ startsWith: 'pk_', isLength: 35 }), | ||
// sensitive items get special handling to prevent leaks | ||
sensitive: true, | ||
// load different values based on any other value | ||
value: switchBy('DMNO_ENV', { | ||
value: switchBy('APP_ENV', { | ||
_default: 'my-dev-key', | ||
production: onePassSecrets.item(), | ||
}), | ||
}, | ||
SAAS_PROJECT_TAG: { | ||
LOGS_TAG: { | ||
// use a function to set a value - reference any other config | ||
value: () => `myapp_${DMNO_CONFIG.DMNO_ENV}`, | ||
value: () => `myapp-frontend_${DMNO_CONFIG.APP_ENV}`, | ||
}, | ||
PORT: { | ||
extends: DmnoBaseTypes.port, // pre-made types built-in for many common cases | ||
value: 4444, | ||
}, | ||
// re-use config from other services (if in a monorepo) | ||
API_URL: pick('api', 'PUBLIC_URL'), | ||
OP_TOKEN: { | ||
// re-use existing types with validation and docs info already built-in | ||
extends: OnePasswordTypes.serviceAccountToken, | ||
}, | ||
}, | ||
}); |
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
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
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
Oops, something went wrong.