Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
713 changes: 693 additions & 20 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
31 changes: 31 additions & 0 deletions packages/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Express.js on Vercel

Basic Express.js + Vercel example that serves html content, JSON data and simulates an api route.

## How to Use

You can choose from one of the following two methods to use this repository:

### One-Click Deploy

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=vercel-examples):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/examples/tree/main/solutions/express&project-name=express&repository-name=express)

### Clone and Deploy

```bash
git clone https://github.com/vercel/examples/tree/main/solutions/express
```

Install the Vercel CLI:

```bash
npm i -g vercel
```

Then run the app at the root of the repository:

```bash
vercel dev
```
26 changes: 26 additions & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@groundup/api",
"version": "1.0.0",
"description": "Express API server for GroundUp monorepo",
"type": "module",
"keywords": [
"express",
"api",
"vercel"
],
"author": "",
"license": "ISC",
"dependencies": {
"@types/express": "^5.0.0",
"express": "^4.18.2"
},
"scripts": {
"dev": "vercel dev",
"build": "tsc",
"start": "node dist/index.js",
"type-check": "tsc --noEmit"
},
"devDependencies": {
"typescript": "^5.9.3"
}
}
Binary file added packages/api/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions packages/api/public/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
body {
font-family: system-ui, sans-serif;
margin: 2rem;
line-height: 1.5;
}
nav a {
margin-right: 1rem;
}

48 changes: 48 additions & 0 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import express from "express";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const app = express();

// Home route - HTML
app.get("/", (req, res) => {
res.type("html").send(`
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Express on Vercel</title>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/api-data">API Data</a>
<a href="/healthz">Health</a>
</nav>
<h1>Welcome to Express on Vercel 🚀</h1>
<p>This is a minimal example without a database or forms.</p>
<img src="/logo.png" alt="Logo" width="120" />
</body>
</html>
`);
});

// Example API endpoint - JSON
app.get("/api-data", (req, res) => {
res.json({
message: "Here is some sample API data",
items: ["apple", "banana", "cherry"],
});
});

// Health check
app.get("/healthz", (req, res) => {
res.status(200).json({ status: "ok", timestamp: new Date().toISOString() });
});

export default app;
11 changes: 11 additions & 0 deletions packages/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"rootDir": ".",
"esModuleInterop": true,
"skipLibCheck": true
}
}