Refactor: Use @simpleworkjs/conf for configuration

- Replace ENV vars with proper config system
- Add conf/ directory with base, development, production, secrets
- Add secrets.example.js template
- Update .gitignore for secrets.js
- Show environment in startup banner
This commit is contained in:
2026-02-25 03:22:33 +00:00
parent 56933f59d1
commit 748636591b
8 changed files with 153 additions and 37 deletions

36
conf/base.js Normal file
View File

@@ -0,0 +1,36 @@
/**
* Base configuration - shared across all environments
*/
module.exports = {
server: {
port: 3000,
host: '0.0.0.0'
},
gateway: {
url: 'http://127.0.0.1:18789',
token: 'a41984619a5f4b9bf9148ab6eb4abca53eb796d046cbbec5'
},
session: {
secret: 'change-me-in-production',
maxAge: 24 * 60 * 60 * 1000 // 24 hours
},
auth: {
disabled: false,
ldap: {
enabled: false,
url: 'ldap://localhost:389',
baseDN: 'ou=users,dc=example,dc=com',
bindDN: '',
bindPassword: '',
searchFilter: '(uid={{username}})'
}
},
data: {
dir: './data'
}
};

16
conf/development.js Normal file
View File

@@ -0,0 +1,16 @@
/**
* Development environment configuration
*/
module.exports = {
auth: {
disabled: true, // Skip auth in dev
ldap: {
enabled: false
}
},
server: {
// Vite runs on 5173, proxy from there
}
};

22
conf/production.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* Production environment configuration
*/
module.exports = {
server: {
// Use PORT env var if set, otherwise default
port: parseInt(process.env.PORT) || 3000
},
session: {
// Should be set via secrets.js in production
secret: process.env.SESSION_SECRET || 'CHANGE-ME-NOW'
},
auth: {
disabled: false,
ldap: {
enabled: process.env.LDAP_ENABLED === 'true'
}
}
};

26
conf/secrets.example.js Normal file
View File

@@ -0,0 +1,26 @@
/**
* Example secrets file
*
* Copy this to secrets.js and fill in your actual values
* secrets.js is ignored by git
*/
module.exports = {
gateway: {
// Your OpenClaw gateway token
token: 'your-gateway-token-here'
},
session: {
// Random string for session signing
secret: 'generate-a-random-string-here'
},
auth: {
ldap: {
// LDAP bind credentials (if needed for search)
bindDN: 'cn=admin,dc=example,dc=com',
bindPassword: 'ldap-admin-password'
}
}
};