forked from kyranet/klasa-dashboard-hooks
-
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.
* [WIP] rewrite * plugging in and docs * docs corrections * going to need this * Add a bunch of stuff * fix lint * docs corrections * another missing external * oops * more init stuff * more externals * tweak headers * whoops * whoops x2 + debug * leTypo * another! * oops * uh, try this * and don't forget this * fixes * how about a diy http server? * oops * try this * hmm? * debug * ? * ah, got it * more fixes * need node v10+ for: for await of although, that can be changed with the transfer command. * some docs and index additions * docs corrections * bloody caps
- Loading branch information
Showing
44 changed files
with
920 additions
and
127 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,3 @@ | ||
{ | ||
"extends": "klasa/md" | ||
} |
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 @@ | ||
* text=auto eol=lf |
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,25 @@ | ||
# Contributing | ||
|
||
**The issue tracker is only for issue reporting or proposals/suggestions. If you have a question, you can find us in our [Discord Server](https://discord.gg/FpEFSyY)**. | ||
|
||
To contribute to this repository, feel free to create a new fork of the repository | ||
submit a pull request. We highly suggest [ESLint](https://eslint.org/) to be installed | ||
in your text editor or IDE of your choice to avoid fail builds from Travis. | ||
|
||
1. Fork, clone, and select the **master** branch. | ||
2. Create a new branch in your fork. | ||
3. Commit your changes, and push them. | ||
4. Submit a Pull Request [here](https://github.com/dirigeants/klasa/pulls)! | ||
|
||
## Klasa Concept Guidelines | ||
|
||
There are a number of guidelines considered when reviewing Pull Requests to be merged into core framework (further referred to as __core__). _This is by no means an exhaustive list, but here are some things to consider before/while submitting your ideas._ | ||
|
||
- Klasa should never change D.JS's default behavior in core. Klasa should only add to D.JS and be as consistent as possible with D.JS. | ||
- Nothing in core should respond with embeds or be terribly "personalized". Instead everything should be an abstract working base that people can personalize themselves to their own needs. | ||
- Everything in core should be generally useful for the majority of Klasa bots. (A reason why core doesn't implement any Music features.) Don't let that stop you if you've got a good concept though, as your idea still might be a great addition to [klasa-pieces](https://github.com/dirigeants/klasa-pieces) or as an optional addon package. | ||
- As much of the framework as possible is meant to be customizable for any possible use-case, even if the use-case is niche. New features shouldn't break existing use-cases without a strong/well-thought-out reason (that doesn't conflict with any other guideline). | ||
- Everything should be shard compliant. If something you are PRing would break when sharding, break other things from supporting sharding, or is incompatible with sharding; then you will need to think of a way to make it work with sharding in mind before it will be accepted/merged. | ||
- Everything should be documented with [jsdocs](http://usejsdoc.org/), whether private or not. __If you see a mistake in the docs, please pr a fix.__ | ||
- Everything should follow OOP paradigms and generally rely on behavior over state where possible. This generally helps methods be predictable, keeps the codebase simple & understandable, reduces code duplication through abstraction, and leads to efficiency and therefore scalability. | ||
- Everything should follow our ESLint rules as closely as possible, and should pass lint tests even if you must disable a rule for a single line. |
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,24 @@ | ||
### Describe the issue | ||
|
||
### Code or steps to reproduce | ||
|
||
```js | ||
|
||
``` | ||
|
||
<!-- | ||
If your issue is a proposal, you can provide its use case showing code. | ||
Make sure to explain everything well and comment the code, so we can | ||
follow up. | ||
--> | ||
|
||
### Expected and actual behaviour | ||
|
||
|
||
### Further details | ||
|
||
- **discord.js version**: | ||
- **node.js version**: | ||
- **Klasa version**: | ||
- [ ] I have modified core files. | ||
- [ ] I have tested the issue on latest master. Commit hash: |
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,13 @@ | ||
### Description of the PR | ||
|
||
|
||
### Changes Proposed in this Pull Request (List new items in CHANGELOG.MD) | ||
|
||
- | ||
|
||
### Semver Classification | ||
|
||
- [ ] This PR only includes documentation or non-code changes. | ||
- [ ] This PR fixes a bug and does not change the (intended) framework interface. | ||
- [ ] This PR adds methods or properties to the framework interface. | ||
- [ ] This PR removes or renames methods or properties in the framework interface. |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"default": true, | ||
"header-style": { "style": "atx" }, | ||
"ul-indent": { "indent": 4 }, | ||
"line-length": false, | ||
"no-hard-tabs": false, | ||
"first-line-h1": false, | ||
"first-header-h1": false, | ||
"no-trailing-punctuation": false, | ||
"no-blanks-blockquote": false, | ||
"no-trailing-spaces": false, | ||
"no-inline-html": false | ||
} |
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,31 @@ | ||
#!/bin/bash | ||
# Based on https://github.com/discordjs/discord.js-site/blob/master/deploy/deploy.sh | ||
|
||
set -e | ||
|
||
if [ -n "$TRAVIS_TAG" -o "$TRAVIS_PULL_REQUEST" != "false" ]; then | ||
echo -e "Not building for a non branch push - building without deploying." | ||
npm run docs | ||
exit 0 | ||
fi | ||
|
||
echo -e "Building for a branch push - building and deploying." | ||
|
||
REPO=$(git config remote.origin.url) | ||
SHA=$(git rev-parse --verify HEAD) | ||
|
||
#new docs | ||
|
||
TARGET_BRANCH="docs" | ||
git clone $REPO out -b $TARGET_BRANCH | ||
|
||
npm run docs | ||
|
||
mv docs/docs.json out/${TRAVIS_BRANCH//\//_}.json | ||
|
||
cd out | ||
git add --all . | ||
git config user.name "Travis CI" | ||
git config user.email "${COMMIT_EMAIL}" | ||
git commit -m "Docs build: ${SHA}" || true | ||
git push "https://${GH_TOKEN}@${GH_REF}" $TARGET_BRANCH |
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,20 @@ | ||
language: node_js | ||
node_js: | ||
- "8" | ||
install: npm install | ||
jobs: | ||
include: | ||
- stage: test | ||
script: npm test | ||
- stage: deploy | ||
script: bash ./.travis-deploy.sh | ||
cache: | ||
directories: | ||
- node_modules | ||
#notifications: | ||
# webhooks: | ||
# urls: | ||
# - https://webhooks.gitter.im/e/0926b82fc22ea0760ede | ||
# on_success: always # options: [always|never|change] default: always | ||
# on_failure: always # options: [always|never|change] default: always | ||
# on_start: never # options: [always|never|change] default: always |
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,2 +1,3 @@ | ||
# klasa-dashboard-hooks | ||
|
||
Simple plugin to expose an api from a klasa bot. Lets you build an external dashboard in one of several frameworks such as Vue.js. |
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,19 @@ | ||
[{ | ||
"name": "Getting Started", | ||
"files": [{ | ||
"name": "Getting Started", | ||
"path": "GettingStarted.md" | ||
}] | ||
}, | ||
{ | ||
"name": "Piece Basics", | ||
"files": [ | ||
{ | ||
"name": "Creating Routes", | ||
"path": "CreatingRoutes.md" | ||
}, | ||
{ | ||
"name": "Creating Middlewares", | ||
"path": "CreatingMiddlewares.md" | ||
}] | ||
}] |
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,3 @@ | ||
## Getting Started | ||
|
||
placeholder |
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 @@ | ||
placeholder |
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 @@ | ||
placeholder |
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 +1,27 @@ | ||
module.exports = { DashboardHooks: require('./lib/DashboardHooks') }; | ||
module.exports = { | ||
Client: require('./lib/Client'), | ||
Server: require('./lib/http/Server'), | ||
Middleware: require('./lib/structures/Middleware'), | ||
MiddlewareStore: require('./lib/structures/MiddlewareStore'), | ||
Route: require('./lib/structures/Route'), | ||
RouteStore: require('./lib/structures/RouteStore'), | ||
constants: require('./lib/util/constants'), | ||
util: require('./lib/util/Util') | ||
}; | ||
|
||
/** | ||
* @external KlasaClient | ||
* @see {@link https://klasa.js.org/#/docs/main/master/class/KlasaClient} | ||
*/ | ||
/** | ||
* @external Piece | ||
* @see {@link https://klasa.js.org/#/docs/main/master/class/Piece} | ||
*/ | ||
/** | ||
* @external Store | ||
* @see {@link https://klasa.js.org/#/docs/main/master/class/Store} | ||
*/ | ||
/** | ||
* @external KlasaClientOptions | ||
* @see {@link https://klasa.js.org/#/docs/main/master/typedef/KlasaClientOptions} | ||
*/ |
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,76 @@ | ||
const { join } = require('path'); | ||
|
||
const { Client, util: { mergeDefault } } = require('klasa'); | ||
|
||
const Server = require('./http/Server'); | ||
const RouteStore = require('./structures/RouteStore'); | ||
const MiddlewareStore = require('./structures/MiddlewareStore'); | ||
const { OPTIONS } = require('./util/constants'); | ||
|
||
/** | ||
* The client for handling everything. See {@tutorial GettingStarted} for more information how to get started using this class. | ||
* @extends external:KlasaClient | ||
* @tutorial GettingStarted | ||
*/ | ||
class DashboardClient extends Client { | ||
|
||
|
||
/** | ||
* @typedef {external:KlasaClientOptions} DashboardClientOptions | ||
* @property {KlasaDashboardHooksOptions} [dashboardHooks] The Klasa-Dashboard-Hooks specific options | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} KlasaDashboardHooksOptions | ||
* @property {string} [apiPrefix="api/"] The route prefix for the api | ||
* @property {string} [origin="*"] The cross origin setting | ||
* @property {number} [port=4000] The port the api runs on | ||
*/ | ||
|
||
/** | ||
* Constructs the klasa-dashboard-hooks client | ||
* @since 0.0.1 | ||
* @param {DashboardClientOptions} config The config to pass to the new client | ||
*/ | ||
constructor(config) { | ||
super(config); | ||
mergeDefault(OPTIONS, this.options); | ||
|
||
/** | ||
* The directory to the node_modules folder where Klasa-Dashboard-Hooks exists | ||
* @since 0.0.1 | ||
* @type {string} | ||
*/ | ||
this.hooksBaseDir = join(__dirname, '../'); | ||
|
||
/** | ||
* The http server handler for the api | ||
* @since 0.0.1 | ||
* @type {Server} | ||
*/ | ||
this.server = new Server(this); | ||
|
||
/** | ||
* The cache where routes are stored | ||
* @since 0.0.1 | ||
* @type {RouteStore} | ||
*/ | ||
this.routes = new RouteStore(this); | ||
|
||
/** | ||
* The cache where middlewares are stored | ||
* @since 0.0.1 | ||
* @type {MiddlewareStore} | ||
*/ | ||
this.middlewares = new MiddlewareStore(this); | ||
|
||
this | ||
.registerStore(this.routes) | ||
.registerStore(this.middlewares); | ||
|
||
this.server.listen(this.options.dashboardHooks.port); | ||
} | ||
|
||
} | ||
|
||
module.exports = DashboardClient; |
Oops, something went wrong.