Examples
Complete, runnable examples showing how to use omni-rest in real applications.
Express.js Example
A complete Express.js server with authentication, guards, and OpenAPI documentation.
- schema.prisma
- seed.ts
- auth.ts
- guards.ts
- server.ts
- package.json
- tsconfig.json
{
"name": "express-example",
"version": "1.0.0",
"scripts": {
"dev": "tsx watch src/server.ts",
"build": "tsc",
"start": "node dist/server.js"
},
"dependencies": {
"express": "^4.18.0",
"omni-rest": "^1.0.0",
"@prisma/client": "^5.0.0",
"cors": "^2.8.5",
"helmet": "^7.0.0",
"jsonwebtoken": "^9.0.0",
"bcryptjs": "^2.4.3",
"swagger-ui-express": "^5.0.0"
},
"devDependencies": {
"@types/express": "^4.17.0",
"@types/cors": "^2.8.0",
"@types/jsonwebtoken": "^9.0.0",
"@types/bcryptjs": "^2.4.0",
"tsx": "^4.0.0",
"typescript": "^5.0.0"
}
}Next.js App Router Example
A complete Next.js application with React components and API routes.
- layout.tsx
- page.tsx
- ProductList.tsx
- ProductForm.tsx
- package.json
// app/api/[...prismaRest]/route.ts
import { PrismaClient } from '@prisma/client';
import { nextjsAdapter } from 'omni-rest/nextjs';
import { createGuards } from '@/lib/guards';
const prisma = new PrismaClient();
const guards = createGuards();
export const { GET, POST, PUT, PATCH, DELETE } = nextjsAdapter(prisma, {
allow: ['product', 'category'],
guards,
defaultLimit: 12,
});