Skip to content
Permalink
Browse files

add xo and lint all server files

  • Loading branch information...
OmgImAlexis committed Aug 9, 2017
1 parent 8b27d72 commit abc5f2b4c1d868899b96a6a72d73dc4382026830
Showing with 2,242 additions and 386 deletions.
  1. +7 −0 .editorconfig
  2. +11 −10 app.js
  3. +15 −17 bin/agendash-standalone.js
  4. +199 −192 lib/agendash.js
  5. +43 −34 lib/middlewares/express.js
  6. +32 −7 package.json
  7. +153 −104 test/test.js
  8. +1,782 −22 yarn.lock
@@ -0,0 +1,7 @@
[*]
charset=utf-8
end_of_line=lf
trim_trailing_whitespace=true
insert_final_newline=true
indent_style=space
indent_size=2
21 app.js
@@ -1,17 +1,18 @@
var path = require('path')
'use strict';
const path = require('path');

module.exports = function (agenda, options) {
options = options || {}
module.exports = (agenda, options) => {
options = options || {};
if (!options.middleware) {
options.middleware = 'express'
options.middleware = 'express';
}

var agendash = require('./lib/agendash')(agenda, options)
const agendash = require('./lib/agendash')(agenda, options);

try {
var middlewarePath = path.join(__dirname, 'lib/middlewares', options.middleware)
return require(middlewarePath)(agendash)
} catch (error) {
throw new Error('No middleware available for ' + options.middleware)
const middlewarePath = path.join(__dirname, 'lib/middlewares', options.middleware);
return require(middlewarePath)(agendash);
} catch (err) {
throw new Error('No middleware available for ' + options.middleware);
}
}
};
@@ -1,32 +1,30 @@
#!/usr/bin/env node
'use strict';
const http = require('http');
const Agenda = require('agenda');
const express = require('express');
const program = require('commander');

var program = require('commander')
program
.option('-d, --db <db>', '[required] Mongo connection string, same as Agenda connection string')
.option('-c, --collection <collection>', '[optional] Mongo collection, same as Agenda collection name, default agendaJobs', 'agendaJobs')
.option('-p, --port <port>', '[optional] Server port, default 3000', (n, d) => +n || d, 3000)
.option('-p, --port <port>', '[optional] Server port, default 3000', (n, d) => Number(n) || d, 3000)
.option('-t, --title <title>', '[optional] Page title, default Agendash', 'Agendash')
.parse(process.argv)
.parse(process.argv);

if (!program.db) {
console.error('--db required')
process.exit(1)
console.error('--db required');
process.exit(1);
}

var http = require('http')
var express = require('express')
var app = express()
const app = express();

var Agenda = require('agenda')
var agenda = new Agenda().database(
program.db,
program.collection
)
const agenda = new Agenda().database(program.db, program.collection);
app.use('/', require('../app')(agenda, {
title: program.title
}))
}));

app.set('port', program.port)
app.set('port', program.port);

var server = http.createServer(app)
server.listen(program.port)
const server = http.createServer(app);
server.listen(program.port);

0 comments on commit abc5f2b

Please sign in to comment.
You can’t perform that action at this time.