Repository navigation
Expand file tree
/
Copy pathplugin.js
More file actions
87 lines (54 loc) · 1.53 KB
/
Copy pathplugin.js
File metadata and controls
87 lines (54 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var Converter = require("csvtojson").Converter;
var converter = new Converter({});
var fs = require('fs');
var result = {};
const internals = {};
internals.onPostAuth = function (options) {
console.log("Enter in function");
return function (request, reply) {
request.payload.file = request.payload.file.pipe(converter);
converter.on("end_parsed", function (jsonArray) {
console.log(jsonArray);
return reply.continue();
});
// converter.on("record_parsed", function(resultRow, rawRow, rowIndex) {
// var i=0;
// for (var key in resultRow) {
// if (!result[key] || !result[key] instanceof Array) {
// result[key] = [];
// }
// result[key][rowIndex] = resultRow[key];
// }
// )
// }
return request.payload.file;
}
}
exports.register = function (server, options, next) {
console.log("start working plugin");
server.ext('onPostAuth', internals.onPostAuth(options));
next();
}
exports.register.attributes = {
name :'test',
version :'1.0.0'
};
// 'use strict';
// var basicRoute = {
// register: function(server,options,next){
// server.route
// ({
// method: 'GET',
// path :'/',
// handler:function(){
// reply(JSON.stringify("working plugin"));
// }
// });
// next();
// }
// }
// basicRoute.register.attributes={
// name :'route',
// version :'1.0.0',
// }
// module.exports = basicRoute;