1 | /** |
||
2 | * @author Jinzulen |
||
3 | * @license Apache 2.0 |
||
4 | * |
||
5 | * TenorJS - Lightweight NodeJS wrapper around the Tenor.com API. |
||
6 | */ |
||
7 | const Utilities = require("./src/Tools/Utilities"); |
||
8 | |||
9 | exports.client = function (Credentials) |
||
10 | { |
||
11 | const Filters = ["off", "low", "medium", "high"], |
||
12 | MediaFilters = ["gif", "mp4", "nanomp4", "nanogif", "tinymp4", "tinygif"]; |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
13 | |||
14 | /** |
||
15 | * Credentials checks. |
||
16 | */ |
||
17 | if (!Credentials.Key || !Credentials.Locale || !Credentials.Filter) |
||
18 | { |
||
19 | throw new Error ("Client configuration is not complete; please ensure all configuration parameters are satisfied (Key, Locale, Filter)."); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Set default date format if user has set none. |
||
24 | */ |
||
25 | if (!Credentials.DateFormat) Credentials.DateFormat = "D/MM/YYYY - H:mm:ss A"; |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
26 | |||
27 | /** |
||
28 | * Check if the set content filter level abides by the available options. |
||
29 | */ |
||
30 | if (!Filters.includes(Credentials.Filter.toLowerCase())) throw new Error ("Content filter level has to be one of these options: off, low, medium, high."); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
31 | |||
32 | /** |
||
33 | * Set API gateway and set content filter to lowercase. |
||
34 | */ |
||
35 | Credentials.Gate = "https://tenor.googleapis.com/v2"; |
||
36 | Credentials.Filter = Credentials.Filter.toLowerCase(); |
||
37 | |||
38 | /** |
||
39 | * Check status of TenorJS config. |
||
40 | */ |
||
41 | Utilities.checkConfig(JSON.stringify(Credentials)); |
||
42 | |||
43 | return require("./src")(Credentials); |
||
44 | }; |