mirror of
https://github.com/bigchaindb/meetups.git
synced 2024-11-21 17:26:56 +01:00
💫 initial commit
This commit is contained in:
commit
52b72f1372
13
.editorconfig
Normal file
13
.editorconfig
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.json]
|
||||
indent_size = 2
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
node_modules
|
||||
npm-debug.log
|
||||
yarn.lock
|
||||
package-lock.json
|
5
.travis.yml
Normal file
5
.travis.yml
Normal file
@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js: node
|
||||
|
||||
notifications:
|
||||
email: false
|
59
index.js
Executable file
59
index.js
Executable file
@ -0,0 +1,59 @@
|
||||
const fetch = require('node-fetch')
|
||||
const ms = require('ms')
|
||||
const chalk = require('chalk')
|
||||
|
||||
let data = []
|
||||
const url = 'https://api.meetup.com/BigchainDB-IPDB-Meetup/events'
|
||||
|
||||
const log = text => console.log(text)
|
||||
const logError = text => console.log(chalk.bold.red(text))
|
||||
|
||||
// Response handling for all fetch calls
|
||||
const handleResponse = res => {
|
||||
if (res.status !== 200) {
|
||||
return logError('Non-200 response code from Meetup: ' + res.status)
|
||||
}
|
||||
return res.json()
|
||||
}
|
||||
|
||||
//
|
||||
// Fetch all upcoming meetups
|
||||
//
|
||||
const fetchMeetups = () => {
|
||||
const start = Date.now()
|
||||
|
||||
fetch(url)
|
||||
.then(res => {
|
||||
return handleResponse(res)
|
||||
})
|
||||
.then(data_ => {
|
||||
if (!data_) {
|
||||
return
|
||||
}
|
||||
|
||||
data = data_
|
||||
|
||||
log(`Re-built meetups cache. ` +
|
||||
`Total: ${data_.length} public meetups. ` +
|
||||
`Elapsed: ${(new Date() - start)}ms`)
|
||||
})
|
||||
.catch(err => {
|
||||
logError('Error parsing response from Meetup: ' + err.stack)
|
||||
})
|
||||
}
|
||||
|
||||
//
|
||||
// Let's roll, and roll again every X ms
|
||||
//
|
||||
fetchMeetups()
|
||||
setInterval(fetchMeetups, ms('15m'))
|
||||
|
||||
//
|
||||
// Create the response
|
||||
//
|
||||
module.exports = async (req, res) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*')
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET')
|
||||
|
||||
return data
|
||||
}
|
21
license.md
Executable file
21
license.md
Executable file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 BigchainDB GmbH
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
BIN
media/repo-banner.sketch
Normal file
BIN
media/repo-banner.sketch
Normal file
Binary file not shown.
BIN
media/repo-banner@2x.png
Normal file
BIN
media/repo-banner@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
34
package.json
Normal file
34
package.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "bigchaindb-meetups",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"start": "micro",
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true,
|
||||
"space": 4,
|
||||
"semicolon": false,
|
||||
"rules": {
|
||||
"camelcase": 0
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "1.1.3",
|
||||
"micro": "7.3.3",
|
||||
"ms": "2.0.0",
|
||||
"node-fetch": "1.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.19.1",
|
||||
"request": "^2.81.0",
|
||||
"request-promise": "^4.2.1",
|
||||
"test-listen": "^1.0.2",
|
||||
"xo": "^0.18.2"
|
||||
},
|
||||
"alias": "bigchaindb-meetups.now.sh",
|
||||
"env": {
|
||||
"NODE_ENV": "production"
|
||||
}
|
||||
}
|
101
readme.md
Normal file
101
readme.md
Normal file
@ -0,0 +1,101 @@
|
||||
# [![meetups](media/repo-banner@2x.png)](https://www.bigchaindb.com)
|
||||
|
||||
> Microservice to cache and expose [our upcoming Meetups](https://www.meetup.com/BigchainDB-IPDB-Meetup/) for use throughout [www.bigchaindb.com](https://www.bigchaindb.com).
|
||||
|
||||
[![Build Status](https://travis-ci.org/bigchaindb/meetups.svg?branch=master)](https://travis-ci.org/bigchaindb/meetups)
|
||||
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
|
||||
[![Greenkeeper badge](https://badges.greenkeeper.io/bigchaindb/meetups.svg)](https://greenkeeper.io/)
|
||||
<img src="http://forthebadge.com/images/badges/powered-by-electricity.svg" height="20"/>
|
||||
<img src="http://forthebadge.com/images/badges/as-seen-on-tv.svg" height="20"/>
|
||||
<img src="http://forthebadge.com/images/badges/uses-badges.svg" height="20"/>
|
||||
|
||||
## API
|
||||
|
||||
Endpoint: [`https://bigchaindb-meetups.now.sh`](https://bigchaindb-meetups.now.sh)
|
||||
|
||||
### GET /
|
||||
|
||||
**200**: Returns all upcoming meetups, e.g.:
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
created: 1480492250000,
|
||||
id: "235925067",
|
||||
name: "Privacy on the Blockchain",
|
||||
rsvp_limit: 55,
|
||||
status: "upcoming",
|
||||
time: 1496854800000,
|
||||
updated: 1495634541000,
|
||||
utc_offset: 7200000,
|
||||
waitlist_count: 9,
|
||||
yes_rsvp_count: 61,
|
||||
venue: {
|
||||
id: 24947394,
|
||||
name: "BlueYard",
|
||||
lat: 52.49262237548828,
|
||||
lon: 13.413067817687988,
|
||||
repinned: false,
|
||||
address_1: "Grimmstraße 13, 10967 ",
|
||||
city: "Berlin",
|
||||
country: "de",
|
||||
localized_country_name: "Germany"
|
||||
},
|
||||
group: {
|
||||
created: 1480330155000,
|
||||
name: "BigchainDB & IPDB Meetup",
|
||||
id: 21301439,
|
||||
join_mode: "open",
|
||||
lat: 52.52000045776367,
|
||||
lon: 13.380000114440918,
|
||||
urlname: "BigchainDB-IPDB-Meetup",
|
||||
who: "Members"
|
||||
},
|
||||
link: "https://www.meetup.com/BigchainDB-IPDB-Meetup/events/235925067/",
|
||||
description: ""
|
||||
visibility: "public"
|
||||
},
|
||||
...
|
||||
]
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
Install dependencies:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
And run the server:
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
Run the tests:
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
Deploy to [now](https://zeit.co/now), make sure to switch to BigchainDB org before deploying:
|
||||
|
||||
```bash
|
||||
# first run
|
||||
now login
|
||||
now switch
|
||||
|
||||
# deploy
|
||||
now
|
||||
# switch alias to new deployment, e.g.
|
||||
now alias bigchaindb-meetups-wxkyissxos bigchaindb-meetups
|
||||
```
|
||||
|
||||
## Authors
|
||||
|
||||
- Matthias Kretschmann ([@kremalicious](https://github.com/kremalicious)) - [BigchainDB](https://www.bigchaindb.com)
|
17
test/index.js
Normal file
17
test/index.js
Normal file
@ -0,0 +1,17 @@
|
||||
import micro from 'micro'
|
||||
import test from 'ava'
|
||||
import listen from 'test-listen'
|
||||
import request from 'request-promise'
|
||||
|
||||
test('it works', async t => {
|
||||
const service = micro(async (req, res) => {
|
||||
micro.send(res, 200, {
|
||||
test: 'woot'
|
||||
})
|
||||
})
|
||||
|
||||
const url = await listen(service)
|
||||
const body = await request(url)
|
||||
|
||||
t.deepEqual(JSON.parse(body).test, 'woot')
|
||||
})
|
Loading…
Reference in New Issue
Block a user