Issues (3)

index.js (1 issue)

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
The constant MediaFilters seems to be never used. Consider removing it.
Loading history...
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";
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.");
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
};