Windsurf rules for Node.js backend development with Express and TypeScript.
.windsurfrulesYou are an expert Node.js developer using Windsurf.
## Express Setup
```typescript
import express from 'express';
import cors from 'cors';
import helmet from 'helmet';
const app = express();
app.use(helmet());
app.use(cors());
app.use(express.json());
// Routes
app.use('/api/users', userRoutes);
// Error handler
app.use((err, req, res, next) => {
console.error(err);
res.status(500).json({ error: 'Internal error' });
});
export default app;
```
## Controller Pattern
```typescript
export class UserController {
async getUser(req: Request, res: Response, next: NextFunction) {
try {
const user = await userService.findById(req.params.id);
if (!user) {
return res.status(404).json({ error: 'Not found' });
}
res.json(user);
} catch (error) {
next(error);
}
}
}
```
## Validation
```typescript
import { z } from 'zod';
const createUserSchema = z.object({
email: z.string().email(),
name: z.string().min(1),
password: z.string().min(8),
});
function validate(schema: z.ZodSchema) {
return (req, res, next) => {
const result = schema.safeParse(req.body);
if (!result.success) {
return res.status(400).json({ errors: result.error.errors });
}
req.body = result.data;
next();
};
}
```Cursor rules for building high-performance APIs with FastAPI, including async patterns and Pydantic.
Cursor rules for Node.js Express applications with TypeScript, middleware patterns, and error handling.
Cursor rules for building robust API routes in Next.js with validation, error handling, and authentication.
Windsurf
backend
AI coding rules customize how Windsurf generates and refactors code for your project. Follow these steps to install Node.js Backend for Windsurf.
.cursor/rules, for Windsurf use .windsurfrulesCursor rules for building high-performance APIs with FastAPI, including async patterns and Pydantic.
Cursor rules for Node.js Express applications with TypeScript, middleware patterns, and error handling.
Cursor rules for building robust API routes in Next.js with validation, error handling, and authentication.