agendash 2.0.0 → 3.1.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/README.md +59 -22
- package/app.js +9 -5
- package/bin/agendash-standalone-fastify.js +61 -0
- package/bin/agendash-standalone-hapi.js +36 -18
- package/bin/agendash-standalone-koa.js +30 -14
- package/bin/agendash-standalone.js +44 -19
- package/lib/controllers/agendash.js +228 -110
- package/lib/csp.js +28 -0
- package/lib/middlewares/README.md +3 -1
- package/lib/middlewares/express.js +43 -17
- package/lib/middlewares/fastify.js +77 -0
- package/lib/middlewares/hapi.js +58 -33
- package/lib/middlewares/koa.js +29 -20
- package/package.json +37 -35
- package/public/app/js/confirmDelete.js +14 -13
- package/public/app/js/confirmDeleteMulti.js +14 -13
- package/public/app/js/confirmRequeue.js +14 -13
- package/public/app/js/confirmRequeueMulti.js +15 -14
- package/public/app/js/confirms.js +4 -4
- package/public/app/js/jobdetail.js +9 -9
- package/public/app/js/joblist.js +50 -43
- package/public/app/js/main.js +109 -72
- package/public/app/js/newJob.js +37 -23
- package/public/app/js/sidebar.js +51 -26
- package/public/app/js/topbar.js +15 -5
- package/.editorconfig +0 -7
- package/.idea/agendash.iml +0 -12
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -92
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.travis.yml +0 -27
- package/.vscode/launch.json +0 -15
- package/History.md +0 -106
- package/renovate.json +0 -5
- package/test/test-express.js +0 -82
- package/test/test-hapi.js +0 -106
- package/test/test-koa.js +0 -85
package/README.md
CHANGED
|
@@ -41,8 +41,6 @@ A Dashboard for [Agenda](https://github.com/agenda/agenda).
|
|
|
41
41
|
|
|
42
42
|

|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
44
|

|
|
47
45
|
|
|
48
46
|
---
|
|
@@ -75,7 +73,7 @@ db.agendaJobs.ensureIndex({
|
|
|
75
73
|
npm install --save agendash
|
|
76
74
|
```
|
|
77
75
|
|
|
78
|
-
|
|
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()`.
|
|
79
77
|
|
|
80
78
|
### Middleware usage
|
|
81
79
|
|
|
@@ -86,19 +84,19 @@ make Agendash available on your site at the `/dash` path. Note: Do not try to mo
|
|
|
86
84
|
at the root level like `app.use('/', Agendash(agenda))`.
|
|
87
85
|
|
|
88
86
|
```js
|
|
89
|
-
var express = require(
|
|
87
|
+
var express = require("express");
|
|
90
88
|
var app = express();
|
|
91
89
|
|
|
92
90
|
// ... your other express middleware like body-parser
|
|
93
91
|
|
|
94
|
-
var Agenda = require(
|
|
95
|
-
var Agendash = require(
|
|
92
|
+
var Agenda = require("agenda");
|
|
93
|
+
var Agendash = require("agendash");
|
|
96
94
|
|
|
97
|
-
var agenda = new Agenda({db: {address:
|
|
95
|
+
var agenda = new Agenda({ db: { address: "mongodb://127.0.0.1/agendaDb" } });
|
|
98
96
|
// or provide your own mongo client:
|
|
99
97
|
// var agenda = new Agenda({mongo: myMongoClient})
|
|
100
98
|
|
|
101
|
-
app.use(
|
|
99
|
+
app.use("/dash", Agendash(agenda));
|
|
102
100
|
|
|
103
101
|
// ... your other routes
|
|
104
102
|
|
|
@@ -110,7 +108,8 @@ own authentication for that path. For example if you have an authenticated
|
|
|
110
108
|
session using passport, you can protect the dashboard path like this:
|
|
111
109
|
|
|
112
110
|
```js
|
|
113
|
-
app.use(
|
|
111
|
+
app.use(
|
|
112
|
+
"/dash",
|
|
114
113
|
function (req, res, next) {
|
|
115
114
|
if (!req.user || !req.user.is_admin) {
|
|
116
115
|
res.send(401);
|
|
@@ -126,9 +125,12 @@ Other middlewares will come soon in the folder `/lib/middlewares/`.
|
|
|
126
125
|
You'll just have to update the last line to require the middleware you need:
|
|
127
126
|
|
|
128
127
|
```js
|
|
129
|
-
app.use(
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
app.use(
|
|
129
|
+
"/agendash",
|
|
130
|
+
Agendash(agenda, {
|
|
131
|
+
middleware: "connect",
|
|
132
|
+
})
|
|
133
|
+
);
|
|
132
134
|
```
|
|
133
135
|
|
|
134
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.
|
|
@@ -142,16 +144,21 @@ npm i @hapi/inert @hapi/hapi
|
|
|
142
144
|
```
|
|
143
145
|
|
|
144
146
|
```js
|
|
145
|
-
const agenda = new Agenda().database(
|
|
147
|
+
const agenda = new Agenda().database(
|
|
148
|
+
"mongodb://127.0.0.1/agendaDb",
|
|
149
|
+
"agendaJobs"
|
|
150
|
+
);
|
|
146
151
|
|
|
147
|
-
const server = require(
|
|
152
|
+
const server = require("@hapi/hapi").server({
|
|
148
153
|
port: 3002,
|
|
149
|
-
host:
|
|
154
|
+
host: "localhost",
|
|
150
155
|
});
|
|
151
|
-
await server.register(require(
|
|
152
|
-
await server.register(
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
await server.register(require("@hapi/inert"));
|
|
157
|
+
await server.register(
|
|
158
|
+
Agendash(agenda, {
|
|
159
|
+
middleware: "hapi",
|
|
160
|
+
})
|
|
161
|
+
);
|
|
155
162
|
|
|
156
163
|
await server.start();
|
|
157
164
|
```
|
|
@@ -165,12 +172,15 @@ npm i koa koa-bodyparser koa-router koa-static
|
|
|
165
172
|
```
|
|
166
173
|
|
|
167
174
|
```js
|
|
168
|
-
const agenda = new Agenda().database(
|
|
175
|
+
const agenda = new Agenda().database(
|
|
176
|
+
"mongodb://127.0.0.1/agendaDb",
|
|
177
|
+
"agendaJobs"
|
|
178
|
+
);
|
|
169
179
|
|
|
170
|
-
const Koa = require(
|
|
180
|
+
const Koa = require("koa");
|
|
171
181
|
const app = new Koa();
|
|
172
182
|
const middlewares = Agendash(agenda, {
|
|
173
|
-
middleware:
|
|
183
|
+
middleware: "koa",
|
|
174
184
|
});
|
|
175
185
|
for (const middleware of middlewares) {
|
|
176
186
|
app.use(middleware);
|
|
@@ -181,6 +191,33 @@ await app.listen(3002);
|
|
|
181
191
|
|
|
182
192
|
Then browse to `http://localhost:3002/`.
|
|
183
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
|
+
|
|
184
221
|
### Standalone usage
|
|
185
222
|
|
|
186
223
|
Agendash comes with a standalone Express app which you can use like this:
|
package/app.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
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(
|
|
11
|
-
const middlewarePath = path.join(
|
|
10
|
+
const agendash = require("./lib/controllers/agendash")(agenda, options);
|
|
11
|
+
const middlewarePath = path.join(
|
|
12
|
+
__dirname,
|
|
13
|
+
"./lib/middlewares",
|
|
14
|
+
options.middleware
|
|
15
|
+
);
|
|
12
16
|
|
|
13
17
|
try {
|
|
14
18
|
return require(middlewarePath)(agendash);
|
|
@@ -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
|
+
});
|
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const Agenda = require(
|
|
4
|
-
const agendash = require(
|
|
5
|
-
const Hapi = require(
|
|
6
|
-
const program = require(
|
|
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
7
|
|
|
8
8
|
program
|
|
9
|
-
.option(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
)
|
|
13
29
|
.parse(process.argv);
|
|
14
30
|
|
|
15
31
|
if (!program.db) {
|
|
16
|
-
console.error(
|
|
32
|
+
console.error("--db required");
|
|
17
33
|
process.exit(1);
|
|
18
34
|
}
|
|
19
35
|
|
|
20
|
-
const init = async() => {
|
|
36
|
+
const init = async () => {
|
|
21
37
|
const server = Hapi.server({
|
|
22
38
|
port: 3002,
|
|
23
|
-
host:
|
|
39
|
+
host: "localhost",
|
|
24
40
|
});
|
|
25
41
|
|
|
26
42
|
const agenda = new Agenda().database(program.db, program.collection);
|
|
27
43
|
|
|
28
|
-
await server.register(require(
|
|
29
|
-
await server.register(
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
await server.register(require("@hapi/inert"));
|
|
45
|
+
await server.register(
|
|
46
|
+
agendash(agenda, {
|
|
47
|
+
middleware: "hapi",
|
|
48
|
+
})
|
|
49
|
+
);
|
|
32
50
|
|
|
33
51
|
await server.start();
|
|
34
|
-
console.log(
|
|
52
|
+
console.log("Server running on %s", server.info.uri);
|
|
35
53
|
};
|
|
36
54
|
|
|
37
|
-
process.on(
|
|
55
|
+
process.on("unhandledRejection", (error) => {
|
|
38
56
|
console.log(error);
|
|
39
57
|
process.exit(1);
|
|
40
58
|
});
|
|
@@ -1,38 +1,54 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const Agenda = require(
|
|
4
|
-
const agendash = require(
|
|
5
|
-
const Koa = require(
|
|
6
|
-
const program = require(
|
|
2
|
+
"use strict";
|
|
3
|
+
const { Agenda } = require("agenda");
|
|
4
|
+
const agendash = require("../app");
|
|
5
|
+
const Koa = require("koa");
|
|
6
|
+
const program = require("commander");
|
|
7
7
|
|
|
8
8
|
program
|
|
9
|
-
.option(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
)
|
|
13
29
|
.parse(process.argv);
|
|
14
30
|
|
|
15
31
|
if (!program.db) {
|
|
16
|
-
console.error(
|
|
32
|
+
console.error("--db required");
|
|
17
33
|
process.exit(1);
|
|
18
34
|
}
|
|
19
35
|
|
|
20
|
-
const init = async() => {
|
|
36
|
+
const init = async () => {
|
|
21
37
|
const agenda = new Agenda().database(program.db, program.collection);
|
|
22
38
|
|
|
23
39
|
const app = new Koa();
|
|
24
40
|
const middlewares = agendash(agenda, {
|
|
25
|
-
middleware:
|
|
41
|
+
middleware: "koa",
|
|
26
42
|
});
|
|
27
43
|
for (const middleware of middlewares) {
|
|
28
44
|
app.use(middleware);
|
|
29
45
|
}
|
|
30
46
|
|
|
31
47
|
await app.listen(program.port);
|
|
32
|
-
console.log(
|
|
48
|
+
console.log("Server running on port %s", program.port);
|
|
33
49
|
};
|
|
34
50
|
|
|
35
|
-
process.on(
|
|
51
|
+
process.on("unhandledRejection", (error) => {
|
|
36
52
|
console.log(error);
|
|
37
53
|
process.exit(1);
|
|
38
54
|
});
|
|
@@ -1,39 +1,64 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const http = require(
|
|
4
|
-
const Agenda = require(
|
|
5
|
-
const agendash = require(
|
|
6
|
-
const express = require(
|
|
7
|
-
const program = require(
|
|
2
|
+
"use strict";
|
|
3
|
+
const http = require("http");
|
|
4
|
+
const { Agenda } = require("agenda");
|
|
5
|
+
const agendash = require("../app");
|
|
6
|
+
const express = require("express");
|
|
7
|
+
const program = require("commander");
|
|
8
8
|
|
|
9
9
|
program
|
|
10
|
-
.option(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.option(
|
|
10
|
+
.option(
|
|
11
|
+
"-d, --db <db>",
|
|
12
|
+
"[required] Mongo connection string, same as Agenda connection string"
|
|
13
|
+
)
|
|
14
|
+
.option(
|
|
15
|
+
"-c, --collection <collection>",
|
|
16
|
+
"[optional] Mongo collection, same as Agenda collection name, default agendaJobs",
|
|
17
|
+
"agendaJobs"
|
|
18
|
+
)
|
|
19
|
+
.option(
|
|
20
|
+
"-p, --port <port>",
|
|
21
|
+
"[optional] Server port, default 3000",
|
|
22
|
+
(n, d) => Number(n) || d,
|
|
23
|
+
3000
|
|
24
|
+
)
|
|
25
|
+
.option(
|
|
26
|
+
"-t, --title <title>",
|
|
27
|
+
"[optional] Page title, default Agendash",
|
|
28
|
+
"Agendash"
|
|
29
|
+
)
|
|
30
|
+
.option(
|
|
31
|
+
"-p, --path <path>",
|
|
32
|
+
"[optional] Path to bind Agendash to, default /",
|
|
33
|
+
"/"
|
|
34
|
+
)
|
|
15
35
|
.parse(process.argv);
|
|
16
36
|
|
|
17
37
|
if (!program.db) {
|
|
18
|
-
console.error(
|
|
38
|
+
console.error("--db required");
|
|
19
39
|
process.exit(1);
|
|
20
40
|
}
|
|
21
41
|
|
|
22
|
-
if (!program.path.startsWith(
|
|
23
|
-
console.error(
|
|
42
|
+
if (!program.path.startsWith("/")) {
|
|
43
|
+
console.error("--path must begin with /");
|
|
24
44
|
process.exit(1);
|
|
25
45
|
}
|
|
26
46
|
|
|
27
47
|
const app = express();
|
|
28
48
|
|
|
29
49
|
const agenda = new Agenda().database(program.db, program.collection);
|
|
30
|
-
app.use(
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
app.use(
|
|
51
|
+
program.path,
|
|
52
|
+
agendash(agenda, {
|
|
53
|
+
title: program.title,
|
|
54
|
+
})
|
|
55
|
+
);
|
|
33
56
|
|
|
34
|
-
app.set(
|
|
57
|
+
app.set("port", program.port);
|
|
35
58
|
|
|
36
59
|
const server = http.createServer(app);
|
|
37
60
|
server.listen(program.port, () => {
|
|
38
|
-
console.log(
|
|
61
|
+
console.log(
|
|
62
|
+
`Agendash started http://localhost:${program.port}${program.path}`
|
|
63
|
+
);
|
|
39
64
|
});
|