Compare commits

...

5 Commits

Author SHA1 Message Date
dc1879e754
css 2022-04-29 11:36:54 +03:00
d5d852b36d
ffs 2022-04-22 16:16:44 +03:00
54d84e24ed
auth stuff 2022-04-22 15:44:48 +03:00
36583590fd
database auth stuff 2022-04-22 15:21:29 +03:00
46ecdd5c38
arbitrary file sharing 2022-04-08 22:24:10 +03:00
7 changed files with 80 additions and 18 deletions

View File

@ -49,6 +49,21 @@ footer {
.background {
background-color: var(--gbot-blue);
height: 86vh;
/* background-color: #406c7e; */
/* opacity: 0.4; */
background-image: linear-gradient(30deg, #ffffff 12%, transparent 12.5%, transparent 87%, #ffffff 87.5%, #ffffff),
linear-gradient(150deg, #ffffff 12%, transparent 12.5%, transparent 87%, #ffffff 87.5%, #ffffff),
linear-gradient(30deg, #ffffff 12%, transparent 12.5%, transparent 87%, #ffffff 87.5%, #ffffff),
linear-gradient(150deg, #ffffff 12%, transparent 12.5%, transparent 87%, #ffffff 87.5%, #ffffff),
linear-gradient(60deg, #ffffff77 25%, transparent 25.5%, transparent 75%, #ffffff77 75%, #ffffff77),
linear-gradient(60deg, #ffffff77 25%, transparent 25.5%, transparent 75%, #ffffff77 75%, #ffffff77);
background-size: 52px 91px;
background-position: 0 0,
0 0,
26px 46px,
26px 46px,
0 0,
26px 46px;
}
.foreground {

1
server/.gitignore vendored
View File

@ -2,6 +2,7 @@ node_modules
logs
media
thumbnails
files
clipIndex.json
.env

View File

@ -12,7 +12,7 @@ class MongoDB {
if (!client) throw new Error('Missing reference to client!');
if (!config) throw new Error('No config file provided!');
if (config && (!config.database || !config.url)) throw new Error('Invalid config file provided!');
if (config && (!config.database || !config.host)) throw new Error('Invalid config provided!');
this.config = config;
this.client = null; // Mongo Client
@ -22,6 +22,13 @@ class MongoDB {
this.logger = new Logger(this);
this.logger._debug = this.parent._debug;
const { API_DB_USERNAME, API_DB_PASSWORD } = process.env;
this._auth = API_DB_USERNAME ? `${API_DB_USERNAME}:${API_DB_PASSWORD}@` : '';
}
URI(database) {
return `mongodb://${this._auth}${this.config.host}/${database}?authSource=${database}`;
}
async init() {
@ -29,8 +36,7 @@ class MongoDB {
this.logger.info('Initializing database connection.');
try {
const client = new MongoClient(this.config.url + this.config.database, { useUnifiedTopology: true });
const client = new MongoClient(this.URI(this.config.database), { useNewUrlParser: true });
this.client = await client.connect();
this.db = await this.client.db(this.config.database);
this.logger.info('Database connected.');

View File

@ -33,7 +33,7 @@ class Client extends EventEmitter {
this._debug = env.DEBUG;
this._mongoOpts = {
database: env.API_DB,
url: env.API_DB_URL
host: env.API_DB_HOST
};
this.ready = false;
@ -120,7 +120,7 @@ class Client extends EventEmitter {
resave: false,
saveUninitialized: false,
store: MongoStore.create({
mongoUrl: this._mongoOpts.url + env.API_SESSION_STORE,
mongoUrl: this.database.URI(env.API_SESSION_STORE),
collectionName: env.API_SESSION_COLLECTION
})
}));

View File

@ -0,0 +1,38 @@
// Endpoint for hosting arbitrary files
const { APIEndpoint } = require('../../interfaces');
const fs = require('fs');
const path = require('path');
class FilesEndpoint extends APIEndpoint {
constructor(client, opts) {
super(client, {
name: 'files',
path: '/files/:filename',
...opts
});
this.methods = [
['get', this.get.bind(this)]
];
this.init();
}
async get(req, res) {
const { filename } = req.params;
const _path = path.join(process.cwd(), 'files');
if (!fs.existsSync(_path)) return res.status(500).send('File serving not set up');
const files = fs.readdirSync(_path);
if (!filename || !files.includes(filename)) return res.status(404).end();
res.sendFile(`${filename}`, { root: _path });
}
}
module.exports = FilesEndpoint;

View File

@ -135,7 +135,7 @@ class Manager extends EventEmitter {
return {
NODE_ENV: env.NODE_ENV,
API_DB: env.API_DB,
API_DB_URL: env.API_DB_URL,
API_DB_HOST: env.API_DB_HOST,
API_SESSION_STORE: env.API_SESSION_STORE,
API_SESSION_COLLECTION: env.API_SESSION_COLLECTION,
API_USER_COLLECTION: env.API_USER_COLLECTION,
@ -146,7 +146,9 @@ class Manager extends EventEmitter {
DISCORD_ID: env.DISCORD_ID,
DISCORD_SCOPE: opts.discord.scope,
DOMAIN: opts.domain,
DEBUG: opts.debug
DEBUG: opts.debug,
API_DB_USERNAME: env.API_DB_USERNAME,
API_DB_PASSWORD: env.API_DB_PASSWORD
};
}

View File

@ -185,9 +185,9 @@
form-data "^3.0.0"
"@types/node@*":
version "17.0.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644"
integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==
version "17.0.25"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.25.tgz#527051f3c2f77aa52e5dc74e45a3da5fb2301448"
integrity sha512-wANk6fBrUwdpY4isjWrKTufkrXdu1D2YHCot2fD/DfWxF5sMrVSA+KN7ydckvaTCh0HiqX9IVl0L5/ZoXg5M7w==
"@types/webidl-conversions@*":
version "6.1.1"
@ -364,10 +364,10 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"
bson@^4.6.1:
version "4.6.1"
resolved "https://registry.yarnpkg.com/bson/-/bson-4.6.1.tgz#2b5da517539bb0f7f3ffb54ac70a384ca899641c"
integrity sha512-I1LQ7Hz5zgwR4QquilLNZwbhPw0Apx7i7X9kGMBTsqPdml/03Q9NBtD9nt/19ahjlphktQImrnderxqpzeVDjw==
bson@^4.6.2:
version "4.6.3"
resolved "https://registry.yarnpkg.com/bson/-/bson-4.6.3.tgz#d1a9a0b84b9e84b62390811fc5580f6a8b1d858c"
integrity sha512-rAqP5hcUVJhXP2MCSNVsf0oM2OGU1So6A9pVRDYayvJ5+hygXHQApf87wd5NlhPM1J9RJnbqxIG/f8QTzRoQ4A==
dependencies:
buffer "^5.6.0"
@ -1208,11 +1208,11 @@ mongodb-connection-string-url@^2.5.2:
whatwg-url "^11.0.0"
mongodb@^4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-4.4.1.tgz#e604cfbe2d5e125ae156ad04b52d261bed480b99"
integrity sha512-IAD3nFtCR4s22vi5qjqkCBnuyDDrOW8WVSSmgHquOvGaP1iTD+XpC5tr8wAUbZ2EeZkaswwBKQFHDvl4qYcKqQ==
version "4.5.0"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-4.5.0.tgz#d74c2008567b606dccef220f62a44cd7b934eb92"
integrity sha512-A2l8MjEpKojnhbCM0MK3+UOGUSGvTNNSv7AkP1fsT7tkambrkkqN/5F2y+PhzsV0Nbv58u04TETpkaSEdI2zKA==
dependencies:
bson "^4.6.1"
bson "^4.6.2"
denque "^2.0.1"
mongodb-connection-string-url "^2.5.2"
socks "^2.6.2"