New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

confetti

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

confetti - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

8

package.json
{
"name": "confetti",
"version": "1.0.7",
"version": "1.0.8",
"description": "A Node wrapper for the Confetti API.",

@@ -22,6 +22,6 @@ "main": "src/index.js",

"chai-as-promised": "^7.1.1",
"fetch-mock": "^9.1.1",
"mocha": "^7.0.1",
"fetch-mock": "^9.2.1",
"mocha": "^7.1.0",
"prettier": "1.19.1",
"sinon": "^9.0.0",
"sinon": "^9.0.1",
"sinon-chai": "^3.5.0"

@@ -28,0 +28,0 @@ },

@@ -9,16 +9,20 @@ const url = require('url')

module.exports = function({ apiKey, fetch, apiHost, apiProtocol }) {
const API_HOST = apiHost || process.env.API_HOST || 'api.confetti.events'
const API_PROTOCOL = apiProtocol || process.env.API_PROTOCOL || 'https'
module.exports = function({ apiKey, fetch, apiHost, apiProtocol } = {}) {
const httpRequest = async function(method, options) {
let { path, json, filter, sort, page, raw } = options
if (!fetch) {
fetch = require('node-fetch')
}
if (options.apiKey) apiKey = options.apiKey
if (options.fetch) fetch = options.fetch
if (options.apiHost) apiHost = options.host
if (options.apiProtocol) apiProtocol = options.protocol
if (!apiKey) {
throw new Error('missing_api_key')
}
const API_HOST = apiHost || process.env.API_HOST || 'api.confetti.events'
const API_PROTOCOL = apiProtocol || process.env.API_PROTOCOL || 'https'
const httpRequest = async function(method, options) {
let { path, json, filter, sort, page, raw } = options
if (!fetch) {
fetch = require('node-fetch')
}
if (!apiKey) {
throw new Error('missing_api_key')
}

@@ -25,0 +29,0 @@ const httpOptions = {

@@ -14,3 +14,3 @@ const dotenv = require('dotenv')

adapter: adapter({
apiKey: settings.key,
apiKey: settings.apiKey,
fetch: settings.fetch,

@@ -28,2 +28,10 @@ apiHost: settings.host,

Object.assign(
Confetti,
resources({
adapter: adapter(),
models
})
)
module.exports = Confetti
module.exports = function({ adapter, models }) {
const createResource = resourceName => {
return {
findAll({ filter, sort, page, raw } = {}) {
findAll({
filter,
sort,
page,
raw,
apiKey,
fetch,
apiHost,
apiProtocol
} = {}) {
return adapter.get({

@@ -9,7 +18,18 @@ path: resourceName,

sort,
page
page,
apiKey,
fetch,
apiHost,
apiProtocol
})
},
find(id, { raw } = {}) {
return adapter.get({ path: `${resourceName}/${id}`, raw })
find(id, { raw, apiKey, fetch, apiHost, apiProtocol } = {}) {
return adapter.get({
path: `${resourceName}/${id}`,
raw,
apiKey,
fetch,
apiHost,
apiProtocol
})
}

@@ -16,0 +36,0 @@ }

const Confetti = require('../../src')
const { expect, sinon, fetchData, fetch } = require('../helper')
const confetti = new Confetti({ key: 'my-key', fetch })
const confetti = new Confetti({ apiKey: 'my-key', fetch })

@@ -6,0 +6,0 @@ describe('Adapter', function() {

@@ -9,7 +9,8 @@ const Confetti = require('../../src')

it('should fail to initiate a Confetti api instance due to missing api key', function() {
expect(() => {
new Confetti()
}).to.throw('missing_api_key')
it('should fail to call due on Confetti api instance due to missing api key', async function() {
const confetti = new Confetti()
await expect(confetti.events.findAll()).to.be.rejectedWith(
'missing_api_key'
)
})
})

@@ -9,123 +9,263 @@ const Confetti = require('../../src')

})
describe('Instance', function() {
describe('Events', function() {
it('should request one event', async function() {
fetch.get(
'https://api.confetti.events/events/1',
Confetti.models.event.sample.single.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.events.find(1)
expect(data).to.deep.equal(
Confetti.models.event.sample.single.formatted
)
})
it('should request multiple events', async function() {
fetch.get(
'https://api.confetti.events/events',
Confetti.models.event.sample.multiple.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.events.findAll()
expect(data).to.deep.equal(
Confetti.models.event.sample.multiple.formatted
)
})
})
describe('Events', function() {
it('should request one event', async function() {
fetch.get(
'https://api.confetti.events/events/1',
Confetti.models.event.sample.single.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.events.find(1)
expect(data).to.deep.equal(Confetti.models.event.sample.single.formatted)
describe('Payments', function() {
it('should request one payment', async function() {
fetch.get(
'https://api.confetti.events/payments/1',
Confetti.models.payment.sample.single.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.payments.find(1)
expect(data).to.deep.equal(
Confetti.models.payment.sample.single.formatted
)
})
it('should request multiple payments', async function() {
fetch.get(
'https://api.confetti.events/payments',
Confetti.models.payment.sample.multiple.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.payments.findAll()
expect(data).to.deep.equal(
Confetti.models.payment.sample.multiple.formatted
)
})
})
it('should request multiple events', async function() {
fetch.get(
'https://api.confetti.events/events',
Confetti.models.event.sample.multiple.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.events.findAll()
expect(data).to.deep.equal(
Confetti.models.event.sample.multiple.formatted
)
describe('Tickets', function() {
it('should request one ticket', async function() {
fetch.get(
'https://api.confetti.events/tickets/1',
Confetti.models.ticket.sample.single.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.tickets.find(1)
expect(data).to.deep.equal(
Confetti.models.ticket.sample.single.formatted
)
})
it('should request multiple tickets', async function() {
fetch.get(
'https://api.confetti.events/tickets',
Confetti.models.ticket.sample.multiple.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.tickets.findAll()
expect(data).to.deep.equal(
Confetti.models.ticket.sample.multiple.formatted
)
})
})
})
describe('Payments', function() {
it('should request one payment', async function() {
fetch.get(
'https://api.confetti.events/payments/1',
Confetti.models.payment.sample.single.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.payments.find(1)
expect(data).to.deep.equal(
Confetti.models.payment.sample.single.formatted
)
describe('Webhooks', function() {
it('should request one webhook', async function() {
fetch.get(
'https://api.confetti.events/webhooks/1',
Confetti.models.webhook.sample.single.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.webhooks.find(1)
expect(data).to.deep.equal(
Confetti.models.webhook.sample.single.formatted
)
})
it('should request multiple webhooks', async function() {
fetch.get(
'https://api.confetti.events/webhooks',
Confetti.models.webhook.sample.multiple.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.webhooks.findAll()
expect(data).to.deep.equal(
Confetti.models.webhook.sample.multiple.formatted
)
})
})
it('should request multiple payments', async function() {
fetch.get(
'https://api.confetti.events/payments',
Confetti.models.payment.sample.multiple.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.payments.findAll()
expect(data).to.deep.equal(
Confetti.models.payment.sample.multiple.formatted
)
describe('Workspaces', function() {
it('should request one workspace', async function() {
fetch.get(
'https://api.confetti.events/workspaces/1',
Confetti.models.workspace.sample.single.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.workspaces.find(1)
expect(data).to.deep.equal(
Confetti.models.workspace.sample.single.formatted
)
})
it('should request multiple workspaces', async function() {
fetch.get(
'https://api.confetti.events/workspaces',
Confetti.models.workspace.sample.multiple.raw
)
const confetti = new Confetti({ apiKey: 'my-key', fetch })
const data = await confetti.workspaces.findAll()
expect(data).to.deep.equal(
Confetti.models.workspace.sample.multiple.formatted
)
})
})
})
describe('Tickets', function() {
it('should request one ticket', async function() {
fetch.get(
'https://api.confetti.events/tickets/1',
Confetti.models.ticket.sample.single.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.tickets.find(1)
expect(data).to.deep.equal(Confetti.models.ticket.sample.single.formatted)
describe('Static', function() {
describe('Events', function() {
it('should request one event', async function() {
fetch.get(
'https://api.confetti.events/events/1',
Confetti.models.event.sample.single.raw
)
const data = await Confetti.events.find(1, { apiKey: 'my-key', fetch })
expect(data).to.deep.equal(
Confetti.models.event.sample.single.formatted
)
})
it('should request multiple events', async function() {
fetch.get(
'https://api.confetti.events/events',
Confetti.models.event.sample.multiple.raw
)
const data = await Confetti.events.findAll({ apiKey: 'my-key', fetch })
expect(data).to.deep.equal(
Confetti.models.event.sample.multiple.formatted
)
})
})
it('should request multiple tickets', async function() {
fetch.get(
'https://api.confetti.events/tickets',
Confetti.models.ticket.sample.multiple.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.tickets.findAll()
expect(data).to.deep.equal(
Confetti.models.ticket.sample.multiple.formatted
)
describe('Payments', function() {
it('should request one payment', async function() {
fetch.get(
'https://api.confetti.events/payments/1',
Confetti.models.payment.sample.single.raw
)
const data = await Confetti.payments.find(1, {
apiKey: 'my-key',
fetch
})
expect(data).to.deep.equal(
Confetti.models.payment.sample.single.formatted
)
})
it('should request multiple payments', async function() {
fetch.get(
'https://api.confetti.events/payments',
Confetti.models.payment.sample.multiple.raw
)
const data = await Confetti.payments.findAll({
apiKey: 'my-key',
fetch
})
expect(data).to.deep.equal(
Confetti.models.payment.sample.multiple.formatted
)
})
})
})
describe('Webhooks', function() {
it('should request one webhook', async function() {
fetch.get(
'https://api.confetti.events/webhooks/1',
Confetti.models.webhook.sample.single.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.webhooks.find(1)
expect(data).to.deep.equal(
Confetti.models.webhook.sample.single.formatted
)
describe('Tickets', function() {
it('should request one ticket', async function() {
fetch.get(
'https://api.confetti.events/tickets/1',
Confetti.models.ticket.sample.single.raw
)
const data = await Confetti.tickets.find(1, { apiKey: 'my-key', fetch })
expect(data).to.deep.equal(
Confetti.models.ticket.sample.single.formatted
)
})
it('should request multiple tickets', async function() {
fetch.get(
'https://api.confetti.events/tickets',
Confetti.models.ticket.sample.multiple.raw
)
const data = await Confetti.tickets.findAll({ apiKey: 'my-key', fetch })
expect(data).to.deep.equal(
Confetti.models.ticket.sample.multiple.formatted
)
})
})
it('should request multiple webhooks', async function() {
fetch.get(
'https://api.confetti.events/webhooks',
Confetti.models.webhook.sample.multiple.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.webhooks.findAll()
expect(data).to.deep.equal(
Confetti.models.webhook.sample.multiple.formatted
)
describe('Webhooks', function() {
it('should request one webhook', async function() {
fetch.get(
'https://api.confetti.events/webhooks/1',
Confetti.models.webhook.sample.single.raw
)
const data = await Confetti.webhooks.find(1, {
apiKey: 'my-key',
fetch
})
expect(data).to.deep.equal(
Confetti.models.webhook.sample.single.formatted
)
})
it('should request multiple webhooks', async function() {
fetch.get(
'https://api.confetti.events/webhooks',
Confetti.models.webhook.sample.multiple.raw
)
const data = await Confetti.webhooks.findAll({
apiKey: 'my-key',
fetch
})
expect(data).to.deep.equal(
Confetti.models.webhook.sample.multiple.formatted
)
})
})
})
describe('Workspaces', function() {
it('should request one workspace', async function() {
fetch.get(
'https://api.confetti.events/workspaces/1',
Confetti.models.workspace.sample.single.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.workspaces.find(1)
expect(data).to.deep.equal(
Confetti.models.workspace.sample.single.formatted
)
describe('Workspaces', function() {
it('should request one workspace', async function() {
fetch.get(
'https://api.confetti.events/workspaces/1',
Confetti.models.workspace.sample.single.raw
)
const data = await Confetti.workspaces.find(1, {
apiKey: 'my-key',
fetch
})
expect(data).to.deep.equal(
Confetti.models.workspace.sample.single.formatted
)
})
it('should request multiple workspaces', async function() {
fetch.get(
'https://api.confetti.events/workspaces',
Confetti.models.workspace.sample.multiple.raw
)
const data = await Confetti.workspaces.findAll({
apiKey: 'my-key',
fetch
})
expect(data).to.deep.equal(
Confetti.models.workspace.sample.multiple.formatted
)
})
})
it('should request multiple workspaces', async function() {
fetch.get(
'https://api.confetti.events/workspaces',
Confetti.models.workspace.sample.multiple.raw
)
const confetti = new Confetti({ key: 'my-key', fetch })
const data = await confetti.workspaces.findAll()
expect(data).to.deep.equal(
Confetti.models.workspace.sample.multiple.formatted
)
})
})
})
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc