Socket
Socket
Sign inDemoInstall

dadjoke.js

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.1.0

examples/example.js

55

lib/core/DadJokeClient.js

@@ -1,47 +0,18 @@

/**
* The base class of the DadJokeClient
*/
class DadJokeClient
{
/**
* Creates a new DadJoke instance
*/
constructor(userAgent)
{
/**
* Snekfetch
*
* @type {Snekfetch}
* @private
*/
this._snek = require('snekfetch');
/**
* The base url
*
* @type {String}
*/
this.baseURL = require('./util/Constants').BASE_URL;
this.userAgent = userAgent;
module.exports = class DadJokeClient {
constructor(userAgent = 'dadjoke.js/Production/v0.1.0') {
this.userAgent = userAgent;
this.snek = require('snekfetch');
this.baseURL = require('../util/Constants').URL;
}
/**
* Gets a Dad Joke!
*
* @returns {Promise<String>} The URL
*/
async getDadJoke()
{
return new Promise((res, rej) =>
{
return this._snek.get(this.baseURL)
.set('User-Agent', this.userAgent || `dadjoke.js (v${require('../../package.json').version} https://github.com/ohlookitsAugust/dadjoke.js)`)
get() {
return new Promise((resolve, reject) => {
this.snek
.get(this.baseURL)
.set('Accept', 'application/json')
.then((result) => res(result.body))
.catch((err) => rej(err));
.set('User-Agent', this.userAgent)
.then((res) => resolve(res.body))
.catch((err) => reject(err));
});
}
}
module.exports = DadJokeClient;
};
module.exports = {
DadJokeClient: require('./core/DadJokeClient'),
Constants: require('./core/util/Constants'),
Client: require('./core/DadJokeClient'),
Constants: require('./util/Constants'),
version: require('../package.json').version
};
{
"name": "dadjoke.js",
"description": "An API wrapper for a dad joke! I mean, who doesn't love them?!",
"version": "0.0.2",
"description": "dadjoke.js is an API Wrapper that handles http requests for Dad Jokes.",
"version": "0.1.0",
"dependencies": {
"snekfetch": "3.6.4"
"snekfetch": "4.0.4"
},
"author": "August (Chris)",
"bugs": {
"url": "https://github.com/ohlookitsAugust/dadjoke.js/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/ohlookitsAugust/dadjoke.js"
}, "main": "./lib/index.js" }
"main": "./lib/index.js",
"typings": "./typings/index.d.ts",
"author": {
"name": "August (Chris)",
"url": "https://augu.me",
"email": "august@augu.me"
}
}
# dadjoke.js
dadjoke.js is a Dad Joke wrapper.
[`dadjoke.js`](https://npmjs.com/package/dadjoke.js) is an API Wrapper that handles http requests for Dad Jokes.
## API
```js
const { DadJokeClient } = require('dadjoke.js');
const client = new DadJokeClient();
**You can add dadjoke.js as an dependency by:**
```sh
# Yarn
$ yarn add dadjoke.js
client.getDadJoke().then((body) => {
console.log(`📣 ${body.joke}`);
});
# NPM
$ npm install dadjoke.js
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc