Files
koodiklinikka.fi-api/index.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

35 lines
848 B
JavaScript

'use strict';
var express = require('express');
var morgan = require('morgan');
var cors = require('cors');
var bodyParser = require('body-parser');
var app = express();
if(app.get('env') != 'development') {
require('newrelic');
}
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(cors({credentials: true, origin: true}));
morgan.token('body', function(req) {
return JSON.stringify(req.body);
});
app.use(morgan(':method :url :status :response-time ms - :res[content-length] :body'));
require('./routes/invite')(app);
require('./routes/members')(app);
require('./routes/feeds')(app);
require('./routes/membership')(app);
app.use(function(err, req, res, next) {
/*jshint unused:false*/
console.error(err);
res.status(500).send('Internal server error');
});
app.listen(process.env.PORT || 9000);