Skip to content

Commit

Permalink
feat: use node-config for loading application configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jrassa committed Feb 6, 2024
1 parent 10d9501 commit 32c6369
Show file tree
Hide file tree
Showing 24 changed files with 305 additions and 390 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
/public

# Config Files
/config/env/development.js
/config/env/dev-sender.js
/config/env/development-*.js
/config/development.js
/config/dev-sender.js
/config/development-*.js

# Packages
*.tar.gz
Expand Down
16 changes: 16 additions & 0 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"port": "PORT",
"app": {
"contactEmail": "CONTACT_EMAIL"
},
"mailer": {
"from": "MAILER_FROM",
"options": {
"host": "MAILER_SERVICE_PROVIDER",
"auth": {
"user": "MAILER_EMAIL_ID",
"pass": "MAILER_PASSWORD"
}
}
}
}
271 changes: 127 additions & 144 deletions config/env/default.js → config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,51 @@ const contactEmail =
'[email protected]';

module.exports = {
mode: 'production',

// The port to use for the application (defaults to the environment variable if present)
port: process.env.PORT || 3001,

// Basic title and instance name
app: {
title: 'Node REST Starter',
instanceName: 'node-rest-starter',
description: 'Node REST app',
clientUrl: 'http://localhost/#',
helpUrl: 'http://localhost/#/help',
contactEmail: contactEmail
},

/**
* Core System Settings
*/

apiDocs: {
enabled: true,
path: '/api-docs',
jsonPath: '/api/spec.json',
uiOptions: {}
},

actuator: {
enabled: true,
options: {
basePath: '/actuator'
}
},

// SocketIO Settings
socketio: {
ignoreOlderThan: 600
},

cors: {
enabled: false,
options: {
credentials: true
}
},

assets: {
models: ['src/**/*.model!(.spec).{js,ts}'],
routes: ['src/**/*.routes!(.spec).{js,ts}'],
Expand Down Expand Up @@ -80,10 +122,10 @@ module.exports = {
// },
// cacheExpire: 1000*60*60*24 // expiration of cache entries
// },
//
// autoLogin: true,
// autoCreateAccounts: true,
// defaultRoles: { user: true },

autoLogin: false,
autoCreateAccounts: false,
defaultRoles: {},
// requiredRoles: ['ROLE'],

roles: ['user', 'editor', 'auditor', 'admin'],
Expand Down Expand Up @@ -158,49 +200,48 @@ module.exports = {
},
mongooseFailOnIndexOptionsConflict: true,

/**
* Environment Settings
/*
* The maximum time in milliseconds allowed for processing operation on the cursor by a mongo query
*/
maxTimeMS: 30000,

// Basic title and instance name
app: {
title: 'Node REST Starter',
name: 'Node Rest Starter',
instanceName: 'node-rest-starter',
url: {
protocol: 'http',
host: 'localhost',
port: 3000
},
clientUrl: 'http://localhost/#',
helpUrl: 'http://localhost/#/help',
contactEmail: contactEmail
},

// Header/footer
banner: {
// The string to display
html: 'DEFAULT SETTINGS',

// additional CSS class to apply to the banner
style: 'default'
},

// Copyright footer (shown above the system footer)
copyright: {
// HTML-enabled contents of the banner
html: 'Copyright © 2018 <a href="http://www.asymmetrik.com" target="_blank">Asymmetrik, Ltd</a>. All Rights Reserved.'
},
/*
* The maximum time in milliseconds allowed for a count operation on the cursor by a mongo search/pagination query
*/
maxCountTimeMS: 5000,

feedback: {
showFlyout: true,
showInSidebar: true,
/**
* Environment Settings
*/

classificationOpts: [
{ level: 'LEVEL-1', prefix: '(L1)' },
{ level: 'LEVEL-2', prefix: '(L2)' },
{ level: 'LEVEL-3', prefix: '(L3)' }
]
// Configuration for outgoing mail server / service
mailer: {
from: process.env.MAILER_FROM || '[email protected]',
provider: './src/app/core/email/providers/smtp-email.provider',
options: {
host: process.env.MAILER_SERVICE_PROVIDER || 'gmail',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: process.env.MAILER_EMAIL_ID || '[email protected]',
pass: process.env.MAILER_PASSWORD || 'PASSWORD'
}
}
/*
provider: './src/app/core/email/providers/log-email.server.provider',
options: {}
*/
/*
provider: './src/app/core/email/providers/https-email.server.provider',
options: {
host: '',
port: ,
path: '',
ca: '/path/to/ca.crt',
cert: '/path/to/cert.crt',
key: '/path/to/cert.key'
}
*/
},

coreEmails: {
Expand All @@ -214,7 +255,7 @@ module.exports = {
enabled: true,
templatePath:
'src/app/core/user/templates/user-signup-alert-email.server.view.html',
subject: 'New Account Request - {{ app.serverUrl }}',
subject: 'New Account Request - {{ app.clientUrl }}',
to: contactEmail
},
welcomeNoAccess: {
Expand Down Expand Up @@ -297,36 +338,28 @@ module.exports = {
auditExpires: 15552000, //180 days
feedbackExpires: 15552000, // 180 days

// Configuration for outgoing mail server / service
mailer: {
from: process.env.MAILER_FROM || '[email protected]',
provider: './src/app/core/email/providers/smtp-email.provider',
options: {
host: process.env.MAILER_SERVICE_PROVIDER || 'gmail',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: process.env.MAILER_EMAIL_ID || '[email protected]',
pass: process.env.MAILER_PASSWORD || 'PASSWORD'
}
}
/*
provider: './src/app/core/email/providers/log-email.server.provider',
options: {}
*/
/*
provider: './src/app/core/email/providers/https-email.server.provider',
options: {
host: '',
port: ,
path: '',
ca: '/path/to/ca.crt',
cert: '/path/to/cert.crt',
key: '/path/to/cert.key'
}
*/
teams: {
implicitMembers: {
/**
* 'roles' strategy matches user.externalRoles against team.requiresExternalRoles to determine implicit
* membership in team. User must have all of the specified roles to be granted access to team.
*/
strategy: 'roles'

/**
* 'teams' strategy matches user.externalGroups against team.requiresExternalGroups to determine implicit
* membership in team. User mush have one of the specified roles to be granted access to team.
*/
// strategy: 'teams'
},
nestedTeams: false
},

/*
* Whether the delete user functionality is enabled or disabled
*/
allowDeleteUser: true,

/**
* Development/debugging settings
*/
Expand All @@ -349,7 +382,7 @@ module.exports = {
application: [
// Console logger
{
stream: process.stdout,
stream: 'process.stdout',
level: 'info'
} //,
// Rotating file logger
Expand All @@ -373,7 +406,7 @@ module.exports = {
audit: [
// Console logger (audit logger must be 'info' level)
{
stream: process.stdout,
stream: 'process.stdout',
level: 'info'
} //,
//{
Expand All @@ -387,7 +420,7 @@ module.exports = {
metrics: [
// Console logger (audit logger must be 'info' level)
{
stream: process.stdout,
stream: 'process.stdout',
level: 'info'
} //,
//{
Expand All @@ -400,82 +433,32 @@ module.exports = {
]
},

teams: {
implicitMembers: {
/**
* 'roles' strategy matches user.externalRoles against team.requiresExternalRoles to determine implicit
* membership in team. User must have all of the specified roles to be granted access to team.
*/
strategy: 'roles'

/**
* 'teams' strategy matches user.externalGroups against team.requiresExternalGroups to determine implicit
* membership in team. User mush have one of the specified roles to be granted access to team.
*/
// strategy: 'teams'
},
nestedTeams: false
},

/**
* Not So Environment-Specific Settings
* UI Settings
*/
// Header/footer
banner: {
// The string to display
html: 'DEFAULT SETTINGS',

apiDocs: {
enabled: true,
path: '/api-docs'
},

actuator: {
enabled: true,
options: {
basePath: '/actuator'
}
},

// The port to use for the application (defaults to the environment variable if present)
port: process.env.PORT || 3001,

// SocketIO Settings
socketio: {
ignoreOlderThan: 600
// additional CSS class to apply to the banner
style: 'default'
},

// CSV Export Settings
csv: {
delayMs: 0
// Copyright footer (shown above the system footer)
copyright: {
// HTML-enabled contents of the banner
html: 'Copyright © 2018 <a href="http://www.asymmetrik.com" target="_blank">Asymmetrik, Ltd</a>. All Rights Reserved.'
},

/*
* The maximum time in milliseconds allowed for processing operation on the cursor by a mongo query
*/
maxTimeMS: 30000,

/*
* The maximum time in milliseconds allowed for a count operation on the cursor by a mongo search/pagination query
*/
maxCountTimeMS: 5000,

/*
* The maximum number of records allowed to be exported to csv
*/
maxExport: 1000,

/*
* Configurations for External Services
*/
external: {},

/*
* Whether the delete user functionality is enabled or disabled
*/
allowDeleteUser: true,
feedback: {
showFlyout: true,
showInSidebar: true,

cors: {
enabled: false,
options: {
credentials: true
// origin: 'http://example.com'
}
classificationOpts: [
{ level: 'LEVEL-1', prefix: '(L1)' },
{ level: 'LEVEL-2', prefix: '(L2)' },
{ level: 'LEVEL-3', prefix: '(L3)' }
]
}
};
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 32c6369

Please sign in to comment.