stamina-api
Advanced tools
Comparing version 1.0.0-dev to 1.0.1-dev
module.exports = { | ||
gettingOption_Missing: "[GETTING_OPTION_MISSING] The 'getting option' is missing.", | ||
gettingOption_Invalid: "[GETTING_OPTION_INVALID] An invalid 'getting option' was provided.", | ||
jokesByType_Missing: "[JOKES_BY_TYPE_MISSING] The 'by type option' is missing.", | ||
jokesByType_Invalid: "[JOKES_BY_TYPE_INVALID] An invalid 'by type option' was provided.", | ||
jokesByType_Missing: "[JOKES_BY_TYPE_MISSING] The 'type' is missing.", | ||
jokesByType_Invalid: "[JOKES_BY_TYPE_INVALID] An invalid 'type' was provided.", | ||
jokesById_Missing: "[JOKES_BY_ID_MISSING] The 'id' is missing.", | ||
jokesById_Invalid: "[JOKES_BY_ID_INVALID] An invalid 'id' was provided.", | ||
MUST_BE_TYPE_OBJECT: "The 'option' option must be an Object.", | ||
MUST_BE_TYPE_STRING_ARRAY: "The 'disallow' option must be an Array or String.", | ||
} |
@@ -46,5 +46,12 @@ const MessageErrors = require("../errors/MessageErrors.js") | ||
}, | ||
/*byId(id) { | ||
return "id: "+id | ||
}*/ | ||
byId(id) { | ||
if (!id) throw new Error(MessageErrors.jokesById_Missing) | ||
if (typeof id !== "number") throw new Error(MessageErrors.jokesById_Invalid) | ||
var blagues = require("../jokes/jokes.json") | ||
blagues = blagues.filter(b => b.id === Number(id)) | ||
if (blagues) { | ||
return blagues | ||
} else throw new Error(MessageErrors.jokesById_Invalid) | ||
} | ||
} |
{ | ||
"name": "stamina-api", | ||
"version": "1.0.0-dev", | ||
"version": "1.0.1-dev", | ||
"description": "Ce module est une api consernant le site Stamina et le jeu portant le même nom, nous sommes encore en développement, mais notre module sera utilisé par vous et par nous les développeurs de Stamina. Mais vous n'aurez accès aux fonctions de développement consernant l'infrastructure de Stamina.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -36,3 +36,3 @@ [](https://discord.gg/rCg6C7YJXJ) | ||
A cette méthode, vous pouvez spécifier certains types que vous ne souhaitez pas | ||
Avec cette méthode, vous pouvez spécifier certains types que vous ne souhaitez pas | ||
recevoir. | ||
@@ -60,3 +60,3 @@ | ||
```js | ||
const blague = await api.jokes.byID(50); | ||
const blague = await Stamina.get("jokes").byID(50); | ||
``` | ||
@@ -63,0 +63,0 @@ |
186465
7557