From f16ed31e84dc8fda7f217be12dd715690b54f471 Mon Sep 17 00:00:00 2001
From: Kyle K <kylek389@gmail.com>
Date: Sun, 19 Mar 2017 02:20:34 -0500
Subject: - add gulpfile and bower preparing for use with vue.js and jquery -
 use express 4.x

---
 .gitignore   |  4 ++++
 app.js       | 40 ++++++++++++++++++++++++++++++++++++++++
 bower.json   | 20 ++++++++++++++++++++
 gulpfile.js  | 18 ++++++++++++++++++
 package.json | 26 ++++++++++++++------------
 server.js    | 40 ----------------------------------------
 6 files changed, 96 insertions(+), 52 deletions(-)
 create mode 100644 app.js
 create mode 100644 bower.json
 create mode 100644 gulpfile.js
 delete mode 100644 server.js

diff --git a/.gitignore b/.gitignore
index 9fc9d78..4d7cfeb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,7 @@ node_modules/
 # AWS #
 #######
 .elasticbeanstalk/
+
+# bower #
+########
+bower_components/
diff --git a/app.js b/app.js
new file mode 100644
index 0000000..ecbf598
--- /dev/null
+++ b/app.js
@@ -0,0 +1,40 @@
+var express = require('express'),
+    app = express(),
+    multer = require('multer');
+var fs = require('fs');
+
+var imgs = ['png', 'jpg', 'jpeg', 'gif', 'bmp']; // only make thumbnail for these
+
+function getExtension(fn) {
+    return fn.split('.').pop();
+}
+
+function fnAppend(fn, insert) {
+    var arr = fn.split('.');
+    var ext = arr.pop();
+    insert = (insert !== undefined) ? insert : new Date().getTime();
+    return arr + '.' + insert + '.' + ext;
+}
+
+
+app.use(multer({
+    dest: './static/uploads/',
+    rename: function (fieldname, filename) {
+        return filename.replace(/\W+/g, '-').toLowerCase();
+    }
+}));
+app.use(express.static(__dirname + '/static'));
+
+
+app.post('/api/upload', function (req, res) {
+    res.send({image: false, file: req.files.userFile.originalname, savedAs: req.files.userFile.name});
+});
+app.get('/api/filenames', function (req, res) { // this is the RESTful API that will send json reply to browser with filenames list
+    var fnames = fs.readdir('./static/uploads', function (err, files) {
+        res.send(JSON.stringify(files));
+    });
+});
+
+var server = app.listen(8081, function () {
+    console.log('listening on port %d', server.address().port);
+});
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..fdeb4cf
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,20 @@
+{
+  "name": "express-upload",
+  "description": "nodejs-express-uploader: node.js, express, multer, html5 progress file upload app",
+  "main": "",
+  "authors": [
+    "Kyle K <kylek389@gmail.com>"
+  ],
+  "license": "MIT",
+  "homepage": "https://github.com/fatalhalt/express-upload",
+  "ignore": [
+    "**/.*",
+    "node_modules",
+    "bower_components",
+    "test",
+    "tests"
+  ],
+  "dependencies": {
+    "jquery": "^3.2.0"
+  }
+}
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..819ef94
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,18 @@
+var gulp = require('gulp');
+var paths = {
+    bower: './bower_components',
+    npm: './node_modules',
+    frontend: './static'
+};
+
+gulp.task('copy', function () {
+    return gulp.src(paths.bower + '/jquery/dist/jquery.min.js')
+      .pipe(gulp.dest(paths.frontend + '/js'));
+});
+gulp.task('copy2', function () {
+    return gulp.src(paths.npm + '/vue/dist/vue.min.js')
+      .pipe(gulp.dest(paths.frontend + '/js'));
+});
+
+gulp.task('default', ['copy','copy2']);
+
diff --git a/package.json b/package.json
index 6c67f56..2e1a1cb 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,15 @@
 {
-    "name": "nodejs express file uploader",
-    "description": "nodejs-express-uploader: node.js, express, multer, html5 progress file upload app",
-    "version": "0.0.1",
-    "engines": {
-        "node": ">= 0.10.x"
-    },
-    "private": true,
-    "dependencies": {
-        "express": "3.x",
-        "multer": "0.x"
-    }
-}
\ No newline at end of file
+  "name": "express-upload",
+  "description": "nodejs-express-uploader: node.js, express, multer, html5 progress file upload app",
+  "version": "0.0.1",
+  "engines": {
+    "node": ">= 0.10.x"
+  },
+  "private": true,
+  "dependencies": {
+    "express": "^4.15.2",
+    "gulp": "^3.9.1",
+    "multer": "0.x",
+    "vue": "^2.2.4"
+  }
+}
diff --git a/server.js b/server.js
deleted file mode 100644
index 6945fbc..0000000
--- a/server.js
+++ /dev/null
@@ -1,40 +0,0 @@
-var express = require('express'),
-    app = express(),
-    multer = require('multer');
-var fs = require('fs');
-
-var imgs = ['png', 'jpg', 'jpeg', 'gif', 'bmp']; // only make thumbnail for these
-
-function getExtension(fn) {
-    return fn.split('.').pop();
-}
-
-function fnAppend(fn, insert) {
-    var arr = fn.split('.');
-    var ext = arr.pop();
-    insert = (insert !== undefined) ? insert : new Date().getTime();
-    return arr + '.' + insert + '.' + ext;
-}
-
-app.configure(function () {
-    app.use(multer({
-        dest: './static/uploads/',
-        rename: function (fieldname, filename) {
-            return filename.replace(/\W+/g, '-').toLowerCase();
-        }
-    }));
-    app.use(express.static(__dirname + '/static'));
-});
-
-app.post('/api/upload', function (req, res) {
-    res.send({image: false, file: req.files.userFile.originalname, savedAs: req.files.userFile.name});
-});
-app.get('/api/filenames', function (req, res) { // this is the RESTful API that will send json reply to browser with filenames list
-    var fnames = fs.readdir('./static/uploads', function (err, files) {
-        res.send(JSON.stringify(files));
-    });
-});
-
-var server = app.listen(8081, function () {
-    console.log('listening on port %d', server.address().port);
-});
\ No newline at end of file
-- 
cgit v1.2.3