Skip to content

Commit

Permalink
feat(types): add typescript type generation as part of build process.…
Browse files Browse the repository at this point in the history
… Add named export run that exports middleware/queues in arena.
  • Loading branch information
ejhayes committed May 20, 2021
1 parent 5673ca9 commit 403d1de
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.tsbuildinfo
dist
node_modules
package-lock.json
*.DS_Store
.vscode
.idea
*.tern-port
*.sublime-workspace
dump.rdb
dump.rdb
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.hbs
*.min.js
*.min.css
*.d.ts
tsconfig.json
pull_request_template.md
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,41 @@ router.use('/', arena);
- `useCdn` - set false to use the bundled js and css files (default: true)
- `customCssPath` - an URL to an external stylesheet (default: null)

In addition to the default export, you can also access both arena and the underlying queues using the named export `run`:

```js
const Arena = require('bull-arena').run;

const express = require('express');
const router = express.Router();

const arena = Arena({
// Include a reference to the bee-queue or bull libraries, depending on the library being used.

queues: [
{
// First queue configuration
},
{
// Second queue configuration
},
{
// And so on...
},
],
});

// manage arena queues using queue
//app.queues.list()

router.use('/', arena.app);
```

When calling the named export `run` the following are returned:

- `app` - the arena middleware
- `queues` - the underlying queues in arena

##### Example config (for bull)

```js
Expand Down
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ function run(config, listenOpts = {}) {
});
}

return app;
return {
app,
queues: Queues,
};
}

module.exports = run;
function runDefault(config, listenOpts = {}) {
return run(config, listenOpts).app;
}

// default export remains unchanged
module.exports = runDefault;

// named exports
module.exports.run = run;
82 changes: 82 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bull-arena",
"description": "An interactive UI dashboard for Bee Queue",
"main": "index.js",
"main": "dist/index.js",
"author": "Mixmax <[email protected]>",
"license": "MIT",
"dependencies": {
Expand All @@ -23,6 +23,7 @@
"@semantic-release/github": "^7.0.7",
"@semantic-release/npm": "^7.0.5",
"@semantic-release/release-notes-generator": "^9.0.1",
"@types/express": "^4.17.11",
"bee-queue": "^1.2.3",
"bull": "^3.16.0",
"conventional-changelog-conventionalcommits": "^4.3.0",
Expand All @@ -33,12 +34,15 @@
"lint-staged": "^10.5.4",
"prettier": "^2.0.5",
"pretty-quick": "^3.1.0",
"semantic-release": "^17.4.2"
"rimraf": "^3.0.2",
"semantic-release": "^17.4.2",
"typescript": "^4.2.4"
},
"scripts": {
"ci": "npm run lint && if [ -z \"$CI\" ]; then npm run ci:commitlint; fi",
"ci": "npm run build && npm run lint && if [ -z \"$CI\" ]; then npm run ci:commitlint; fi",
"ci:commitlint": "commitlint --from \"origin/${GITHUB_BASE_REF:-master}\"",
"dry:run": "npm publish --dry-run",
"build": "rimraf dist && tsc",
"lint": "prettier -c .",
"lint:staged": "lint-staged",
"prepare": "husky install",
Expand All @@ -48,9 +52,8 @@
"node": ">=7.6.0"
},
"files": [
"index.js",
"public",
"src"
"dist",
"public"
],
"repository": "https://github.com/bee-queue/arena.git",
"version": "3.21.0"
Expand Down
2 changes: 1 addition & 1 deletion src/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ module.exports = function (config) {

return {
app,
Queues: app.locals.Queues,
Queues: queues,
};
};
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"include": ["index.js","src"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"composite": true,
"outDir": "dist",
"target": "es2017"
}
}

0 comments on commit 403d1de

Please sign in to comment.