Skip to content

Commit

Permalink
Merge pull request agenda#56 from agenda/add-xo
Browse files Browse the repository at this point in the history
add xo and lint all server files
  • Loading branch information
OmgImAlexis authored Jan 26, 2018
2 parents 4fe5f02 + dbeebce commit b0a3bd4
Show file tree
Hide file tree
Showing 9 changed files with 2,398 additions and 568 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
language: node_js
node_js:
- 4
- 5
- 6
- 7
- 8
services:
- mongodb
sudo: false
Expand All @@ -15,9 +18,10 @@ addons:
before_script:
- mongo --version
- mongod --version
- 'if [ "$AGENDA_VERSION" ]; then npm install agenda@$AGENDA_VERSION; fi'
- 'if [ "$AGENDA_VERSION" ]; then yarn add agenda@$AGENDA_VERSION; fi'
- 'until nc -z 127.0.0.1 27017 ; do echo Waiting for MongoDB; sleep 1; done'
env:
- AGENDA_VERSION=^0.10.0
- AGENDA_VERSION=^0.9.0
- AGENDA_VERSION=^0.8.0
- AGENDA_VERSION=^0.7.0
21 changes: 11 additions & 10 deletions app.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
};
32 changes: 15 additions & 17 deletions bin/agendash-standalone.js
Original file line number Diff line number Diff line change
@@ -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);
Loading

0 comments on commit b0a3bd4

Please sign in to comment.