Skip to content

Commit

Permalink
Add file upload handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZandercraftGames committed Sep 27, 2023
1 parent 1eac7ec commit 56ffe3e
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 2 deletions.
Binary file modified README.md
Binary file not shown.
8 changes: 7 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ const express = require('express')
const path = require('path')
const cookieParser = require('cookie-parser')
const logger = require('morgan')
const multer = require('multer')

// Setup multer disk-store
const upload = multer({ dest: 'uploads/' })

// --- Routers ---
const indexRouter = require('./routes/index')
const apiRouter = require('./routes/api')

Expand Down Expand Up @@ -38,4 +43,5 @@ app.use(function (err, req, res, next) {
res.render('error', {title: `Error ${err.status}: ${err.message}`})
})

module.exports = app
module.exports.app = app
module.exports.upload = upload
2 changes: 1 addition & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require('dotenv').config()
* Module dependencies.
*/

const app = require('../app');
const app = require('../app').app;
const debug = require('debug')('technicflux:server');
const http = require('http');
const database = require('../database')
Expand Down
127 changes: 127 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"http-errors": "~1.6.3",
"mongoose": "^7.5.3",
"morgan": "~1.9.1",
"multer": "^1.4.5-lts.1",
"standard": "^17.1.0"
},
"devDependencies": {
Expand Down
5 changes: 5 additions & 0 deletions uploads/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
======================INTERNAL FILE======================
This is just a placeholder file within the uploads
folder. The file itself is just used to keep the folder on
Git before any other files are added.
=========================================================

0 comments on commit 56ffe3e

Please sign in to comment.