agendash 1.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +3 -2
- package/History.md +80 -58
- package/LICENSE +1 -1
- package/README.md +173 -49
- package/all-jobs.png +0 -0
- package/app.js +12 -7
- package/bin/agendash-standalone-fastify.js +61 -0
- package/bin/agendash-standalone-hapi.js +60 -0
- package/bin/agendash-standalone-koa.js +56 -0
- package/bin/agendash-standalone.js +47 -15
- package/create-job.png +0 -0
- package/entrypoint.sh +1 -1
- package/lib/controllers/agendash.js +340 -0
- package/lib/middlewares/README.md +12 -5
- package/lib/middlewares/express.js +58 -34
- package/lib/middlewares/fastify.js +75 -0
- package/lib/middlewares/hapi.js +65 -88
- package/lib/middlewares/koa.js +71 -0
- package/mobile-ui-sm.png +0 -0
- package/mobile-ui-xs.png +0 -0
- package/package.json +45 -36
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/app/assets/ArgensdashV2Logo.svg +18 -0
- package/public/app/css/styles.css +221 -0
- package/public/app/js/confirmDelete.js +40 -0
- package/public/app/js/confirmDeleteMulti.js +45 -0
- package/public/app/js/confirmRequeue.js +40 -0
- package/public/app/js/confirmRequeueMulti.js +45 -0
- package/public/app/js/confirms.js +8 -0
- package/public/app/js/jobdetail.js +48 -0
- package/public/app/js/joblist.js +239 -0
- package/public/app/js/main.js +275 -0
- package/public/app/js/newJob.js +89 -0
- package/public/app/js/sidebar.js +121 -0
- package/public/app/js/topbar.js +95 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +40 -164
- package/public/site.webmanifest +1 -0
- package/search.png +0 -0
- package/.editorconfig +0 -7
- package/.travis.yml +0 -24
- package/job-details.png +0 -0
- package/lib/agendash.js +0 -295
- package/public/css/bootstrap-theme.css +0 -587
- package/public/css/bootstrap-theme.css.map +0 -1
- package/public/css/bootstrap-theme.min.css +0 -6
- package/public/css/bootstrap-theme.min.css.map +0 -1
- package/public/css/bootstrap.css +0 -6760
- package/public/css/bootstrap.css.map +0 -1
- package/public/css/bootstrap.min.css +0 -6
- package/public/css/bootstrap.min.css.map +0 -1
- package/public/css/dashboard.css +0 -94
- package/public/fonts/glyphicons-halflings-regular.eot +0 -0
- package/public/fonts/glyphicons-halflings-regular.svg +0 -288
- package/public/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/public/fonts/glyphicons-halflings-regular.woff +0 -0
- package/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/public/js/backbone-min.js +0 -2
- package/public/js/backbone-min.map +0 -1
- package/public/js/bootstrap.js +0 -2363
- package/public/js/bootstrap.min.js +0 -7
- package/public/js/jquery-2.2.0.min.js +0 -4
- package/public/js/lodash.min.js +0 -120
- package/public/js/main.js +0 -414
- package/public/js/moment.min.js +0 -7
- package/test/test-express.js +0 -98
- package/test/test-hapi.js +0 -104
- package/yarn.lock +0 -4412
package/Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM node:
|
|
1
|
+
FROM node:14-alpine
|
|
2
2
|
|
|
3
3
|
# Dependencies
|
|
4
4
|
# RUN apk update && apk upgrade && \
|
|
@@ -6,7 +6,8 @@ FROM node:8.2.0-alpine
|
|
|
6
6
|
|
|
7
7
|
ENV NODE_ENV=production \
|
|
8
8
|
MONGODB_URI=mongodb://mongodb \
|
|
9
|
-
COLLECTION=agendaJobs
|
|
9
|
+
COLLECTION=agendaJobs \
|
|
10
|
+
BASE_PATH=/
|
|
10
11
|
|
|
11
12
|
RUN mkdir -p /agendash
|
|
12
13
|
WORKDIR /agendash
|
package/History.md
CHANGED
|
@@ -1,84 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
====
|
|
3
|
-
* Add Hapi v17 middleware, drop support for Node.js v6 & v7 (#81) by umens (**BREAKING**)
|
|
4
|
-
* Support Agenda version 2 by alexkwolfe (**BREAKING**)
|
|
1
|
+
# 3.0.0
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
- BREAKING: Drop support for MongoDB v3.4, only >=v3.6 is supported now.
|
|
4
|
+
- BREAKING: Drop support for node 10, but added node 16 support.
|
|
5
|
+
- feat: add `fastify` support #194
|
|
6
|
+
- fix: a lot of rendering issues
|
|
7
|
+
- fix: newer version of `mongodb` compatibility #193
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* Agenda `>=0.7.0 <1.0.0` → `^1.0.3` and thus require MongoDB v3+
|
|
11
|
-
* async `^1.0.0` → `^2.6.0`
|
|
12
|
-
* Drop support for Node.js v4 and v5 (might still work but we're stopping testing these) (**BREAKING**)
|
|
13
|
-
* Switch testing with Mocha to [Ava](https://www.npmjs.com/package/ava) (#70)
|
|
14
|
-
* Docker support (#54) by WoLfulus
|
|
15
|
-
* Fix 404 errors when deleting and re-queuing jobs (#61) by koresar
|
|
9
|
+
This file won't mention contributors anymore. Because all contributors are listed on the [main page](https://github.com/agenda/agendash) now. Thanks, GitHub!
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
==================
|
|
11
|
+
# 2.1.0 - JSON validation when creating jobs
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
* (loris) Fix #24 - Added indexes for faster queries.
|
|
22
|
-
* Fix #28 - Removed dependency on Mongo Driver.
|
|
23
|
-
* Added API tests with mocha and supertest. No frontend tests.
|
|
13
|
+
- feat: Add json validator message when createJob #169 (thanks @love8587)
|
|
24
14
|
|
|
25
|
-
0.
|
|
26
|
-
==================
|
|
15
|
+
# 2.0.0 - First public release of v2 as Agendash proper
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
Complete rewrite of Agendash in Vue.js!
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
==================
|
|
19
|
+
Supports Node.js 10 and up.
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
# 2.0.0-beta0.8.2 / 2020-12-04 - As agendash2, in parallel repository https://github.com/agenda/agendash-v2
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
- fix: search by job name, small side bar design fix and toggle improvements (thanks @simllll)
|
|
24
|
+
- fix: joblist reset fix (thanks @simllll)
|
|
25
|
+
- fix: improve design on desktop + close sidebar on mobile when clicked on something (thanks @simllll)
|
|
26
|
+
- feat: enable options.query as number (thanks @Enubia @simllll)
|
|
27
|
+
- feat: multiselect checkboxes (thanks @Enubia @simllll)
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
* Limit to 200 jobs on page, no UI for configuration
|
|
29
|
+
# 2.0.0-beta0.1.0 / 2020-04-30 - First public release of Agendash2 in parallel repository https://github.com/agenda/agendash-v2
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
- New frontend written from scratch in Vue.js
|
|
32
|
+
- Add search
|
|
33
|
+
- Add pagination
|
|
34
|
+
- Change default refresh interval to 60 seconds
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
* Fixed "queued" label colors
|
|
36
|
+
# 1.0.0 / 2019-02-25
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
- Add Hapi v17 middleware, drop support for Node.js v6 & v7 (#81) by umens (**BREAKING**)
|
|
39
|
+
- Support Agenda version 2 by alexkwolfe (**BREAKING**)
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
* Middleware option moved to "options" object
|
|
41
|
+
# 0.5.0 / 2019-02-25
|
|
52
42
|
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
- Update dependencies (#69, #70) (**BREAKING**)
|
|
44
|
+
- Agenda `>=0.7.0 <1.0.0` → `^1.0.3` and thus require MongoDB v3+
|
|
45
|
+
- async `^1.0.0` → `^2.6.0`
|
|
46
|
+
- Drop support for Node.js v4 and v5 (might still work but we're stopping testing these) (**BREAKING**)
|
|
47
|
+
- Switch testing with Mocha to [Ava](https://www.npmjs.com/package/ava) (#70)
|
|
48
|
+
- Docker support (#54) by WoLfulus
|
|
49
|
+
- Fix 404 errors when deleting and re-queuing jobs (#61) by koresar
|
|
55
50
|
|
|
56
|
-
|
|
51
|
+
# 0.4.0 / 2016-10-27
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
- (simison) Agenda dependency version `<1.0.0` to avoid breaking dependency.
|
|
54
|
+
- (loris) Fix #24 - Added indexes for faster queries.
|
|
55
|
+
- Fix #28 - Removed dependency on Mongo Driver.
|
|
56
|
+
- Added API tests with mocha and supertest. No frontend tests.
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
* (ebourmalo) Fix the middleware usage and use a proper structure
|
|
58
|
+
# 0.3.2 / 2016-06-30
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
==================
|
|
60
|
+
- (HugoCornu) Fix #19 "Schedule Job" - Don't repeat job if user didn't want it repeated
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
* Select All and Select None
|
|
62
|
+
# 0.3.1 / 2016-04-12
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
==================
|
|
64
|
+
- (simison) Add engines key to package.json
|
|
72
65
|
|
|
73
|
-
|
|
66
|
+
# 0.3.0 / 2016-04-04
|
|
74
67
|
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
- (bh-chaker) Schedule Job Feature - create new jobs from the UI
|
|
69
|
+
- Limit to 200 jobs on page, no UI for configuration
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
* Added screenshots
|
|
71
|
+
# 0.2.1 / 2016-03-25
|
|
80
72
|
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
- (vziukas) Recurring job count and labels
|
|
74
|
+
- Fixed "queued" label colors
|
|
83
75
|
|
|
84
|
-
|
|
76
|
+
# 0.2.0 / 2016-03-18
|
|
77
|
+
|
|
78
|
+
- (vziukas) Configurable title
|
|
79
|
+
- Middleware option moved to "options" object
|
|
80
|
+
|
|
81
|
+
# 0.1.1 / 2016-03-17
|
|
82
|
+
|
|
83
|
+
- (vziukas) multiple instances of agendash can each have a separate agenda
|
|
84
|
+
|
|
85
|
+
# 0.1.0 / 2016-03-15
|
|
86
|
+
|
|
87
|
+
- (rapidia) remove "arrow function" syntax for non-chrome browsers
|
|
88
|
+
- (ebourmalo) Fix the middleware usage and use a proper structure
|
|
89
|
+
|
|
90
|
+
# 0.0.5 / 2016-02-24
|
|
91
|
+
|
|
92
|
+
- Batch requeue and delete
|
|
93
|
+
- Select All and Select None
|
|
94
|
+
|
|
95
|
+
# 0.0.4 / 2016-02-24
|
|
96
|
+
|
|
97
|
+
- Select multiple jobs
|
|
98
|
+
|
|
99
|
+
# 0.0.2 / 2016-02-23
|
|
100
|
+
|
|
101
|
+
- version bump so npm will update docs
|
|
102
|
+
- Added screenshots
|
|
103
|
+
|
|
104
|
+
# 0.0.1 / 2016-02-23
|
|
105
|
+
|
|
106
|
+
- Initial Release
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,84 +1,102 @@
|
|
|
1
1
|
# Agendash
|
|
2
|
-
[](https://travis-ci.org/agenda/agendash)
|
|
3
|
-
<a href="https://slackin-ekwifvcwbr.now.sh/"><img src="https://slackin-ekwifvcwbr.now.sh/badge.svg" alt="Slack Status"></a>
|
|
4
|
-
[](https://snyk.io/test/github/agenda/agendash?targetFile=package.json)
|
|
5
2
|
|
|
6
|
-
A Dashboard for [Agenda](https://github.com/agenda/agenda)
|
|
3
|
+
A Dashboard for [Agenda](https://github.com/agenda/agenda).
|
|
7
4
|
|
|
8
5
|
---
|
|
9
6
|
|
|
10
7
|
### Features
|
|
11
8
|
|
|
12
|
-
- Job status auto-refreshes
|
|
13
|
-
- Schedule a new job from the UI
|
|
14
|
-
- Dive in to see more details about the job, like the json data
|
|
15
|
-
- Requeue a job
|
|
16
|
-
- Delete jobs
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- Automatically creates additional indexes on several columns (See #24).
|
|
9
|
+
- Job status auto-refreshes: 60-second polling by default.
|
|
10
|
+
- Schedule a new job from the UI.
|
|
11
|
+
- Dive in to see more details about the job, like the json data.
|
|
12
|
+
- Requeue a job. Clone the data and run immediately.
|
|
13
|
+
- Delete jobs. Useful for cleaning up old completed jobs.
|
|
14
|
+
- Search jobs by name and metadata. Supports querying by Mongo Object Id.
|
|
15
|
+
- Pagination
|
|
16
|
+
- Responsive UI
|
|
21
17
|
|
|
22
18
|
---
|
|
23
19
|
|
|
24
20
|
### Screenshots
|
|
25
21
|
|
|
22
|
+
#### Dashboard
|
|
23
|
+
|
|
26
24
|

|
|
27
25
|
|
|
28
26
|
---
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
#### Create jobs
|
|
29
|
+
|
|
30
|
+

|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
#### Search by name, metadata, job status
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
npm install --save agendash
|
|
38
|
-
```
|
|
36
|
+

|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
---
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
#### Responsive UI
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+

|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
./node_modules/.bin/agendash --db=mongodb://localhost/agendaDb --collection=agendaCollection --port=3001
|
|
48
|
-
```
|
|
44
|
+

|
|
49
45
|
|
|
50
|
-
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
# Troubleshooting
|
|
49
|
+
|
|
50
|
+
### Index for sorting
|
|
51
|
+
|
|
52
|
+
It may be required to create the following index for faster sorting (see [#24](https://github.com/agenda/agendash/issues/24))
|
|
51
53
|
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
+
```
|
|
55
|
+
db.agendaJobs.ensureIndex({
|
|
56
|
+
"nextRunAt" : -1,
|
|
57
|
+
"lastRunAt" : -1,
|
|
58
|
+
"lastFinishedAt" : -1
|
|
59
|
+
}, "agendash")
|
|
54
60
|
```
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
# Roadmap
|
|
65
|
+
|
|
66
|
+
- [ ] Get more test coverage
|
|
67
|
+
- [ ] Add middlewares for fastify, and other express-like libraries
|
|
68
|
+
- [ ] You decide! Submit a feature request
|
|
69
|
+
|
|
70
|
+
### Install
|
|
57
71
|
|
|
58
|
-
```bash
|
|
59
|
-
npx agendash --db=mongodb://localhost/agendaDb --collection=agendaCollection --port=3001
|
|
60
72
|
```
|
|
73
|
+
npm install --save agendash
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
_Note_: `Agendash` requires mongodb version >2.6.0 to perform the needed aggregate queries. This is your mongo database version, not your node package version! To check your database version, connect to mongo and run `db.version()`.
|
|
61
77
|
|
|
62
78
|
### Middleware usage
|
|
63
79
|
|
|
80
|
+
#### Express
|
|
81
|
+
|
|
64
82
|
Agendash provides Express middleware you can use at a specified path, for example this will
|
|
65
83
|
make Agendash available on your site at the `/dash` path. Note: Do not try to mount Agendash
|
|
66
84
|
at the root level like `app.use('/', Agendash(agenda))`.
|
|
67
85
|
|
|
68
86
|
```js
|
|
69
|
-
var express = require(
|
|
87
|
+
var express = require("express");
|
|
70
88
|
var app = express();
|
|
71
89
|
|
|
72
90
|
// ... your other express middleware like body-parser
|
|
73
91
|
|
|
74
|
-
var Agenda = require(
|
|
75
|
-
var Agendash = require(
|
|
92
|
+
var Agenda = require("agenda");
|
|
93
|
+
var Agendash = require("agendash");
|
|
76
94
|
|
|
77
|
-
var agenda = new Agenda({db: {address:
|
|
95
|
+
var agenda = new Agenda({ db: { address: "mongodb://127.0.0.1/agendaDb" } });
|
|
78
96
|
// or provide your own mongo client:
|
|
79
97
|
// var agenda = new Agenda({mongo: myMongoClient})
|
|
80
98
|
|
|
81
|
-
app.use(
|
|
99
|
+
app.use("/dash", Agendash(agenda));
|
|
82
100
|
|
|
83
101
|
// ... your other routes
|
|
84
102
|
|
|
@@ -89,8 +107,9 @@ By mounting Agendash as middleware on a specific path, you may provide your
|
|
|
89
107
|
own authentication for that path. For example if you have an authenticated
|
|
90
108
|
session using passport, you can protect the dashboard path like this:
|
|
91
109
|
|
|
92
|
-
```
|
|
93
|
-
app.use(
|
|
110
|
+
```js
|
|
111
|
+
app.use(
|
|
112
|
+
"/dash",
|
|
94
113
|
function (req, res, next) {
|
|
95
114
|
if (!req.user || !req.user.is_admin) {
|
|
96
115
|
res.send(401);
|
|
@@ -106,24 +125,129 @@ Other middlewares will come soon in the folder `/lib/middlewares/`.
|
|
|
106
125
|
You'll just have to update the last line to require the middleware you need:
|
|
107
126
|
|
|
108
127
|
```js
|
|
109
|
-
app.use(
|
|
110
|
-
|
|
111
|
-
|
|
128
|
+
app.use(
|
|
129
|
+
"/agendash",
|
|
130
|
+
Agendash(agenda, {
|
|
131
|
+
middleware: "connect",
|
|
132
|
+
})
|
|
133
|
+
);
|
|
112
134
|
```
|
|
113
135
|
|
|
114
136
|
Note that if you use a CSRF protection middleware like [`csurf`](https://www.npmjs.com/package/csurf), you might need to [configure it off](https://github.com/agenda/agendash/issues/23#issuecomment-270917949) for Agendash-routes.
|
|
115
137
|
|
|
116
|
-
|
|
138
|
+
#### Hapi
|
|
139
|
+
|
|
140
|
+
A minimum Node.js version 12 is required for `@hapi/hapi` dependency.
|
|
141
|
+
|
|
142
|
+
```shell
|
|
143
|
+
npm i @hapi/inert @hapi/hapi
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const agenda = new Agenda().database(
|
|
148
|
+
"mongodb://127.0.0.1/agendaDb",
|
|
149
|
+
"agendaJobs"
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const server = require("@hapi/hapi").server({
|
|
153
|
+
port: 3002,
|
|
154
|
+
host: "localhost",
|
|
155
|
+
});
|
|
156
|
+
await server.register(require("@hapi/inert"));
|
|
157
|
+
await server.register(
|
|
158
|
+
Agendash(agenda, {
|
|
159
|
+
middleware: "hapi",
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
await server.start();
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Then browse to `http://localhost:3002/`.
|
|
167
|
+
|
|
168
|
+
#### Koa
|
|
169
|
+
|
|
170
|
+
```shell
|
|
171
|
+
npm i koa koa-bodyparser koa-router koa-static
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
const agenda = new Agenda().database(
|
|
176
|
+
"mongodb://127.0.0.1/agendaDb",
|
|
177
|
+
"agendaJobs"
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const Koa = require("koa");
|
|
181
|
+
const app = new Koa();
|
|
182
|
+
const middlewares = Agendash(agenda, {
|
|
183
|
+
middleware: "koa",
|
|
184
|
+
});
|
|
185
|
+
for (const middleware of middlewares) {
|
|
186
|
+
app.use(middleware);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
await app.listen(3002);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Then browse to `http://localhost:3002/`.
|
|
193
|
+
|
|
194
|
+
#### Fastify
|
|
195
|
+
|
|
196
|
+
```shell
|
|
197
|
+
npm i fastify
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
const agenda = new Agenda().database(
|
|
202
|
+
"mongodb://127.0.0.1/agendaDb",
|
|
203
|
+
"agendaJobs"
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
const Fastify = require("fastify");
|
|
207
|
+
const fastify = new Fastify();
|
|
208
|
+
|
|
209
|
+
fastify.register(
|
|
210
|
+
Agendash(
|
|
211
|
+
agenda,
|
|
212
|
+
{ middleware: "fastify" }
|
|
213
|
+
);
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
await fastify.listen(3002);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Then browse to `http://localhost:3002/`.
|
|
220
|
+
|
|
221
|
+
### Standalone usage
|
|
222
|
+
|
|
223
|
+
Agendash comes with a standalone Express app which you can use like this:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
./node_modules/.bin/agendash --db=mongodb://localhost/agendaDb --collection=agendaCollection --port=3002
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
or like this, for default collection `agendaJobs` and default port `3000`:
|
|
117
230
|
|
|
118
|
-
|
|
231
|
+
```bash
|
|
232
|
+
./node_modules/.bin/agendash --db=mongodb://localhost/agendaDb
|
|
233
|
+
```
|
|
119
234
|
|
|
120
|
-
|
|
121
|
-
- `title`: Defaults to `"Agendash"`. Useful if you are running multiple Agenda pools.
|
|
235
|
+
If you are using npm >= 5.2, then you can use [npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b):
|
|
122
236
|
|
|
123
|
-
|
|
237
|
+
```bash
|
|
238
|
+
npx agendash --db=mongodb://localhost/agendaDb --collection=agendaCollection --port=3002
|
|
239
|
+
```
|
|
124
240
|
|
|
125
|
-
|
|
241
|
+
Then browse to `http://localhost:3002/`.
|
|
242
|
+
|
|
243
|
+
### Docker usage
|
|
244
|
+
|
|
245
|
+
Agendash can also be run within a Docker container like this:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
docker run -p 3000:3000 \
|
|
249
|
+
--env MONGODB_URI=mongo://myUser:myPass@myHost/myDb \
|
|
250
|
+
--env COLLECTION=myAgendaCollection agenda/agendash
|
|
251
|
+
```
|
|
126
252
|
|
|
127
|
-
|
|
128
|
-
- [ ] Write some tests!
|
|
129
|
-
- [ ] Use Agendash and submit issues!
|
|
253
|
+
Then browse to `http://localhost:3000/`.
|
package/all-jobs.png
CHANGED
|
Binary file
|
package/app.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
const path = require(
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require("path");
|
|
3
3
|
|
|
4
4
|
module.exports = (agenda, options) => {
|
|
5
5
|
options = options || {};
|
|
6
6
|
if (!options.middleware) {
|
|
7
|
-
options.middleware =
|
|
7
|
+
options.middleware = "express";
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const agendash = require(
|
|
10
|
+
const agendash = require("./lib/controllers/agendash")(agenda, options);
|
|
11
|
+
const middlewarePath = path.join(
|
|
12
|
+
__dirname,
|
|
13
|
+
"./lib/middlewares",
|
|
14
|
+
options.middleware
|
|
15
|
+
);
|
|
11
16
|
|
|
12
17
|
try {
|
|
13
|
-
const middlewarePath = path.join(__dirname, 'lib/middlewares', options.middleware);
|
|
14
18
|
return require(middlewarePath)(agendash);
|
|
15
|
-
} catch (
|
|
16
|
-
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(error);
|
|
21
|
+
throw new Error(`Middleware load failed with ${JSON.stringify(options)}`);
|
|
17
22
|
}
|
|
18
23
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const Agenda = require("agenda");
|
|
4
|
+
const agendash = require("../app");
|
|
5
|
+
const Fastify = require("fastify");
|
|
6
|
+
const program = require("commander");
|
|
7
|
+
|
|
8
|
+
program
|
|
9
|
+
.option(
|
|
10
|
+
"-d, --db <db>",
|
|
11
|
+
"[required] Mongo connection string, same as Agenda connection string"
|
|
12
|
+
)
|
|
13
|
+
.option(
|
|
14
|
+
"-c, --collection <collection>",
|
|
15
|
+
"[optional] Mongo collection, same as Agenda collection name, default agendaJobs",
|
|
16
|
+
"agendaJobs"
|
|
17
|
+
)
|
|
18
|
+
.option(
|
|
19
|
+
"-p, --port <port>",
|
|
20
|
+
"[optional] Server port, default 3000",
|
|
21
|
+
(n, d) => Number(n) || d,
|
|
22
|
+
3000
|
|
23
|
+
)
|
|
24
|
+
.option(
|
|
25
|
+
"-t, --title <title>",
|
|
26
|
+
"[optional] Page title, default Agendash",
|
|
27
|
+
"Agendash"
|
|
28
|
+
)
|
|
29
|
+
.option(
|
|
30
|
+
"-p, --path <path>",
|
|
31
|
+
"[optional] Path to bind Agendash to, default /",
|
|
32
|
+
"/"
|
|
33
|
+
)
|
|
34
|
+
.parse(process.argv);
|
|
35
|
+
|
|
36
|
+
if (!program.db) {
|
|
37
|
+
console.error("--db required");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!program.path.startsWith("/")) {
|
|
42
|
+
console.error("--path must begin with /");
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const fastify = Fastify();
|
|
47
|
+
|
|
48
|
+
const agenda = new Agenda().database(program.db, program.collection);
|
|
49
|
+
|
|
50
|
+
fastify.register(
|
|
51
|
+
agendash(agenda, {
|
|
52
|
+
middleware: "fastify",
|
|
53
|
+
title: program.title,
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
fastify.listen(program.port, function () {
|
|
58
|
+
console.log(
|
|
59
|
+
`Agendash started http://localhost:${program.port}${program.path}`
|
|
60
|
+
);
|
|
61
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const { Agenda } = require("agenda");
|
|
4
|
+
const agendash = require("../app");
|
|
5
|
+
const Hapi = require("@hapi/hapi");
|
|
6
|
+
const program = require("commander");
|
|
7
|
+
|
|
8
|
+
program
|
|
9
|
+
.option(
|
|
10
|
+
"-d, --db <db>",
|
|
11
|
+
"[required] Mongo connection string, same as Agenda connection string"
|
|
12
|
+
)
|
|
13
|
+
.option(
|
|
14
|
+
"-c, --collection <collection>",
|
|
15
|
+
"[optional] Mongo collection, same as Agenda collection name, default agendaJobs",
|
|
16
|
+
"agendaJobs"
|
|
17
|
+
)
|
|
18
|
+
.option(
|
|
19
|
+
"-p, --port <port>",
|
|
20
|
+
"[optional] Server port, default 3000",
|
|
21
|
+
(n, d) => Number(n) || d,
|
|
22
|
+
3000
|
|
23
|
+
)
|
|
24
|
+
.option(
|
|
25
|
+
"-t, --title <title>",
|
|
26
|
+
"[optional] Page title, default Agendash",
|
|
27
|
+
"Agendash"
|
|
28
|
+
)
|
|
29
|
+
.parse(process.argv);
|
|
30
|
+
|
|
31
|
+
if (!program.db) {
|
|
32
|
+
console.error("--db required");
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const init = async () => {
|
|
37
|
+
const server = Hapi.server({
|
|
38
|
+
port: 3002,
|
|
39
|
+
host: "localhost",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const agenda = new Agenda().database(program.db, program.collection);
|
|
43
|
+
|
|
44
|
+
await server.register(require("@hapi/inert"));
|
|
45
|
+
await server.register(
|
|
46
|
+
agendash(agenda, {
|
|
47
|
+
middleware: "hapi",
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
await server.start();
|
|
52
|
+
console.log("Server running on %s", server.info.uri);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
process.on("unhandledRejection", (error) => {
|
|
56
|
+
console.log(error);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
init();
|