Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

first1-test

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

first1-test - npm Package Compare versions

Comparing version 1.0.18 to 1.0.19

.env

66

index.js

@@ -6,14 +6,49 @@ const fetch = require('node-fetch')

const FETCHERS = {
const _FETCHERS = {
notificationApi: {
options: {
key: process.env.NOTIFICATION_API_KEY
withOptions: function () {
return getFetchOptions()
},
fetch: async function (options) {
const defaultOptions = this.withOptions()
const mergeOptions = { ...defaultOptions, options }
return fetch(options.url, mergeOptions)
.then(response => response.json())
.catch(error => console.log(error))
}
},
v3Api: {
withOptions: function (query, variables) {
return {
method: 'POST',
body: JSON.stringify({ query, variables }),
headers: { 'Content-Type': 'application/graphql' }
}
},
fetch: async function (query, variables) {
const options = this.withOptions(query, variables)
const url = process.env.GRAPHQL_URL
return fetch(url, options)
.then(response => response.json())
.catch(error => console.log(error))
}
},
harvestApi: {
withOptions: function () {
return getFetchOptions(this.options)
return getFetchOptions({
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: `Basic ${process.env.HARVEST_KEY}`
}
})
},
fetch: async function (url) {
const options = this.withOptions()
const response = await fetch(url, options)
return response.json()
console.log('url: ', url)
const defaultOptions = this.withOptions()
return fetch(`https://harvest.greenhouse.io/v1/${url}`, defaultOptions)
.then(response => response.json())
.catch(error => console.log(error))
}

@@ -25,13 +60,10 @@ }

const notificationApi = async (url, body) => {
return FETCHERS.notificationApi.fetch(url)
const getExportObject = () => {
const exported = {}
for (const item in _FETCHERS) {
exported[item] = (...arg) => _FETCHERS[item].fetch(...arg)
}
return exported
}
const runTest = async () => {
const r = await notificationApi('https://jsonplaceholder.typicode.com/todos/1')
console.log('Test:notificationApi ', r)
}
runTest()
exports.notificationApi = notificationApi
module.exports = getExportObject()
{
"name": "first1-test",
"version": "1.0.18",
"version": "1.0.19",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

const hasBody = (method) => {
const hasBody = ({ method, body }) => {
const methodWithBody = ['POST', 'PUT', 'DELETE']
return methodWithBody.includes(method)
return body && methodWithBody.includes(method)
}

@@ -11,7 +11,5 @@

method: method || 'GET',
body: hasBody(method) ? JSON.stringify(body) : null,
body: hasBody(options) ? body : null,
headers: {
'Content-Type': 'application/json',
// Authorization: s`Bearer ${process.env.NOTIFICATION_API_KEY}`,
// Authorization: s`Bearer ${key}`,
...headers

@@ -22,6 +20,4 @@ }

return fetchOptions
// const response = await fetch(url, options);
// return response.json();
}
exports.getFetchOptions = getFetchOptions
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