aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/albums/link/linkPOST.js2
-rw-r--r--src/api/routes/auth/registerPOST.js2
-rw-r--r--src/api/routes/files/uploadPOST.js4
-rw-r--r--src/api/routes/service/configGET.js18
-rw-r--r--src/api/structures/Server.js6
-rw-r--r--src/api/utils/Util.js4
6 files changed, 18 insertions, 18 deletions
diff --git a/src/api/routes/albums/link/linkPOST.js b/src/api/routes/albums/link/linkPOST.js
index 968e57d..e929c89 100644
--- a/src/api/routes/albums/link/linkPOST.js
+++ b/src/api/routes/albums/link/linkPOST.js
@@ -22,7 +22,7 @@ class linkPOST extends Route {
Count the amount of links created for that album already and error out if max was reached
*/
const count = await db.table('links').where('albumId', albumId).count({ count: 'id' });
- if (count[0].count >= process.env.MAX_LINKS_PER_ALBUM) return res.status(400).json({ message: 'Maximum links per album reached' });
+ if (count[0].count >= parseInt(process.env.MAX_LINKS_PER_ALBUM, 10)) return res.status(400).json({ message: 'Maximum links per album reached' });
/*
Try to allocate a new identifier on the db
diff --git a/src/api/routes/auth/registerPOST.js b/src/api/routes/auth/registerPOST.js
index ee8e5ae..0bd8cfd 100644
--- a/src/api/routes/auth/registerPOST.js
+++ b/src/api/routes/auth/registerPOST.js
@@ -10,7 +10,7 @@ class registerPOST extends Route {
}
async run(req, res, db) {
- if (!process.env.USER_ACCOUNTS) return res.status(401).json({ message: 'Creation of new accounts is currently disabled' });
+ if (process.env.USER_ACCOUNTS == 'false') return res.status(401).json({ message: 'Creation of new accounts is currently disabled' });
if (!req.body) return res.status(400).json({ message: 'No body provided' });
const { username, password } = req.body;
if (!username || !password) return res.status(401).json({ message: 'Invalid body provided' });
diff --git a/src/api/routes/files/uploadPOST.js b/src/api/routes/files/uploadPOST.js
index 82e9d09..e88091a 100644
--- a/src/api/routes/files/uploadPOST.js
+++ b/src/api/routes/files/uploadPOST.js
@@ -181,7 +181,7 @@ class uploadPOST extends Route {
/*
If exif removal has been force service-wide or requested by the user, remove it
*/
- if (process.env.STRIP_EXIF) { // || user.settings.stripExif) {
+ if (process.env.STRIP_EXIF == 'true') { // || user.settings.stripExif) {
// Util.removeExif(upload.filename);
}
@@ -195,7 +195,7 @@ class uploadPOST extends Route {
const busboy = new Busboy({
headers: req.headers,
limits: {
- fileSize: process.env.MAX_SIZE * (1000 * 1000),
+ fileSize: parseInt(process.env.MAX_SIZE, 10) * (1000 * 1000),
files: 1
}
});
diff --git a/src/api/routes/service/configGET.js b/src/api/routes/service/configGET.js
index 230b594..e12c57b 100644
--- a/src/api/routes/service/configGET.js
+++ b/src/api/routes/service/configGET.js
@@ -11,15 +11,15 @@ class configGET extends Route {
config: {
serviceName: process.env.SERVICE_NAME,
uploadFolder: process.env.UPLOAD_FOLDER,
- linksPerAlbum: process.env.MAX_LINKS_PER_ALBUM,
- maxUploadSize: process.env.MAX_SIZE,
- filenameLength: process.env.GENERATED_FILENAME_LENGTH,
- albumLinkLength: process.env.GENERATED_ALBUM_LENGTH,
- generateThumbnails: process.env.GENERATE_THUMBNAILS,
- generateZips: process.env.GENERATE_ZIPS,
- stripExif: process.env.STRIP_EXIF,
- publicMode: process.env.PUBLIC_MODE,
- enableAccounts: process.env.USER_ACCOUNTS
+ linksPerAlbum: parseInt(process.env.MAX_LINKS_PER_ALBUM, 10),
+ maxUploadSize: parseInt(process.env.MAX_SIZE, 10),
+ filenameLength: parseInt(process.env.GENERATED_FILENAME_LENGTH, 10),
+ albumLinkLength: parseInt(process.env.GENERATED_ALBUM_LENGTH, 10),
+ generateThumbnails: process.env.GENERATE_THUMBNAILS == 'true' ? true : false,
+ generateZips: process.env.GENERATE_ZIPS == 'true' ? true : false,
+ stripExif: process.env.STRIP_EXIF == 'true' ? true : false,
+ publicMode: process.env.PUBLIC_MODE == 'true' ? true : false,
+ enableAccounts: process.env.USER_ACCOUNTS == 'true' ? true : false
}
});
}
diff --git a/src/api/structures/Server.js b/src/api/structures/Server.js
index d2cc2f1..0dd22d7 100644
--- a/src/api/structures/Server.js
+++ b/src/api/structures/Server.js
@@ -10,14 +10,14 @@ const jetpack = require('fs-jetpack');
const path = require('path');
const rateLimiter = new RateLimit({
- windowMs: process.env.RATE_LIMIT_WINDOW,
- max: process.env.RATE_LIMIT_MAX,
+ windowMs: parseInt(process.env.RATE_LIMIT_WINDOW, 10),
+ max: parseInt(process.env.RATE_LIMIT_MAX, 10),
delayMs: 0
});
class Server {
constructor() {
- this.port = process.env.SERVER_PORT;
+ this.port = parseInt(process.env.SERVER_PORT, 10);
this.server = express();
this.server.set('trust proxy', 1);
this.server.use(helmet());
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js
index 9e9753c..1242a5a 100644
--- a/src/api/utils/Util.js
+++ b/src/api/utils/Util.js
@@ -106,7 +106,7 @@ class Util {
static getUniqueFilename(name) {
const retry = (i = 0) => {
const filename = randomstring.generate({
- length: process.env.GENERATED_FILENAME_LENGTH,
+ length: parseInt(process.env.GENERATED_FILENAME_LENGTH, 10),
capitalization: 'lowercase'
}) + path.extname(name);
const exists = jetpack.exists(path.join(__dirname, '..', '..', '..', process.env.UPLOAD_FOLDER, filename));
@@ -121,7 +121,7 @@ class Util {
static getUniqueAlbumIdentifier() {
const retry = async (i = 0) => {
const identifier = randomstring.generate({
- length: process.env.GENERATED_ALBUM_LENGTH,
+ length: parseInt(process.env.GENERATED_ALBUM_LENGTH, 10),
capitalization: 'lowercase'
});
const exists = await db.table('links').where({ identifier }).first();