Skip to content

Instantly share code, notes, and snippets.

@99darwin
Last active June 26, 2019 15:26
Show Gist options
  • Save 99darwin/a318fc471631b656be2e321c7bc79485 to your computer and use it in GitHub Desktop.
Save 99darwin/a318fc471631b656be2e321c7bc79485 to your computer and use it in GitHub Desktop.
Simple server for node-rpc-tutorial
const express = require('express')
const bodyParser = require('body-parser')
const path = require('path')
const app = express()
const port = process.env.PORT || 1337
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.text())
app.use(bodyParser.json({ type: "application/vnd.api+json" }))
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*")
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
next()
})
app.use(express.static(path.join(__dirname, 'src')))
require('./src/api')(app)
app.listen(port, () => {
console.log(`App listening on port: ${port}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment