Ind.ie is now Small Technology Foundation.
Commit 482a9925 authored by Frauke's avatar Frauke

Added info service and uploading of files

parent b1ac5e73
......@@ -45,5 +45,6 @@ function readFile (fileName) {
module.exports = {
writeFile,
readFile
readFile,
makeDir
}
......@@ -329,6 +329,11 @@
"normalize-path": "2.1.1"
}
},
"append-field": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/append-field/-/append-field-0.1.0.tgz",
"integrity": "sha1-bdxY+gg8e8VF08WZWygwzCNm1Eo="
},
"aproba": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
......@@ -1520,6 +1525,38 @@
"resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
"integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug="
},
"busboy": {
"version": "0.2.14",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
"integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=",
"requires": {
"dicer": "0.2.5",
"readable-stream": "1.1.14"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "0.0.1",
"string_decoder": "0.10.31"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
}
}
},
"bytes": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
......@@ -2883,6 +2920,38 @@
"kuler": "0.0.0"
}
},
"dicer": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz",
"integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=",
"requires": {
"readable-stream": "1.1.14",
"streamsearch": "0.1.2"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "0.0.1",
"string_decoder": "0.10.31"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
}
}
},
"diff": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz",
......@@ -5660,6 +5729,14 @@
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"inherits-ex": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/inherits-ex/-/inherits-ex-1.2.0.tgz",
"integrity": "sha1-MVlON25zgZjvdUD9V1lBCl1CQDg=",
"requires": {
"xtend": "4.0.1"
}
},
"ini": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
......@@ -6994,6 +7071,17 @@
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz",
"integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE="
},
"mime-type": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/mime-type/-/mime-type-3.0.5.tgz",
"integrity": "sha1-ftKSan2oImifgSVPWYf+lQNiLpo=",
"requires": {
"media-typer": "0.3.0",
"minimatch": "3.0.4",
"path.js": "1.0.7",
"util-ex": "0.3.15"
}
},
"mime-types": {
"version": "2.1.17",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz",
......@@ -7126,6 +7214,28 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"multer": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/multer/-/multer-1.3.0.tgz",
"integrity": "sha1-CSsmcPaEb6SRSWXvyM+Uwg/sbNI=",
"requires": {
"append-field": "0.1.0",
"busboy": "0.2.14",
"concat-stream": "1.6.0",
"mkdirp": "0.5.1",
"object-assign": "3.0.0",
"on-finished": "2.3.0",
"type-is": "1.6.15",
"xtend": "4.0.1"
},
"dependencies": {
"object-assign": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz",
"integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I="
}
}
},
"mustache": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-2.3.0.tgz",
......@@ -11843,6 +11953,16 @@
"pify": "2.3.0"
}
},
"path.js": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path.js/-/path.js-1.0.7.tgz",
"integrity": "sha1-fRNrYH3hm/2YugaIdJJih+ZTSTk=",
"requires": {
"escape-string-regexp": "1.0.5",
"inherits-ex": "1.2.0",
"util-ex": "0.3.15"
}
},
"pause": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
......@@ -16103,6 +16223,11 @@
}
}
},
"streamsearch": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
},
"strict-uri-encode": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
......@@ -16931,6 +17056,15 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"util-ex": {
"version": "0.3.15",
"resolved": "https://registry.npmjs.org/util-ex/-/util-ex-0.3.15.tgz",
"integrity": "sha1-+SYc2hPEMn0HQMvme+Eife2LAFg=",
"requires": {
"inherits-ex": "1.2.0",
"xtend": "4.0.1"
}
},
"utila": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz",
......
// Middleware for transfering the received files to feathers body
// Note: files will only be added to the request when multer is previous middleware
module.exports = (req, res, next) => {
if(req.files) {
const data = Object.assign({}, req.body, req.files)
req.body = data
}
next()
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ const email = require('./email/email.service.js')
const keys = require('./keys/keys.service.js')
const messages = require('./messages/messages.service.js')
const locale = require('./locale/locale.service.js')
const info = require('./info/info.service.js')
module.exports = function (app) {
app.configure(createWebsite)
app.configure(websiteReady)
......@@ -13,4 +14,5 @@ module.exports = function (app) {
app.configure(keys)
app.configure(messages)
app.configure(locale)
app.configure(info)
}
/* eslint-disable no-unused-vars */
class Service {
constructor (options) {
this.options = options || {};
}
async update (id, data, params) {
return data
}
}
module.exports = function (options) {
return new Service(options)
}
module.exports.Service = Service
module.exports = {
before: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
after: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
error: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
}
// Initializes the `info` service on path `/info`
const createService = require('./info.class.js')
const hooks = require('./info.hooks')
const fileMiddleware = require('../../middleware/file')
// initialise multer with storage and fileFilter
const multer = require('multer')
const {imagefilter} = require('../../lib/fileFilters')
const {infoStorage} = require('../../lib/fileStorages')
const upload = multer({ storage: infoStorage, fileFilter: imagefilter })
// set fields which contain the files
const uploadFields = upload.fields([{ name: 'profileImage', maxCount: 1 }, { name: 'headerImage', maxCount: 1 }])
module.exports = function (app) {
const paginate = app.get('paginate')
const options = {
name: 'info',
paginate
}
// Initialize our service with any options it requires
app.use('/info',
uploadFields, // set multer middleware
fileMiddleware, // middleware for transfering the received files to feathers body (MUST COME AFTER MULTER MIDDLEWARE)
createService(options)
)
// Get our initialized service so that we can register hooks and filters
const service = app.service('info')
service.hooks(hooks)
}
const assert = require('assert');
const app = require('../../server/app');
describe('\'info\' service', () => {
it('registered the service', () => {
const service = app.service('info');
assert.ok(service, 'Registered the service');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment