aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPitu <[email protected]>2017-10-03 19:48:26 -0300
committerPitu <[email protected]>2017-10-03 19:48:26 -0300
commitc1963b28099dfb89cc8d080719ac2c12a885df30 (patch)
tree87073cc4ff18a526cfee1f9c02f349b8713b18dc
parentMerge remote-tracking branch 'origin/master' (diff)
downloadhost.fuwn.me-c1963b28099dfb89cc8d080719ac2c12a885df30.tar.xz
host.fuwn.me-c1963b28099dfb89cc8d080719ac2c12a885df30.zip
Changed how domains are handled
-rw-r--r--config.sample.js48
-rw-r--r--lolisafe.js74
2 files changed, 62 insertions, 60 deletions
diff --git a/config.sample.js b/config.sample.js
index 5bc76ce..4555f3e 100644
--- a/config.sample.js
+++ b/config.sample.js
@@ -7,25 +7,25 @@ module.exports = {
If it's set to false, then upload will be public for anyone to use.
*/
private: true,
-
+
// If true, users will be able to create accounts and access their uploaded files
enableUserAccounts: true,
-
- // The registered domain where you will be serving the app. Use IP if none.
- domains: [
-
- /*
- You need to specify the base domain where loli-self is running
- and how should it resolve the URL for uploaded files. For example:
- */
- // Files will be served at http(s)://i.kanacchi.moe/Fxt0.png
- { host: 'kanacchi.moe', resolve: 'https://i.kanacchi.moe'},
+ /*
+ Here you can decide if you want lolisafe to serve the files or if you prefer doing so via nginx.
+ The main difference between the two is the ease of use and the chance of analytics in the future.
+ If you set it to `true`, the uploaded files will be located after the host like:
+ https://lolisafe.moe/yourFile.jpg
- // Files will be served at https://my.kanacchi.moe/loli-self/files/Fxt0.png
- { host: 'kanacchi.moe', resolve: 'https://my.kanacchi.moe/loli-self/files' }
+ If you set it to `false`, you need to specify the domain in the setting right below `serveFilesWithNode`
+ and make nginx directly serve whatever folder it is you are serving your downloads in. This also gives
+ you the ability to serve them, for example, like this:
+ https://files.lolisafe.moe/yourFile.jpg
- ],
+ So ultimately, it's up to you.
+ */
+ serveFilesWithNode: false,
+ domain: '',
// Port on which to run the server
port: 9999,
@@ -48,18 +48,20 @@ module.exports = {
// Folder where images should be stored
folder: 'uploads',
- // Max file size allowed. Needs to be in MB
- // Note: When maxSize is greater than 1 MiB,
- // you must set the client_max_body_size
- // to the same as maxSize.
+ /*
+ Max file size allowed. Needs to be in MB
+ Note: When maxSize is greater than 1 MiB, you must set the client_max_body_size to the same as maxSize.
+ */
maxSize: '512MB',
// The length of the random generated name for the uploaded files
fileLength: 32,
- // NOTE: Thumbnails are only for the admin panel and they require you
- // to install a separate binary called graphicsmagick (http://www.graphicsmagick.org)
- // for images and FFmpeg (https://ffmpeg.org/) for video files
+ /*
+ NOTE: Thumbnails are only for the admin panel and they require you
+ to install a separate binary called graphicsmagick (http://www.graphicsmagick.org)
+ for images and ffmpeg (https://ffmpeg.org/) for video files
+ */
generateThumbnails: false
},
@@ -69,9 +71,7 @@ module.exports = {
// The following values shouldn't be touched
database: {
client: 'sqlite3',
- connection: {
- filename: './database/db'
- },
+ connection: { filename: './database/db' },
useNullAsDefault: true
}
}
diff --git a/lolisafe.js b/lolisafe.js
index 0255b0e..a9c7f45 100644
--- a/lolisafe.js
+++ b/lolisafe.js
@@ -1,55 +1,57 @@
-const config = require('./config.js')
-const api = require('./routes/api.js')
-const album = require('./routes/album.js')
-const express = require('express')
-const helmet = require('helmet')
-const bodyParser = require('body-parser')
-const RateLimit = require('express-rate-limit')
-const db = require('knex')(config.database)
-const fs = require('fs')
-const exphbs = require('express-handlebars')
-const safe = express()
+const config = require('./config.js');
+const api = require('./routes/api.js');
+const album = require('./routes/album.js');
+const express = require('express');
+const helmet = require('helmet');
+const bodyParser = require('body-parser');
+const RateLimit = require('express-rate-limit');
+const db = require('knex')(config.database);
+const fs = require('fs');
+const exphbs = require('express-handlebars');
+const safe = express();
require('./database/db.js')(db)
-fs.existsSync('./pages/custom' ) || fs.mkdirSync('./pages/custom')
-fs.existsSync('./' + config.logsFolder) || fs.mkdirSync('./' + config.logsFolder)
-fs.existsSync('./' + config.uploads.folder) || fs.mkdirSync('./' + config.uploads.folder)
-fs.existsSync('./' + config.uploads.folder + '/thumbs') || fs.mkdirSync('./' + config.uploads.folder + '/thumbs')
+fs.existsSync('./pages/custom' ) || fs.mkdirSync('./pages/custom');
+fs.existsSync('./' + config.logsFolder) || fs.mkdirSync('./' + config.logsFolder);
+fs.existsSync('./' + config.uploads.folder) || fs.mkdirSync('./' + config.uploads.folder);
+fs.existsSync('./' + config.uploads.folder + '/thumbs') || fs.mkdirSync('./' + config.uploads.folder + '/thumbs');
-safe.use(helmet())
-safe.set('trust proxy', 1)
+safe.use(helmet());
+safe.set('trust proxy', 1);
-safe.engine('handlebars', exphbs({defaultLayout: 'main'}))
-safe.set('view engine', 'handlebars')
-safe.enable('view cache')
+safe.engine('handlebars', exphbs({ defaultLayout: 'main' }));
+safe.set('view engine', 'handlebars');
+safe.enable('view cache');
-let limiter = new RateLimit({ windowMs: 5000, max: 2 })
-safe.use('/api/login/', limiter)
-safe.use('/api/register/', limiter)
+let limiter = new RateLimit({ windowMs: 5000, max: 2 });
+safe.use('/api/login/', limiter);
+safe.use('/api/register/', limiter);
-safe.use(bodyParser.urlencoded({ extended: true }))
-safe.use(bodyParser.json())
+safe.use(bodyParser.urlencoded({ extended: true }));
+safe.use(bodyParser.json());
-safe.use('/', express.static('./uploads'))
-safe.use('/', express.static('./public'))
-safe.use('/', album)
-safe.use('/api', api)
+if (config.serveFilesWithNode) {
+ safe.use('/', express.static('./uploads'));
+}
+safe.use('/', express.static('./public'));
+safe.use('/', album);
+safe.use('/api', api);
for (let page of config.pages) {
- let root = './pages/'
+ let root = './pages/';
if (fs.existsSync(`./pages/custom/${page}.html`)) {
- root = './pages/custom/'
+ root = './pages/custom/';
}
if (page === 'home') {
- safe.get('/', (req, res, next) => res.sendFile(`${page}.html`, { root: root }))
+ safe.get('/', (req, res, next) => res.sendFile(`${page}.html`, { root: root }));
} else {
- safe.get(`/${page}`, (req, res, next) => res.sendFile(`${page}.html`, { root: root }))
+ safe.get(`/${page}`, (req, res, next) => res.sendFile(`${page}.html`, { root: root }));
}
}
-safe.use((req, res, next) => res.status(404).sendFile('404.html', { root: './pages/error/' }))
-safe.use((req, res, next) => res.status(500).sendFile('500.html', { root: './pages/error/' }))
+safe.use((req, res, next) => res.status(404).sendFile('404.html', { root: './pages/error/' }));
+safe.use((req, res, next) => res.status(500).sendFile('500.html', { root: './pages/error/' }));
-safe.listen(config.port, () => console.log(`loli-safe started on port ${config.port}`))
+safe.listen(config.port, () => console.log(`loli-safe started on port ${config.port}`));