Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
markuskonk committed Feb 19, 2018
1 parent 052c075 commit cbe2c90
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "google"
}
69 changes: 35 additions & 34 deletions controllers/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,63 +19,64 @@

const express = require('express');
const bodyParser = require('body-parser');
const debug = require('debug')('bindings:bindings')
const fs = require("fs");
const debug = require('debug')('bindings:bindings');
const fs = require('fs');

var bindings = {};
let bindings = {};

bindings.start = (conf) => {

return new Promise((resolve, reject) => {

const app = express();
app.use(bodyParser.urlencoded({extended: true}));
debug('Receiving data to create bindings');
app.post("/api/v1/bindings", function(req, res){
switch(req.body.purpose){
case "showFigureCode":
bindings.showFigureCode(req.body);
res.send({callback:"ok"});
break;
default:
break;
}
});

var bindingsListen = app.listen(conf.port, () => {
app.use(bodyParser.urlencoded({extended: true}));
debug('Receiving data to create bindings');
app.post('/api/v1/bindings', function(req, res) {
switch (req.body.purpose) {
case 'showFigureCode':
bindings.showFigureCode(req.body);
res.send({callback: 'ok'});
break;
default:
break;
}
});
let bindingsListen = app.listen(conf.port, () => {
debug('Bindings server listening on port %s', conf.port);
resolve(bindingsListen);
});
});
};

bindings.readRmarkdown = function(compendium_id, mainfile){
if (!compendium_id | !mainfile)
bindings.readRmarkdown = function( compendiumId, mainfile ) {
if ( !compendiumId | !mainfile ) {
throw new Error('File does not exist.');
var paper = __dirname + "/" + compendium_id + "/" + mainfile;
fs.exists(paper,function(ex){
if (!ex)
}
let paper = __dirname + '/' + compendiumId + '/' + mainfile;
fs.exists(paper, function(ex) {
if (!ex) {
throw new Error('File does not exist.');
}
});
const readerStream = fs.createReadStream(paper);
readerStream.setEncoding('utf8');
var data = '';
let data = '';
readerStream
.on('data', function(chunk) {
data += chunk;
})
.on('end', function(){
.on('end', function() {
bindings.saveRmarkdown(data);
return data;
})
.on('error', function(err){
.on('error', function(err) {
debug(err);
});
});
};

bindings.saveRmarkdown = function(data){
fs.writeFile(__dirname + '/testdata/paper_interactive.Rmd', data,'utf8', function(err){
debug(err)
});
}
bindings.saveRmarkdown = function(data) {
fs.writeFile(__dirname + '/testdata/paper_interactive.Rmd',
data, 'utf8', function(err) {
debug(err);
} );
};

module.exports = bindings;
module.exports = bindings;
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

const config = require('./config/config');
const debug = require('debug')('bindings');
var bindings = require('./controllers/bindings');
let bindings = require('./controllers/bindings');

bindings.start({
port: config.net.port
})
});
41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"name": "o2r-bindings",
"version": "0.0.1",
"description": "Microservice for linking text, data, and code.",
"main": "index.js",
"scripts": {
"start": "node index.js",
"requests": "node bindings.js"
},
"author": "Markus Konkol (http://o2r.info)",
"license": "Apache-2.0",
"dependencies": {
"express": "~4.16.2",
"body-parser": "^1.18.2",
"debug": "^3.1.0"
},
"devDependencies": {
"asserthat":"0.11.0",
"eslint":"4.16.0",
"eslint-config-es":"0.9.1"
}
"name": "o2r-bindings",
"version": "0.0.1",
"description": "Microservice for linking text, data, and code.",
"main": "index.js",
"scripts": {
"start": "node index.js",
"requests": "node bindings.js"
},
"author": "Markus Konkol (http://o2r.info)",
"license": "Apache-2.0",
"dependencies": {
"express": "~4.16.2",
"body-parser": "^1.18.2",
"debug": "^3.1.0"
},
"devDependencies": {
"asserthat": "0.11.0",
"eslint": "4.16.0",
"eslint-config-es": "0.9.1",
"eslint-config-google": "^0.9.1"
}
}

0 comments on commit cbe2c90

Please sign in to comment.