TypeScript Types
Overview
RNode Server provides comprehensive TypeScript support with full type definitions for all APIs and interfaces.
Core Types
- Interfaces - Complete interface definitions and examples
Type Categories
Request & Response
Request- HTTP request object with all properties and methodsResponse- HTTP response object with all methodsRequestBody- Union type for different body typesBinaryData- Binary data interface
Configuration
AppOptions- Application configuration optionsSSLOptions- SSL/TLS configurationStaticOptions- Static file serving optionsUploadOptions- File upload configurationDownloadOptions- File download configuration
HTTP Utilities
HttpRequestOptions- Single HTTP request optionsHttpBatchRequest- Batch request configurationHttpResponse- HTTP response interfaceHttpBatchResponse- Batch response interface
Middleware & Routing
MiddlewareFunction- Middleware function typeNextFunction- Next function typeRouteHandler- Route handler typeRouteParams- Route parameters interfaceQueryParams- Query string parameters
File Operations
FileInfo- File information interfaceParsedCookie- Cookie parsing interfaceCookieOptions- Cookie configuration options
Usage Examples
Basic Typing
typescript
import { createApp, Request, Response } from 'rnode-server';
const app = createApp();
app.get('/api/users/{id}', (req: Request, res: Response) => {
const { id } = req.params;
res.json({ userId: id });
});Custom Interfaces
typescript
interface UserRequest extends Request {
body: {
name: string;
email: string;
};
}
app.post('/api/users', (req: UserRequest, res: Response) => {
const { name, email } = req.body;
// TypeScript provides full type safety
});Next Steps
- API Reference - Complete API documentation
- Examples - Practical usage examples
- Architecture - System design overview