Files
koodiklinikka.fi-api/routes/members.js
Cihan Bebek f783a27045 Membership registration & payment API (#4)
* remove newrelic from use in devenv

* add endpoint for membership payments

* fix some wierd spaces

* minor code styling and logging stuff

* replace non-breaking spaces with normal ones

* remove duplicate function

* minor code styling

* add functionality for writing new member to google sheets

* add config example

* update example config, start using config in google credentials

* remove var creds from google sheets auth

* rename config.example to config.template and fix readme

* add async and google-spreadsheet packages

* rename workingWithRows to addRow

* return missing header from readme

* minor code styling

* flatten google config structure, add address fields

* add request validation to membership endpoint

* fix config field names

* more error handling, fix indentation
2017-07-08 20:23:16 +01:00

38 lines
806 B
JavaScript

'use strict';
var github = require('../services/github');
var cache = require('apicache').middleware;
module.exports = function (app) {
/*
* GET /members
* Endpoint for fetching GitHub org public members
*/
app.get('/members', cache('3 hours'), function(req, res, next) {
github.getMembers().then(function(data) {
res.status(200).send(data);
}, function(error) {
next(error);
});
});
/*
* Post /members
* Endpoint for getting an invite to GitHub organization
*/
app.post('/members', function(req, res, next) {
if(!req.body.username) {
return res.status(400).send('invalid_username');
}
github.inviteToOrg({
login: req.body.username
})
.then(function() {
res.status(200).end();
})
.catch(next);
});
};