A serverless fraud detection API built with TypeScript and deployed on Vercel. This service validates IP addresses and provides fraud detection capabilities.
├── api/
│ └── index.ts # Main Vercel serverless function
├── col/ # Bruno API test collection
│ ├── bruno.json # Bruno collection configuration
│ ├── success.bru # Test case for successful requests
│ └── invalid-payload.bru # Test case for invalid payloads
├── package.json # Dependencies and package manager config
├── tsconfig.json # TypeScript configuration
├── pnpm-lock.yaml # pnpm lockfile
└── README.md # This file
This project uses pnpm as the package manager. Use corepack to install it (do not use npm install
).
- Node.js (configured for Node 22 via tsconfig)
- Corepack (comes with Node.js 16+)
-
Enable corepack to use pnpm:
corepack enable
-
Install dependencies:
pnpm install
Note: This project depends on private packages from
@sandbox-as-a-service/types
. You'll need proper NPM_TOKEN access to install all dependencies.
- URL:
/api
- Method:
POST
- Content-Type:
application/json
{
"ip": "192.168.1.1"
}
Success (200):
{
"message": "Valid IP received",
"ip": "192.168.1.1"
}
Validation Error (400):
{
"error": "Invalid payload",
"details": [/* Zod validation errors */]
}
Method Not Allowed (405):
{
"error": "Method Not Allowed"
}
Unsupported Media Type (415):
{
"error": "Unsupported Media Type"
}
This project includes a Bruno API test collection in the col/
directory.
- success.bru: Tests successful IP validation
- invalid-payload.bru: Tests handling of invalid payloads
Use Bruno CLI or Bruno GUI to execute the test collection:
-
Install Bruno CLI:
pnpm add -g @usebruno/cli
-
Run tests:
bru run col/
For local development with Vercel:
# Install Vercel CLI
pnpm add -g vercel
# Run locally
vercel dev
The project uses TypeScript with strict configuration extending @tsconfig/node22
. Type checking:
pnpm tsc --noEmit
- TypeScript - Type-safe JavaScript
- Zod - Schema validation
- Vercel - Serverless deployment platform
- Bruno - API testing
- pnpm - Fast, disk space efficient package manager
This project is configured for deployment on Vercel. The api/index.ts
file serves as the main serverless function endpoint.