Last active
May 31, 2016 08:59
-
-
Save samcorcos/ca4e923530d05c8fe54d276f74d2a212 to your computer and use it in GitHub Desktop.
Initial index.js file for payment processor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require("express") | |
var app = express() | |
var cors = require("cors") | |
var path = require('path') | |
var bodyParser = require('body-parser') | |
var parseURLencoded = bodyParser.urlencoded({ extended: true }) | |
app.use(cors()) | |
app.get('/', function (req, res) { | |
res.sendFile(path.join(__dirname + '/public/index.html')) | |
}) | |
app.post('/api/purchase', parseURLencoded, function(req, res) { | |
var auth = req.headers['authorization'] | |
if (auth !== "false") { | |
var token = req.body.token | |
res.status(201).send(token) | |
} else { | |
res.status(401).send("Unauthorized.") | |
} | |
}) | |
app.listen(3030, function () { | |
console.log('Example app listening on port 3030!') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment