Skip to content

Instantly share code, notes, and snippets.

@rayriffy
Created February 21, 2019 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayriffy/5ba8d32a2cc8fe7de6793a5c373e1487 to your computer and use it in GitHub Desktop.
Save rayriffy/5ba8d32a2cc8fe7de6793a5c373e1487 to your computer and use it in GitHub Desktop.
import bodyParser from 'body-parser'
import chalk from 'chalk'
import express from 'express'
import cors from 'cors'
const {PORT = 3000} = process.env
const server = express()
server.use(bodyParser.json())
server.use(bodyParser.urlencoded({extended: true}))
server.use(cors())
server.get('/', (req, res) => {
res.status(200).send({
message: 'OK',
})
})
server.post('/', (req, res) => {
res.status(200).send({
message: 'OK with POST',
})
})
server.all('*', (req, res) => {
res.status(404).send({
message: 'not found',
})
})
server.listen(PORT, () => {
console.log(`${chalk.black.bgGreen(' INFO ')} app is running on port ${PORT}`)
})
export default server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment