@saaslayer/config
v0.0.1
Published
Shared serverless config resolution (git:/file:/opt: variables via configorama) + deploy-time helpers (repo links, stage/branch).
Maintainers
Readme
@saaslayer/config
Shared serverless config resolution and deploy-time helpers for the monorepo.
Wraps configorama so stack configs can use
${git:…}, ${file:…}, ${opt:…} variables, while leaving osls-native ${sls:…} / ${aws:…}
variables for the Serverless Framework to resolve at deploy time (allowUnknownVars: true).
API
const { serverlessConfig, serverlessConfigAsync, repoLink, getCurrentBranch } = require('@saaslayer/config')serverlessConfig(pathOrOpts) / serverlessConfigAsync(pathOrOpts)
Resolve a stack.yml through configorama and return the config object. Used by yaml-based
stacks via a serverless.js entrypoint:
// control-plane/deployer-service/serverless.js
const { serverlessConfig } = require('@saaslayer/config')
module.exports = serverlessConfig(require('path').resolve(__dirname, 'stack.yml'))Pass { configPath, debug: true } to print the fully-resolved config and exit.
repoLink(dir?, ref?)
Build a browsable GitHub URL to a directory in this repo — for embedding in CloudFormation
stack Descriptions from JS/.mjs configs (which osls resolves natively, without configorama):
// services/manifest-service/serverless.mjs
import { repoLink } from '@saaslayer/config'
export default {
service: 'saaslayer-manifest',
// ...
resources: {
Description: `SaaSLayer control-plane manifest store. Source: ${repoLink(import.meta.dirname)}`,
},
}Defaults to the HEAD ref (stable across branches/merges); pass a ref (e.g. getCurrentBranch())
to link at a specific branch.
Why two mechanisms?
- yaml configs (
stack.yml) go throughserverlessConfig→ configorama resolves${git:dir}. - JS configs (
.mjs) compute the link in JavaScript withrepoLink()— no config-format conversion, works under plain osls.
