Make default configuration work

This commit is contained in:
hiimgoodpack 2021-01-25 10:17:22 -05:00
parent 45a4a50812
commit 869c20e035
Signed by: hiimgoodpack
GPG key ID: 4E0E62733C14AE69
4 changed files with 14 additions and 11 deletions

View file

@ -33,13 +33,9 @@ npm i
```
This will install all of the node modules.
Then, run:
```
cp secret.js.template secret.js
```
This will create a new secret.js based on that template.
***OPTIONAL***: You may want to edit secret.js and have jwtPrivateKey set to a randomly generated key, such as with /dev/urandom. This will allow session cookies to persist after server reboot.
***IMPORTANT***: Open secret.js with your favourite editor, and set the jwtPrivateKey variable to a random string of characters, preferably generated from /dev/urandom or using node's own generation thing.
If you don't set one yourself, a private key will be randomly generated each time the server starts.
***NOTE***: You can edit config.js to tweak some of the settings. You might wanna do that, especially if you are planning to run it on a domain. (setting the address variable)
@ -51,4 +47,4 @@ Just run Brainlet with the command below:
node index.js
```
Good luck!
Good luck!

View file

@ -9,7 +9,7 @@ module.exports = {
// }
//},
corsAllowList: [ 'localhost' ],
mongoUrl: 'mongodb://192.168.0.105:27017/app',
mongoUrl: 'mongodb://localhost:27017/app',
bcryptRounds: 10,
roleMap: {
'BANNED': 0,

10
secret.js Executable file
View file

@ -0,0 +1,10 @@
module.exports = {
jwtPrivateKey: 'KEY'
};
// Set default values
// You shouldn't need to touch this for configuring this
if (module.exports.jwtPrivateKey === 'KEY') {
console.error('[*] [config] jwtPrivateKey was not specified in secret.js. A randomly generated private key will be used instead');
module.exports.jwtPrivateKey = require('crypto').randomBytes(129).toString('base64');
}

View file

@ -1,3 +0,0 @@
module.exports = {
jwtPrivateKey: 'KEY'
};