From 233e2f3e22bf37d2ae61f6a422514e9781b81589 Mon Sep 17 00:00:00 2001 From: hippoz Date: Wed, 7 Oct 2020 18:00:32 +0300 Subject: [PATCH] change messages to lowercase to fit my style --- index.js | 22 +++++++++++----------- views/upload.ejs | 4 ++-- views/uploaded.ejs | 2 +- views/uploadfailed.ejs | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 6acc8e5..cd13d3e 100644 --- a/index.js +++ b/index.js @@ -85,13 +85,13 @@ app.get('/file/:filename', (req, res) => { const isValid = isPathValid(filename, filePath); if (!isValid) { - res.status(400).send('Invalid input.'); + res.status(400).send('invalid input.'); return; } fs.access(filePath, fs.F_OK, (err) => { if (err) { - res.status(404).send('File not found or is invalid.'); + res.status(404).send('file not found or is invalid.'); return; } @@ -114,44 +114,44 @@ app.post('/api/upload', [ cors(corsOptions) ], (req, res) => { const chosenFileName = req.body.filename; if (config.passwords.indexOf(password) === -1) { - return res.status(401).render('uploadfailed', { message: 'The password you entered is not correct.' }); + return res.status(401).render('uploadfailed', { message: 'the password you entered is not correct.' }); } if (!req.files || Object.keys(req.files).length === 0) { - return res.status(400).render('uploadfailed', { message: 'You forgot to upload a file.' }); + return res.status(400).render('uploadfailed', { message: 'you forgot to upload a file.' }); } const file = req.files.file; if (!isFilenameValid(chosenFileName)) { - return res.status(400).render('uploadfailed', { message: 'Invalid name.' }); + return res.status(400).render('uploadfailed', { message: 'invalid name.' }); } const filepath = path.join(config.storagePath, chosenFileName); if (!isFilenameValid(file.name) || !isPathValid(chosenFileName, filepath)) { - return res.status(400).render('uploadfailed', { message: 'Invalid name.' }); + return res.status(400).render('uploadfailed', { message: 'invalid name.' }); } fs.stat(filepath, (err) => { if(err == null) { - return res.status(400).render('uploadfailed', { message: 'A file with that name already exists.' }); + return res.status(400).render('uploadfailed', { message: 'a file with that name already exists.' }); } else if(err.code === 'ENOENT') { file.mv(filepath, (err) => { - if (err) return res.status(500).render('uploadfailed', { message: 'Something went wrong while uploading the file.' }); + if (err) return res.status(500).render('uploadfailed', { message: 'something went wrong while uploading the file.' }); res.render('uploaded', { file: { name: chosenFileName } }); }); } else { - return res.status(500).render('uploadfailed', { message: 'Something went wrong.' });; + return res.status(500).render('uploadfailed', { message: 'something went wrong.' });; } }); }); app.use(function (err, req, res, next) { console.error(err.stack); - res.status(500).send('Internal Server Error: Something went wrong'); + res.status(500).send('internal server error: something went wrong'); }); app.listen(config.server.port, () => { - console.log(`Started server on port ${config.server.port}`); + console.log(`started server on port ${config.server.port}`); }); \ No newline at end of file diff --git a/views/upload.ejs b/views/upload.ejs index 081ae83..aa0f213 100644 --- a/views/upload.ejs +++ b/views/upload.ejs @@ -9,8 +9,8 @@

this is the upload page

i think

- Password:
- File name:
+ password:
+ file name:

diff --git a/views/uploaded.ejs b/views/uploaded.ejs index 5397249..d50b2ee 100644 --- a/views/uploaded.ejs +++ b/views/uploaded.ejs @@ -9,6 +9,6 @@

the file was uploaded

i think


- Go to file + go to file \ No newline at end of file diff --git a/views/uploadfailed.ejs b/views/uploadfailed.ejs index d855dcd..9e48485 100644 --- a/views/uploadfailed.ejs +++ b/views/uploadfailed.ejs @@ -10,6 +10,6 @@

i think

<%= message %>


- Go back + go back \ No newline at end of file