Skip to content

The Node Express Vercel repository is a demonstration of deploying a Node.js Express.js project to Vercel, a cloud platform known for its simplicity and scalability. The repository includes a guide and configuration files for deploying an Express.js application to Vercel, showcasing how to leverage Vercel's features for hosting Node.js application

Notifications You must be signed in to change notification settings

Soumyadeep765/Vercel_Test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vercel Demo node js Project

This project demonstrates how to set up two different API routes on Vercel: one using Express and another using module exports.

Features

  • Express API: A route that handles requests using an Express server.
  • Module Exports API: A route that uses module exports for handling requests without a server.

Project Structure

src/
├── express.js      # Express API
├── module.js       # Module exports API
├── index.js        # Main entry point for routing
package.json        # Dependencies and scripts
vercel.json         # Vercel configuration for routing
readme.md           # Project description

API Routes

  1. Module Exports Route: /api/module

    • Description: This route is handled by the module.js file. It uses a lightweight, serverless function to respond to requests.
    • Response: Returns a simple JSON message like {"message": "Hello from Module Export on Vercel!"}.
  2. Express Route: /api/express

    • Description: This route is handled by the express.js file. It uses an Express server to manage requests and responses.
    • Response: Returns a JSON message like {"message": "Hello from Express on Vercel!"}.

Examples

Vercel Configuration

The vercel.json file defines the routing for the two APIs:

{
  "version": 2,
  "builds": [
    {
      "src": "src/*.js",
      "use": "@vercel/node"
    }
  ],
  "routes": [
    {
      "src": "/api/module",
      "dest": "/src/module.js"
    },
    {
      "src": "/api/express",
      "dest": "/src/express.js"
    },
    {
      "src": "/",
      "dest": "/src/main.js"
    }
  ]
}

Key Updates:

  • API Routes section clearly defines the two routes (/api/module and /api/express).

  • Each route is described in detail, including the file that handles the route and the type of response users can expect.

  • and / for main route that is default url route

This simple structure should make it easy to understand what each route does.

About

The Node Express Vercel repository is a demonstration of deploying a Node.js Express.js project to Vercel, a cloud platform known for its simplicity and scalability. The repository includes a guide and configuration files for deploying an Express.js application to Vercel, showcasing how to leverage Vercel's features for hosting Node.js application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published