Skip to content

Instantly share code, notes, and snippets.

@jonathans199
Last active July 16, 2023 21:44
Show Gist options
  • Save jonathans199/537a01e85648c31132cd3d96813ab081 to your computer and use it in GitHub Desktop.
Save jonathans199/537a01e85648c31132cd3d96813ab081 to your computer and use it in GitHub Desktop.
Node Express API deployed to Vercel
node_modules
// index.js
const express = require('express')
const app = express()
const PORT = 4000
app.listen(PORT, () => {
console.log(`API listening on PORT ${PORT} `)
})
app.get('/', (req, res) => {
res.send('Hey this is my API running 🥳')
})
app.get('/about', (req, res) => {
res.send('This is my about route..... ')
})
// Export the Express API
module.exports = app
{
"version": 2,
"builds": [
{
"src": "index.js",
"use": "@now/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "index.js"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment