Skip to content

Instantly share code, notes, and snippets.

@samcorcos
Last active May 31, 2016 08:59
Show Gist options
  • Save samcorcos/ca4e923530d05c8fe54d276f74d2a212 to your computer and use it in GitHub Desktop.
Save samcorcos/ca4e923530d05c8fe54d276f74d2a212 to your computer and use it in GitHub Desktop.
Initial index.js file for payment processor
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