update folder stucture and improve documentation

This commit is contained in:
hippoz 2021-03-13 03:42:01 +02:00
parent e41a04999c
commit a47d938b7e
Signed by untrusted user who does not match committer: hippoz
GPG key ID: 7C52899193467641
29 changed files with 4821 additions and 2223 deletions

View file

@ -1,52 +1,8 @@
# Brainlet
Brainlet is a simple chat app. Each category has a text channel associated with it, all messages sent in the text channel are temporary, while in the category itself all posts are permanent.
# Resources
As its database, it uses Mongo DB.
## Self-hosting
So you wanna host Brainlet yourself, huh?
## Self hosting
Firstly, you're gonna need a MongoDB server, I just use Docker for the Mongo server, but you can *try* to not use Docker, though Mongo does not want to standalone on anything outside a perfect debian system or windows, so just use Docker. (if you are on windows, simply install mongo normally, it should work nicely)
Let create a Docker container for Mongo!
```
docker run -it -v mongodata:/data/db -p 27017:27017 --name mongodb -d mongo
```
This should automatically run it, however, next time you need it you gotta run:
```
docker start mongodb
```
Stopping it is as simple as:
```
docker stop mongodb
```
Now that we have a Mongo server set up, let's actually begin to set up the Brainlet server.
***NOTE***: You need nodejs and npm installed in order to proceed! I recommend using node 12.x, but anything above that will probably work.
Once you have installed node, clone the repo and then cd into it.
Then, run the following command:
```
npm i
```
This will install all of the node modules.
***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.
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)
### You should now be ready to go!
Just run Brainlet with the command below:
```
node index.js
```
Afterwards, try going [here](http://localhost:3005/auth.html) to visit the site.
Good luck!
So you want to host brainlet yourself? Head over to the [self hosting guide](resources/Guides/HOSTING.md)! See you there!

4725
brainlet/package-lock.json generated Executable file

File diff suppressed because it is too large Load diff

29
brainlet/package.json Executable file
View file

@ -0,0 +1,29 @@
{
"name": "dictionar",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-rate-limit": "^5.1.3",
"express-validator": "^6.6.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.10.0",
"semver": "^5.7.1",
"socket.io": "^3.0.1",
"uuid": "^8.3.1",
"ws": "^7.4.3"
},
"devDependencies": {
"eslint": "^7.21.0"
}
}

View file

@ -1,6 +0,0 @@
vulns:
- you can send a malformed request and express will send the full error
- 2 users can have the same name if one of the letters is uppercase
notes:
- please remove excessive whitespace please

2135
package-lock.json generated Executable file → Normal file

File diff suppressed because it is too large Load diff

29
package.json Executable file → Normal file
View file

@ -1,28 +1 @@
{
"name": "dictionar",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-rate-limit": "^5.1.3",
"express-validator": "^6.6.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.10.0",
"socket.io": "^3.0.1",
"uuid": "^8.3.1",
"ws": "^7.4.3"
},
"devDependencies": {
"eslint": "^7.21.0"
}
}
{}

View file

@ -1,5 +1,7 @@
# Waffle API docs (currently not implemented)
*Again, this IS NOT YET IMPLEMENTED IN THE CURRENT BRAINLET RELEASE*
# Gateway
Waffle uses a WebSocket gateway to transmit various updates from the server to the client and vice-versa (new message, user disconnecting, connect to voice, etc.)

View file

@ -0,0 +1,58 @@
# Self-hosting
## Preface
So you wanna host Brainlet yourself, huh?
This guide assumes you're using Linux, though these instructions can easily be translated to Windows or Mac.
## MongoDB setup
Firstly, you're gonna need a MongoDB server, I just use Docker for the Mongo server, but you can *try* to not use Docker, though it can get tricky sometimes.
Let create a Docker container for Mongo!
```
docker run -it -v mongodata:/data/db -p 27017:27017 --name mongodb -d mongo
```
This should automatically run it, however, next time you need it you gotta run:
```
docker start mongodb
```
Stopping it is as simple as:
```
docker stop mongodb
```
Now that we have a Mongo server set up, let's actually begin to set up the Brainlet server.
## Server setup
You need nodejs and npm installed in order to proceed! I recommend using node 12.x.
Once you have installed node, clone the repo and then cd into the brainlet folder.
Then, run the following command:
```
npm i
```
This will install all of the node modules.
## Post-install
### The secret.js file (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.
If you don't set one yourself, a private key will be randomly generated each time the server starts.
### The config.js file (important)
You need to edit the config.js file in order to allow your domain to CORS, and make various tweaks to how the server behaves. This will be better documented in the future.
## You should now be ready to go!
Just run Brainlet with the command below:
```
node index.js
```
Afterwards, try going to [http://localhost:3005/auth.html](http://localhost:3005/auth.html) to visit the site, assuming default port config.
Good luck!

View file

@ -1,10 +0,0 @@
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");
}