-
-
Save rayriffy/5ba8d32a2cc8fe7de6793a5c373e1487 to your computer and use it in GitHub Desktop.
This file contains 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
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