Skip to content

Commit 221a9f8

Browse files
author
Sven Fehler
authored
Merge pull request #78 (v2.2.0) from Sv443/wip/2.2.0
2 parents 11c39bd + 712f8e5 commit 221a9f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+6750
-1667
lines changed

.github/Contributing.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
# Before submitting your contribution, please read the following:
1+
# Contributing Guide
2+
This guide will tell you how you can and should contribute to JokeAPI.
3+
Not following it might cause me to reject your changes but at the very least we will both lose time.
4+
So please read this guide before contributing. Thanks :)
5+
6+
## Menu:
7+
- [Submitting or editing jokes](#submitting-or-editing-jokes)
8+
- [Contributing to JokeAPI's code](#submitting-code)
9+
- [Submitting a translation](#submitting-translations)
10+
- [Tips and Tricks for contributing](#other-nice-to-know-stuff)
11+
12+
<br><br><br><br>
13+
14+
## Submitting or editing jokes:
15+
To submit a joke manually, you can use the form on [this page.](https://sv443.net/jokeapi/v2/#submit)
16+
To submit it through code, you can make use of the ["submit" endpoint.](https://sv443.net/jokeapi/v2/#submit-endpoint)
17+
18+
If you instead want to *edit* a joke, you can find them in the `jokes-xy.json` files in [`data/jokes/`](../data/jokes/)
19+
Please then follow the [code contribution section](#submitting-code) as well.
20+
21+
<br><br>
22+
23+
## Submitting code:
224
1. [Read the Code_of_Conduct.md file](./Code_of_Conduct.md) (TLDR: just behave in a friendly manner).
325
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.
426
3. Make the changes you want to make to the code.
@@ -7,8 +29,8 @@
729
- `npm run validate-ids` to verify that all jokes have the correct ID.
830
- `npm run lint` to check the code for any warnings or errors.
931
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.
10-
6. Add yourself to the `contributors` object in the file `package.json` :)
11-
- **If it doesn't exist or is empty** please add it using the second format on [this website](https://flaviocopes.com/package-json/#contributors)
32+
6. Add yourself to the `contributors` object in the [`package.json`](../package.json) file :)
33+
<!-- - **If it doesn't exist or is empty** please add it using the second format on [this website](https://flaviocopes.com/package-json/#contributors) -->
1234
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
1335
- 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.
1436
8. Request a review from me (Sv443).
@@ -19,9 +41,20 @@
1941

2042
<br><br>
2143

22-
### Other nice-to-know stuff:
44+
## Submitting Translations:
45+
If you want to submit a translation, please follow these steps:
46+
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.
47+
2. Translate coded error messages in the file [`data/errorMessages.js`](../data/errorMessages.js) by following the style of the other translations.
48+
3. Translate the generic strings inside of the file [`data/translations.json`](../data/translations.json) by also following the style of the other translations.
49+
4. Add yourself to the `contributors` object in the [`package.json`](../package.json) file :)
50+
51+
<br><br>
52+
53+
## Other nice-to-know stuff:
2354
- 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.
24-
- 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.
25-
- 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.
55+
- 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.
56+
- 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.
57+
58+
<br><br>
2659

27-
## If you need any help, please feel free to contact me through [Discord](https://sv443.net/discord) or [E-Mail](mailto:sven.fehler@web.de?subject=Questions%20about%20contributing%20to%20JokeAPI)
60+
## 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:contact@sv443.net?subject=Questions%20about%20contributing%20to%20JokeAPI)

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--- Provide a short, general summary of your changes in the Title above -->
2+
3+
## Description
4+
<!-- Describe your changes in detail -->
5+
6+
## Related Issue
7+
<!-- If there is an issue related to this PR or this PR fixes the issue, please add it here: -->
8+
9+
## Motivation and Context
10+
<!- Why is this change required? What problem does it solve? -->
11+
12+
## How Has This Been Tested?
13+
<!-- Please describe in detail how you tested your changes. -->
14+
<!-- Include details of your testing environment, and the tests you ran to -->
15+
<!-- see how your change affects other areas of the code, etc. -->
16+
17+
## Screenshots (if appropriate):
18+
<!-- Add some screenshots here, if applicable -->
19+
20+
## Checklist
21+
- [ ] I have read the [Contributing Guide](../Contributing.md)
22+
- [ ] I read and accept the [Code of Conduct](../Code_of_Conduct.md) (TLDR: just behave in a friendly manner)
23+
- [ ] My code follows the general style of this project
24+
- [ ] I have commented my code, particularly in hard-to-understand areas
25+
- [ ] I have made corresponding changes to the documentation (if applicable)
26+
- [ ] I ensured that the automated checks that ran on this PR have completed successfully
27+
- [ ] I added myself to the `package.json` file (optional)

.github/SECURITY.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Please **do not** create a GitHub issue!
66

77
## Supported Versions
88
These versions are still supported and will be receiving security updates:
9-
| Version | Supported |
10-
| --- | --- |
11-
| v1.0 ||
12-
| v1.1 ||
13-
| v2.0 ||
14-
| v2.1 ||
9+
| Version | Supported | Status |
10+
| --- | --- | --- |
11+
| [v1.0](https://github.com/Sv443/JokeAPI/releases/tag/v1.0.0) || deprecated |
12+
| [v1.1](https://github.com/Sv443/JokeAPI/releases/tag/v1.1.3) || deprecated |
13+
| [v2.0](https://github.com/Sv443/JokeAPI/releases/tag/v2.0.1) || outdated |
14+
| [v2.1](https://github.com/Sv443/JokeAPI/releases/tag/v2.1.5) || outdated |
15+
| [v2.2](https://github.com/Sv443/JokeAPI/releases/tag/v2.2.0) || active |

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,17 @@ node_modules/
1616
dev/madge/
1717
dependency-graph.html
1818
test.js
19+
!tools/test.js
1920

2021
# Docs:
2122
docs/documentation.html
2223
docs/compiled
2324

2425
# Joke submissions:
25-
data/submissions/submission_*.json
26-
27-
# Re-inclusions:
28-
!change.log*
26+
data/submissions/*/*.json
2927

3028
# Auth Tokens:
3129
data/tokens.json
3230

3331
# Other potentially sensitive information:
34-
lists/*.json
32+
data/lists/*.json

.snyk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
2-
version: v1.14.1
2+
version: v1.13.5
33
ignore: {}
44
# patches apply the minimum changes required to fix a vulnerability
55
patch:

.vscode/launch.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,30 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"program": "${workspaceFolder}/tools/add-joke.js",
9+
"name": "Tools/xy",
10+
"request": "launch",
11+
"type": "node",
12+
"skipFiles": [
13+
"<node_internals>/**"
14+
],
15+
"args": [
16+
"--trace-deprecation"
17+
],
18+
"console": "integratedTerminal"
19+
},
720
{
821
"type": "node",
922
"request": "launch",
10-
"name": "Launch Program",
23+
"name": "Debug JokeAPI",
1124
"skipFiles": [
1225
"<node_internals>/**"
1326
],
14-
"program": "${workspaceFolder}/JokeAPI.js"
27+
"program": "${workspaceFolder}/JokeAPI.js",
28+
"args": [
29+
"--trace-deprecation"
30+
]
1531
}
1632
],
1733
"debug.javascript.usePreview": true

.vscode/settings.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,35 @@
1313
"color": "#f88"
1414
}
1515
],
16-
"(#MARKER)": [ // #MARKER test
16+
"(#MARKER)": [ //#MARKER test
1717
{
1818
"backgroundColor": "#f41",
1919
"color": "#fff",
2020
"isWholeLine": true,
2121
"overviewRulerColor": "#f41"
2222
}
2323
],
24-
"(#SECTION [a-zA-Z0-9_-]+)": [ //#SECTION test
24+
"(#SECTION [a-zA-Z0-9_-,]+)": [ //#SECTION test, foo bar
2525
{
2626
"backgroundColor": "#44f",
2727
"color": "white",
2828
"overviewRulerColor": "#44f"
2929
}
3030
],
31-
"(#DEBUG#)": [
31+
"(#DEBUG)": [ //#DEBUG
3232
{
3333
"backgroundColor": "#ff0",
3434
"color": "blue",
3535
"overviewRulerColor": "#ff0"
3636
}
37+
],
38+
"(?<!\\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)": [
39+
{
40+
"rangeBehavior": 1,
41+
"borderWidth": "1px",
42+
"borderColor": "$1",
43+
"borderStyle": "solid"
44+
}
3745
]
3846
},
3947
"npm-scripts.showStartNotification": false

JokeAPI.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// 🔹 JokeAPI v2 by Sv443 🔹
1+
// 🔹 JokeAPI by Sv443 🔹
22
//
33
// GitHub: https://github.com/Sv443/JokeAPI
44
// API Docs: https://sv443.net/jokeapi/v2
55
// ️
6-
// ⚠️ Please read the LICENSE.txt file before redistributing JokeAPI.
6+
// ⚠️ Please read the LICENSE.txt file before modifying, redistributing or even selling JokeAPI.
77
// ⚠️ Thanks :)
88

99

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

1616
function initJokeAPI()
1717
{
18+
if(settings.debug.verboseLogging)
19+
console.log("\n\n");
1820
debug("PreInit", "Called InitJokeAPI");
1921
// the debugger and child processes don't get along together so only wrap JokeAPI if the debugger is not active:
2022
if(!jsl.inDebugger() && !settings.wrapper.skipWrapping)

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
# [![icon](https://sv443.net/cdn/jokeapi/icon_readme.png)](#readme)<br>JokeAPI
44
### A REST API that serves uniformly and well formatted jokes and offers a great variety of filtering methods and response customization
55
[![GitHub](https://img.shields.io/github/license/Sv443/JokeAPI)](https://sv443.net/LICENSE)
6-
[![Uptime / 7 Days](https://img.shields.io/uptimerobot/ratio/7/m782998549-afcc0d10c27c87df47e73289)](https://status.sv443.net/)
6+
[![Uptime / 7 Days](https://img.shields.io/uptimerobot/ratio/7/m784261094-bff76b959ebb8fc39f7eb2d0)](https://status.sv443.net/)
77
[![Open Issues](https://img.shields.io/github/issues/Sv443/JokeAPI)](https://github.com/Sv443/JokeAPI/issues)
88

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

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

1615
<br><br>
1716

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

2020

2121
</div>
2222
<br><br>
2323

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

2626
<br><br>
2727

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

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

changelog.txt

100755100644
Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
====================
1+
=====================
2+
JokeAPI Changelog
3+
- Version 2.2.0 -
4+
=====================
25

3-
JokeAPI Changelog
4-
- Version 2.1.5 -
5-
6-
====================
76

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

913

10-
[PLANNED: 2.2.0]
11-
- Add joke category "Pun" (issue #105)
12-
- Allow definition of max requests per minute per each client (issue #37)
13-
- Add support for jokes and error messages of different languages (issue #75)
14+
[CURRENT: 2.2.0]
15+
- Added joke category "Pun" (issue #105)
16+
- Added "?amount" parameter to joke endpoint so multiple jokes can be fetched at once (issue #126)
17+
- Added support for jokes and error messages of different languages (issue #75)
1418
- /langcode/{LANGUAGE} endpoint
1519
- /languages endpoint
1620
- "?lang=code" URL parameter
17-
- Fix ID caching (again, sigh) (issue #80)
18-
- Add pm2 custom metrics (issue #91)
19-
- Fix HTTP 403 errors (issue #96)
20-
- Remake the URL parser using a "commercial" package (issue #97)
21-
- Daemonize the API token refreshing (issue #102)
22-
- Rate limit joke submissions more harshly (issue #104)
23-
- Fix resources not being served with Brotli even though it is supported by the client (issue #106)
24-
25-
26-
[CURRENT: 2.1.5] - 2020 Q3 general patch #2
21+
- Fixed ID caching (again, sigh) (issue #80)
22+
- Added pm2 custom metrics (issue #91)
23+
- Fixed HTTP 403 errors (issue #96)
24+
- Remade the URL parser using a package (issue #97)
25+
- Daemonized the API token refreshing (issue #102)
26+
- Rate limiting joke submissions more harshly now (issue #104)
27+
- Fixed error where the end of the payload were cut off, thus invalidating JSON (issue #119)
28+
- Joke submission property order is now enforced, improving uniformity (issue #120)
29+
- Joke submissions are now validated to make sure they don't contain fancy Unicode chars (issue #123)
30+
31+
32+
[2.1.5] - 2020 Q3 general patch #2
2733
- Ditched my botched rate limiting package for a "commercial" one (issue #113)
2834
- Added API token section to documentation (issue #114)
2935
- Client now receives a "Token-Valid" header with the value 0 or 1 depending on token validity (issue #115)

0 commit comments

Comments
 (0)