Skip to content

Commit

Permalink
Removed code for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinWilloughby committed Nov 10, 2021
1 parent 2d9b12e commit c7328f5
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 23 deletions.
12 changes: 0 additions & 12 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// Import libraries.
const express = require('express');
const compression = require('compression');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const expressHandlebars = require('express-handlebars');
const fileUpload = require('express-fileupload');

// Setup our router.
const router = require('./router.js');

// Configure our port and our mongodb instance.
const port = process.env.PORT || process.env.NODE_PORT || 3000;

const dbURL = process.env.MONGODB_URI || 'mongodb://localhost/ImageUpload';
Expand All @@ -21,15 +17,9 @@ mongoose.connect(dbURL, (err) => {
}
});

// Setup our express app with compression.
const app = express();
app.use(compression());

// Add our fileUpload plugin. This will take any data uploaded with the 'multipart/formdata'
// encoding type, and add them to the req.files object in our requests.
app.use(fileUpload());

// Continue adding standard plugins that already exist in DomoMaker, etc.
app.use(bodyParser.urlencoded({
extended: true,
}));
Expand All @@ -41,10 +31,8 @@ app.set('views', `${__dirname}/../views`);
app.disable('x-powered-by');
app.use(cookieParser());

// Pull in our routes.
router(app);

// Start the server.
app.listen(port, (err) => {
if (err) {
throw err;
Expand Down
6 changes: 0 additions & 6 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// Pull in our file controllers. If you are continuing from DomoMaker, you likely
// have the import for the entire controllers folder. In that case, you want to make
// sure your controllers/index.js is properly importing and exporting the files.js file.
const file = require('./controllers/files.js');

const router = (app) => {
// Setup post requests to /upload.
app.post('/upload', file.uploadFile);

// Setup get requests to /retrieve
app.get('/retrieve', file.retrieveFile);

// Setup get requests to the root for the index page.
app.get('/', file.uploadPage);
};

Expand Down
5 changes: 0 additions & 5 deletions views/upload.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
<body>
<html>
<body>
<!-- Post form. Note that the encoding type is set to 'multipart/form-data'. You cannot
upload files using the standard form-urlencoded encoding type. Also note that because we
are using the default html form action, we have named out file sampleFile. This will become
relevant in our src/controllers/files.js when trying to access the file on the server. -->
<form ref='uploadForm'
id='uploadForm'
action='/upload'
Expand All @@ -20,7 +16,6 @@
<input type='submit' value='Upload!' />
</form>

<!-- Get form. Just a standard GET request getting made with a query parameter of ?filename -->
<form ref='retrieveForm'
id='retrieveForm'
action='/retrieve'
Expand Down

0 comments on commit c7328f5

Please sign in to comment.