forked from agenda/agendash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request agenda#56 from agenda/add-xo
add xo and lint all server files
- Loading branch information
Showing
9 changed files
with
2,398 additions
and
568 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.