Skip to content

Commit

Permalink
Merge pull request #78 (v2.2.0) from Sv443/wip/2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fehler authored Aug 1, 2020
2 parents 11c39bd + 712f8e5 commit 221a9f8
Show file tree
Hide file tree
Showing 61 changed files with 6,750 additions and 1,667 deletions.
47 changes: 40 additions & 7 deletions .github/Contributing.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
# Before submitting your contribution, please read the following:
# Contributing Guide
This guide will tell you how you can and should contribute to JokeAPI.
Not following it might cause me to reject your changes but at the very least we will both lose time.
So please read this guide before contributing. Thanks :)

## Menu:
- [Submitting or editing jokes](#submitting-or-editing-jokes)
- [Contributing to JokeAPI's code](#submitting-code)
- [Submitting a translation](#submitting-translations)
- [Tips and Tricks for contributing](#other-nice-to-know-stuff)

<br><br><br><br>

## Submitting or editing jokes:
To submit a joke manually, you can use the form on [this page.](https://sv443.net/jokeapi/v2/#submit)
To submit it through code, you can make use of the ["submit" endpoint.](https://sv443.net/jokeapi/v2/#submit-endpoint)

If you instead want to *edit* a joke, you can find them in the `jokes-xy.json` files in [`data/jokes/`](../data/jokes/)
Please then follow the [code contribution section](#submitting-code) as well.

<br><br>

## Submitting code:
1. [Read the Code_of_Conduct.md file](./Code_of_Conduct.md) (TLDR: just behave in a friendly manner).
2. [Click here](https://github.com/Sv443/JokeAPI/fork) to fork the repository. Afterwards, clone or download it and locate the folder where it is contained.
3. Make the changes you want to make to the code.
Expand All @@ -7,8 +29,8 @@
- `npm run validate-ids` to verify that all jokes have the correct ID.
- `npm run lint` to check the code for any warnings or errors.
5. Run JokeAPI locally by running the command `node JokeAPI`, request some jokes and test the areas you modified / added to make sure everything still works.
6. Add yourself to the `contributors` object in the file `package.json` :)
- **If it doesn't exist or is empty** please add it using the second format on [this website](https://flaviocopes.com/package-json/#contributors)
6. Add yourself to the `contributors` object in the [`package.json`](../package.json) file :)
<!-- - **If it doesn't exist or is empty** please add it using the second format on [this website](https://flaviocopes.com/package-json/#contributors) -->
7. Submit a pull request on your forked repository, selecting `Sv443/JokeAPI` as the base repo and `master` as the base branch and selecting `YourUsername/JokeAPI` as the head repo and `YourBranch` as the compare branch
- If your pull request is not ready to be merged yet, you can add `[WIP]` to the beginning of the title which will tell the repo maintainer(s) and automated scripts not to merge it yet.
8. Request a review from me (Sv443).
Expand All @@ -19,9 +41,20 @@

<br><br>

### Other nice-to-know stuff:
## Submitting Translations:
If you want to submit a translation, please follow these steps:
1. Find your language's two-character code in the file [`data/languages.json`](../data/languages.json). You'll need to specify it for every translation.
2. Translate coded error messages in the file [`data/errorMessages.js`](../data/errorMessages.js) by following the style of the other translations.
3. Translate the generic strings inside of the file [`data/translations.json`](../data/translations.json) by also following the style of the other translations.
4. Add yourself to the `contributors` object in the [`package.json`](../package.json) file :)

<br><br>

## Other nice-to-know stuff:
- I really recommend using [Visual Studio Code](https://code.visualstudio.com/) with the extension [`fabiospampinato.vscode-highlight`](https://marketplace.visualstudio.com/items?itemName=fabiospampinato.vscode-highlight) - it will add custom styling to the syntax highlighting in the editor and make the code easier to read and work with.
- If you want to generate a dependency graph, you need to install [Graphviz](https://graphviz.gitlab.io/download/) and add the path to the `bin` folder to your `%PATH%` environment vaiable. Then, run the command `npm run dependency-graph` and open the file `./dev/dependency-graph.html` in a browser.
- If you need to add an authorization token, you can generate one or multiple tokens with the command `npm run add-token [amount]`. If you omit the "amount" parameter, the script will generate a single token. After you run the command, the tokens will be listed in the console and you can now (after restarting JokeAPI) use it in the `x-api-token` header to gain unlimited access to JokeAPI.
- If you want to generate a dependency graph, you need to install [Graphviz](https://graphviz.gitlab.io/download/) and add the path to the `bin` folder to your `%PATH%` / `$PATH` environment vaiable. Then, run the command `npm run dependency-graph` and open the file [`dev/dependency-graph.html`](../dev/dependency-graph.html) in a browser.
- If you need to add an authorization token, you can generate one or multiple tokens with the command `npm run add-token [amount]`. If you omit the "amount" parameter, the script will generate a single token. After you run the command, the tokens will be listed in the console and you can now (after restarting JokeAPI) use it in the `Authorization` header to gain unlimited access to JokeAPI.

<br><br>

## If you need any help, please feel free to contact me through [Discord](https://sv443.net/discord) or [E-Mail](mailto:[email protected]?subject=Questions%20about%20contributing%20to%20JokeAPI)
## If you need any help, feel free to contact me through [Discord](https://sv443.net/discord) (fastest way to contact me) or [E-Mail](mailto:[email protected]?subject=Questions%20about%20contributing%20to%20JokeAPI)
27 changes: 27 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--- Provide a short, general summary of your changes in the Title above -->

## Description
<!-- Describe your changes in detail -->

## Related Issue
<!-- If there is an issue related to this PR or this PR fixes the issue, please add it here: -->

## Motivation and Context
<!- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
<!-- Please describe in detail how you tested your changes. -->
<!-- Include details of your testing environment, and the tests you ran to -->
<!-- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):
<!-- Add some screenshots here, if applicable -->

## Checklist
- [ ] I have read the [Contributing Guide](../Contributing.md)
- [ ] I read and accept the [Code of Conduct](../Code_of_Conduct.md) (TLDR: just behave in a friendly manner)
- [ ] My code follows the general style of this project
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation (if applicable)
- [ ] I ensured that the automated checks that ran on this PR have completed successfully
- [ ] I added myself to the `package.json` file (optional)
13 changes: 7 additions & 6 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ Please **do not** create a GitHub issue!

## Supported Versions
These versions are still supported and will be receiving security updates:
| Version | Supported |
| --- | --- |
| v1.0 ||
| v1.1 ||
| v2.0 ||
| v2.1 ||
| Version | Supported | Status |
| --- | --- | --- |
| [v1.0](https://github.com/Sv443/JokeAPI/releases/tag/v1.0.0) || deprecated |
| [v1.1](https://github.com/Sv443/JokeAPI/releases/tag/v1.1.3) || deprecated |
| [v2.0](https://github.com/Sv443/JokeAPI/releases/tag/v2.0.1) || outdated |
| [v2.1](https://github.com/Sv443/JokeAPI/releases/tag/v2.1.5) || outdated |
| [v2.2](https://github.com/Sv443/JokeAPI/releases/tag/v2.2.0) || active |
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ node_modules/
dev/madge/
dependency-graph.html
test.js
!tools/test.js

# Docs:
docs/documentation.html
docs/compiled

# Joke submissions:
data/submissions/submission_*.json

# Re-inclusions:
!change.log*
data/submissions/*/*.json

# Auth Tokens:
data/tokens.json

# Other potentially sensitive information:
lists/*.json
data/lists/*.json
2 changes: 1 addition & 1 deletion .snyk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.14.1
version: v1.13.5
ignore: {}
# patches apply the minimum changes required to fix a vulnerability
patch:
Expand Down
20 changes: 18 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"program": "${workspaceFolder}/tools/add-joke.js",
"name": "Tools/xy",
"request": "launch",
"type": "node",
"skipFiles": [
"<node_internals>/**"
],
"args": [
"--trace-deprecation"
],
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"name": "Debug JokeAPI",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/JokeAPI.js"
"program": "${workspaceFolder}/JokeAPI.js",
"args": [
"--trace-deprecation"
]
}
],
"debug.javascript.usePreview": true
Expand Down
14 changes: 11 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,35 @@
"color": "#f88"
}
],
"(#MARKER)": [ // #MARKER test
"(#MARKER)": [ //#MARKER test
{
"backgroundColor": "#f41",
"color": "#fff",
"isWholeLine": true,
"overviewRulerColor": "#f41"
}
],
"(#SECTION [a-zA-Z0-9_-]+)": [ //#SECTION test
"(#SECTION [a-zA-Z0-9_-,]+)": [ //#SECTION test, foo bar
{
"backgroundColor": "#44f",
"color": "white",
"overviewRulerColor": "#44f"
}
],
"(#DEBUG#)": [
"(#DEBUG)": [ //#DEBUG
{
"backgroundColor": "#ff0",
"color": "blue",
"overviewRulerColor": "#ff0"
}
],
"(?<!\\w)(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|rgba?\\s*\\([^)]*?\\)|hsla?\\s*\\([^)]*?\\)|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyanaqua|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|tan|teal|thistle|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen)(?!\\w)": [
{
"rangeBehavior": 1,
"borderWidth": "1px",
"borderColor": "$1",
"borderStyle": "solid"
}
]
},
"npm-scripts.showStartNotification": false
Expand Down
6 changes: 4 additions & 2 deletions JokeAPI.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// 🔹 JokeAPI v2 by Sv443 🔹
// 🔹 JokeAPI by Sv443 🔹
//
// GitHub: https://github.com/Sv443/JokeAPI
// API Docs: https://sv443.net/jokeapi/v2
// ️
// ⚠️ Please read the LICENSE.txt file before redistributing JokeAPI.
// ⚠️ Please read the LICENSE.txt file before modifying, redistributing or even selling JokeAPI.
// ⚠️ Thanks :)


Expand All @@ -15,6 +15,8 @@ const settings = require("./settings");

function initJokeAPI()
{
if(settings.debug.verboseLogging)
console.log("\n\n");
debug("PreInit", "Called InitJokeAPI");
// the debugger and child processes don't get along together so only wrap JokeAPI if the debugger is not active:
if(!jsl.inDebugger() && !settings.wrapper.skipWrapping)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
# [![icon](https://sv443.net/cdn/jokeapi/icon_readme.png)](#readme)<br>JokeAPI
### A REST API that serves uniformly and well formatted jokes and offers a great variety of filtering methods and response customization
[![GitHub](https://img.shields.io/github/license/Sv443/JokeAPI)](https://sv443.net/LICENSE)
[![Uptime / 7 Days](https://img.shields.io/uptimerobot/ratio/7/m782998549-afcc0d10c27c87df47e73289)](https://status.sv443.net/)
[![Uptime / 7 Days](https://img.shields.io/uptimerobot/ratio/7/m784261094-bff76b959ebb8fc39f7eb2d0)](https://status.sv443.net/)
[![Open Issues](https://img.shields.io/github/issues/Sv443/JokeAPI)](https://github.com/Sv443/JokeAPI/issues)

[![Actions Status](https://github.com/Sv443/JokeAPI/workflows/build/badge.svg)](https://github.com/Sv443/JokeAPI/actions)
[![Known Vulnerabilities](https://snyk.io/test/github/Sv443/JokeAPI/badge.svg)](https://snyk.io/test/github/Sv443/JokeAPI)

[![Discord](https://img.shields.io/discord/565933531214118942)](https://discord.gg/aBH4uRG)
[![GitHub watchers](https://img.shields.io/github/watchers/Sv443/JokeAPI?style=social)](https://github.com/Sv443/JokeAPI/watchers)
[![GitHub stars](https://img.shields.io/github/stars/Sv443/JokeAPI?style=social)](https://github.com/Sv443/JokeAPI/stargazers)

<br><br>

# [Documentation](https://sv443.net/jokeapi/v2) &bull; [Try it out](https://sv443.net/jokeapi/v2#try-it) &bull; [Changelog](./changelog.txt)
# [Documentation](https://sv443.net/jokeapi/v2)
# [Try it out](https://sv443.net/jokeapi/v2#try-it) &bull; [Changelog](./changelog.txt)


</div>
<br><br>

## Before contributing to JokeAPI, please read the [contributing guide](./.github/Contributing.md)
## If you want to contribute to JokeAPI (code, jokes or translations), please read the [contributing guide.](./.github/Contributing.md)

<br><br>

Expand All @@ -37,6 +37,7 @@
- [Jokepy](https://github.com/aksty/Jokepy) by [aksty](https://github.com/aksty)
- [Dark1](https://github.com/whiteadi/Dark1) by [whiteadi](https://github.com/whiteadi)
- [Prejudice Networks](https://github.com/LiamTownsley/Prejudice-Networks) by [Liam Townsley](https://github.com/LiamTownsley)
- [https://irshad.ml/humour.html](https://irshad.ml/humour.html) by [draco-malfoy](https://github.com/draco-malfoy)

([Contact me](https://sv443.net/discord) to get your project added here)

Expand Down
44 changes: 25 additions & 19 deletions changelog.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
====================
=====================
JokeAPI Changelog
- Version 2.2.0 -
=====================

JokeAPI Changelog
- Version 2.1.5 -

====================

[Planned for future releases]
- Allow definition of max requests per minute per each client (issue #37)
- Add positive flags and a "?whitelistFlags" param (issue #127)
- Add Unit Tests (issue #121)
- Serve docs with nginx to speed up page load times (issue #118)


[PLANNED: 2.2.0]
- Add joke category "Pun" (issue #105)
- Allow definition of max requests per minute per each client (issue #37)
- Add support for jokes and error messages of different languages (issue #75)
[CURRENT: 2.2.0]
- Added joke category "Pun" (issue #105)
- Added "?amount" parameter to joke endpoint so multiple jokes can be fetched at once (issue #126)
- Added support for jokes and error messages of different languages (issue #75)
- /langcode/{LANGUAGE} endpoint
- /languages endpoint
- "?lang=code" URL parameter
- Fix ID caching (again, sigh) (issue #80)
- Add pm2 custom metrics (issue #91)
- Fix HTTP 403 errors (issue #96)
- Remake the URL parser using a "commercial" package (issue #97)
- Daemonize the API token refreshing (issue #102)
- Rate limit joke submissions more harshly (issue #104)
- Fix resources not being served with Brotli even though it is supported by the client (issue #106)


[CURRENT: 2.1.5] - 2020 Q3 general patch #2
- Fixed ID caching (again, sigh) (issue #80)
- Added pm2 custom metrics (issue #91)
- Fixed HTTP 403 errors (issue #96)
- Remade the URL parser using a package (issue #97)
- Daemonized the API token refreshing (issue #102)
- Rate limiting joke submissions more harshly now (issue #104)
- Fixed error where the end of the payload were cut off, thus invalidating JSON (issue #119)
- Joke submission property order is now enforced, improving uniformity (issue #120)
- Joke submissions are now validated to make sure they don't contain fancy Unicode chars (issue #123)


[2.1.5] - 2020 Q3 general patch #2
- Ditched my botched rate limiting package for a "commercial" one (issue #113)
- Added API token section to documentation (issue #114)
- Client now receives a "Token-Valid" header with the value 0 or 1 depending on token validity (issue #115)
Expand Down
Loading

0 comments on commit 221a9f8

Please sign in to comment.