mirror of
https://github.com/oceanprotocol/webtasks
synced 2024-11-27 12:52:58 +01:00
add bounties webtask
This commit is contained in:
parent
d76fb48264
commit
92d80ab42f
27
README.md
27
README.md
@ -14,6 +14,7 @@
|
|||||||
- [Tasks](#tasks)
|
- [Tasks](#tasks)
|
||||||
- [Medium](#medium)
|
- [Medium](#medium)
|
||||||
- [YouTube](#youtube)
|
- [YouTube](#youtube)
|
||||||
|
- [Bounties](#Bounties)
|
||||||
- [Zoho](#zoho)
|
- [Zoho](#zoho)
|
||||||
- [Campaigns API](#campaigns-api)
|
- [Campaigns API](#campaigns-api)
|
||||||
- [CRM API](#crm-api)
|
- [CRM API](#crm-api)
|
||||||
@ -52,6 +53,32 @@ http://localhost:8080/:youtube_playlist_id
|
|||||||
https://TASK_URL/TASK_NAME/:youtube_playlist_id
|
https://TASK_URL/TASK_NAME/:youtube_playlist_id
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Bounties
|
||||||
|
|
||||||
|
**`webtask-bounties.js`**: Task to fetch open bounties on Gitcoin and Bounties.network in one request. Task creates a unified response from fetching both networks.
|
||||||
|
|
||||||
|
Construct your `/` request url like so, e.g. locally:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
http://localhost:8080/
|
||||||
|
|
||||||
|
# when published on webtask.io
|
||||||
|
https://TASK_URL/TASK_NAME/
|
||||||
|
```
|
||||||
|
|
||||||
|
Response is structured by network and fills it with whatever comes back from respective API:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"gitcoin": [
|
||||||
|
{...}
|
||||||
|
],
|
||||||
|
"bountiesNetwork": [
|
||||||
|
{...}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Zoho
|
### Zoho
|
||||||
|
|
||||||
**`webtask-zoho.js`**: Generic task to subscribe users into lists on Zoho Campaigns & Zoho CRM.
|
**`webtask-zoho.js`**: Generic task to subscribe users into lists on Zoho Campaigns & Zoho CRM.
|
||||||
|
10
package.json
10
package.json
@ -3,23 +3,23 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "wt serve webtask-zoho.js",
|
"start": "wt serve webtask-bounties.js",
|
||||||
"test": "eslint ./*.js"
|
"test": "eslint ./*.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.18.3",
|
"body-parser": "^1.18.3",
|
||||||
"cors": "^2.8.4",
|
"cors": "^2.8.4",
|
||||||
"express": "^4.16.3",
|
"express": "^4.16.4",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"webtask-tools": "^3.4.0"
|
"webtask-tools": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^5.4.0",
|
"eslint": "^5.7.0",
|
||||||
"eslint-config-oceanprotocol": "^1.1.1",
|
"eslint-config-oceanprotocol": "^1.2.0",
|
||||||
"eslint-config-standard": "^12.0.0",
|
"eslint-config-standard": "^12.0.0",
|
||||||
"eslint-plugin-import": "^2.14.0",
|
"eslint-plugin-import": "^2.14.0",
|
||||||
"eslint-plugin-node": "^7.0.1",
|
"eslint-plugin-node": "^7.0.1",
|
||||||
"eslint-plugin-promise": "^4.0.0",
|
"eslint-plugin-promise": "^4.0.1",
|
||||||
"eslint-plugin-security": "^1.4.0",
|
"eslint-plugin-security": "^1.4.0",
|
||||||
"eslint-plugin-standard": "^4.0.0"
|
"eslint-plugin-standard": "^4.0.0"
|
||||||
}
|
}
|
||||||
|
39
webtask-bounties.js
Normal file
39
webtask-bounties.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
'use strict' // eslint-disable-line
|
||||||
|
|
||||||
|
const express = require('express')
|
||||||
|
const request = require('request')
|
||||||
|
const webtask = require('webtask-tools')
|
||||||
|
|
||||||
|
const app = express()
|
||||||
|
|
||||||
|
// Just chained callbacks in lack of proper async/await support on webtask.io
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
|
||||||
|
// Gitcoin bounties
|
||||||
|
request('https://gitcoin.co/api/v0.1/bounties/', (error, response, body) => {
|
||||||
|
if (error) return error
|
||||||
|
|
||||||
|
const gitcoinBody = JSON.parse(body) // returns only open bounties by default
|
||||||
|
const gitcoin = gitcoinBody.filter(
|
||||||
|
// filter the response manually, no way atm to do that as API query
|
||||||
|
item => item.funding_organisation.includes('Ocean Protocol')
|
||||||
|
)
|
||||||
|
|
||||||
|
let holder = {}
|
||||||
|
|
||||||
|
holder.gitcoin = gitcoin
|
||||||
|
|
||||||
|
// Bounties.network bounties
|
||||||
|
request('https://new.api.bounties.network/bounty/?search=ocean%20protocol&bountyStage=1', (error, response, body) => {
|
||||||
|
if (error) return
|
||||||
|
|
||||||
|
const bountiesNetwork = JSON.parse(body)
|
||||||
|
holder.bountiesNetwork = bountiesNetwork.results
|
||||||
|
|
||||||
|
// Send final response
|
||||||
|
res.send(holder)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = webtask.fromExpress(app)
|
Loading…
Reference in New Issue
Block a user