Skip to content

Commit

Permalink
Merge pull request #4 from snyk-tech-services/develop
Browse files Browse the repository at this point in the history
fix: Merge changes to prod
  • Loading branch information
aarlaud authored May 29, 2020
2 parents 459cbe9 + d58a7f4 commit c3feca9
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 79 deletions.
81 changes: 81 additions & 0 deletions src/lib/examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { requestsManager } from './request/requestManager'

const run = async () => {
const manager = new requestsManager()
manager.on('data', {
callback:(requestId, data) => {
console.log("response for request ", requestId)
console.log(data)
}
})

manager.on('error', {
callback:(requestId, data) => {
console.log("response for request ", requestId)
console.log(data)
}
})

try{
let requestSync = await manager.request({verb: "GET", url: '/', body: ''})
console.log(requestSync)
console.log('done with synced request')
} catch (err) {
console.log('error')
console.log(err)
}


manager.on('data', {
callback:(requestId, data) => {
console.log("response for request on test-channel ", requestId)
console.log(data)
},
channel: 'test-channel'
})

try {
console.log('1',manager.requestStream({verb: "GET", url: '/', body: ''}))
console.log('1-channel',manager.requestStream({verb: "GET", url: '/', body: ''}, 'test-channel'))
console.log('2',manager.requestStream({verb: "GET", url: '/', body: ''}))
console.log('2-channel',manager.requestStream({verb: "GET", url: '/', body: ''}, 'test-channel'))
console.log('3',manager.requestStream({verb: "GET", url: '/', body: ''}))
console.log('3-channel',manager.requestStream({verb: "GET", url: '/', body: ''}, 'test-channel'))
} catch (err) {
console.log(err)
}




const filters = `{
"filters": {
"severities": [
"high",
"medium",
"low"
],
"exploitMaturity": [
"mature",
"proof-of-concept",
"no-known-exploit",
"no-data"
],
"types": [
"vuln",
"license"
],
"ignored": false
}
}
`
try {
const results = await manager.requestBulk([{verb: "GET", url: '/', body: ''}, {verb: "POST", url: '/org/334e0c45-5d3d-40f6-b882-ae82a164b317/project/0bbbfee1-2138-4322-80d4-4166d1259ae5/issues', body: filters}, {verb: "GET", url: '/', body: ''}])
console.log(results)
} catch(resultsWithError) {
console.log(resultsWithError)
}

}

run()
82 changes: 3 additions & 79 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,82 +1,6 @@
import 'source-map-support/register';
import { requestsManager } from './request/requestManager'

const run = async () => {
const manager = new requestsManager()
manager.on('data', {
callback:(requestId, data) => {
console.log("response for request ", requestId)
console.log(data)
}
})

manager.on('error', {
callback:(requestId, data) => {
console.log("response for request ", requestId)
console.log(data)
}
})

try{
let requestSync = await manager.request({verb: "GET", url: '/', body: ''})
console.log(requestSync)
console.log('done with synced request')
} catch (err) {
console.log('error')
console.log(err)
}


manager.on('data', {
callback:(requestId, data) => {
console.log("response for request on test-channel ", requestId)
console.log(data)
},
channel: 'test-channel'
})

try {
console.log('1',manager.requestStream({verb: "GET", url: '/', body: ''}))
console.log('1-channel',manager.requestStream({verb: "GET", url: '/', body: ''}, 'test-channel'))
console.log('2',manager.requestStream({verb: "GET", url: '/', body: ''}))
console.log('2-channel',manager.requestStream({verb: "GET", url: '/', body: ''}, 'test-channel'))
console.log('3',manager.requestStream({verb: "GET", url: '/', body: ''}))
console.log('3-channel',manager.requestStream({verb: "GET", url: '/', body: ''}, 'test-channel'))
} catch (err) {
console.log(err)
}




const filters = `{
"filters": {
"severities": [
"high",
"medium",
"low"
],
"exploitMaturity": [
"mature",
"proof-of-concept",
"no-known-exploit",
"no-data"
],
"types": [
"vuln",
"license"
],
"ignored": false
}
}
`
try {
const results = await manager.requestBulk([{verb: "GET", url: '/', body: ''}, {verb: "POST", url: '/org/334e0c45-5d3d-40f6-b882-ae82a164b317/project/0bbbfee1-2138-4322-80d4-4166d1259ae5/issues', body: filters}, {verb: "GET", url: '/', body: ''}])
console.log(results)
} catch(resultsWithError) {
console.log(resultsWithError)
}

}

run()
export {
requestsManager
}

0 comments on commit c3feca9

Please sign in to comment.