|
| 1 | +--- |
| 2 | +title: Server & Deployment |
| 3 | +description: Learn how to configure, integrate, and deploy ObjectQL applications |
| 4 | +--- |
| 5 | + |
| 6 | +ObjectQL is designed to be **framework-agnostic** and can be integrated with any Node.js server or deployed to various environments. This section covers server configuration, integration patterns, and deployment strategies. |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +The server layer in ObjectQL provides: |
| 11 | + |
| 12 | +- **Multiple Framework Support**: Express, Next.js, Fastify, and more |
| 13 | +- **API Styles**: REST, JSON-RPC, GraphQL, and WebSocket support |
| 14 | +- **Configuration Management**: Environment-based configuration |
| 15 | +- **Plugin System**: Extend functionality with plugins |
| 16 | +- **Microservices**: Federation and distributed architectures |
| 17 | + |
| 18 | +## Key Topics |
| 19 | + |
| 20 | +### [Configuration](/docs/server/configuration) |
| 21 | + |
| 22 | +Configure your ObjectQL application: |
| 23 | +- Database connections |
| 24 | +- Environment variables |
| 25 | +- Metadata loading |
| 26 | +- Driver configuration |
| 27 | +- Runtime options |
| 28 | + |
| 29 | +### [Server Integration](/docs/server/integration) |
| 30 | + |
| 31 | +Integrate ObjectQL with web frameworks: |
| 32 | +- Express.js setup |
| 33 | +- Next.js integration |
| 34 | +- Fastify adapter |
| 35 | +- Custom server setup |
| 36 | +- HTTP API exposure |
| 37 | + |
| 38 | +### [Microservices & Federation](/docs/server/microservices) |
| 39 | + |
| 40 | +Build distributed systems with ObjectQL: |
| 41 | +- Service federation |
| 42 | +- Remote data sources |
| 43 | +- Cross-service queries |
| 44 | +- Load balancing |
| 45 | +- Service discovery |
| 46 | + |
| 47 | +### [Plugin System](/docs/server/plugins) |
| 48 | + |
| 49 | +Extend ObjectQL with plugins: |
| 50 | +- Creating custom plugins |
| 51 | +- Plugin lifecycle |
| 52 | +- Bundling behavior |
| 53 | +- Sharing plugins |
| 54 | +- Official plugins |
| 55 | + |
| 56 | +## Quick Setup |
| 57 | + |
| 58 | +### Express Integration |
| 59 | + |
| 60 | +```typescript |
| 61 | +import express from 'express'; |
| 62 | +import { ObjectQL } from '@objectql/core'; |
| 63 | +import { SqlDriver } from '@objectql/driver-sql'; |
| 64 | +import { createNodeHandler } from '@objectql/server'; |
| 65 | + |
| 66 | +const app = express(); |
| 67 | + |
| 68 | +// Initialize ObjectQL |
| 69 | +const objectql = new ObjectQL({ |
| 70 | + datasources: { |
| 71 | + default: new SqlDriver({ |
| 72 | + client: 'postgresql', |
| 73 | + connection: process.env.DATABASE_URL |
| 74 | + }) |
| 75 | + } |
| 76 | +}); |
| 77 | + |
| 78 | +await objectql.init(); |
| 79 | + |
| 80 | +// Mount ObjectQL handler |
| 81 | +app.use('/api/objectql', createNodeHandler(objectql)); |
| 82 | + |
| 83 | +// Start server |
| 84 | +app.listen(3000, () => { |
| 85 | + console.log('Server running on http://localhost:3000'); |
| 86 | +}); |
| 87 | +``` |
| 88 | + |
| 89 | +### Configuration File |
| 90 | + |
| 91 | +```typescript |
| 92 | +// objectql.config.ts |
| 93 | +import { defineConfig } from '@objectql/core'; |
| 94 | + |
| 95 | +export default defineConfig({ |
| 96 | + datasources: { |
| 97 | + default: { |
| 98 | + driver: 'sql', |
| 99 | + client: 'postgresql', |
| 100 | + connection: { |
| 101 | + host: process.env.DB_HOST, |
| 102 | + database: process.env.DB_NAME, |
| 103 | + user: process.env.DB_USER, |
| 104 | + password: process.env.DB_PASSWORD |
| 105 | + } |
| 106 | + } |
| 107 | + }, |
| 108 | + modules: [ |
| 109 | + 'src/objects', |
| 110 | + '@objectql/module-auth' |
| 111 | + ] |
| 112 | +}); |
| 113 | +``` |
| 114 | + |
| 115 | +## Deployment Patterns |
| 116 | + |
| 117 | +### Traditional Server |
| 118 | + |
| 119 | +Deploy to VPS, EC2, or dedicated servers: |
| 120 | +- Process management with PM2 |
| 121 | +- Nginx reverse proxy |
| 122 | +- Environment configuration |
| 123 | +- Database migrations |
| 124 | + |
| 125 | +### Serverless |
| 126 | + |
| 127 | +Deploy to serverless platforms: |
| 128 | +- AWS Lambda |
| 129 | +- Vercel Functions |
| 130 | +- Cloudflare Workers |
| 131 | +- Database connection pooling |
| 132 | + |
| 133 | +### Containers |
| 134 | + |
| 135 | +Deploy with Docker: |
| 136 | +- Dockerfile configuration |
| 137 | +- Docker Compose setup |
| 138 | +- Kubernetes deployment |
| 139 | +- Health checks and monitoring |
| 140 | + |
| 141 | +## Next Steps |
| 142 | + |
| 143 | +- Configure your application with **[Configuration](/docs/server/configuration)** |
| 144 | +- Integrate with your framework using **[Server Integration](/docs/server/integration)** |
| 145 | +- Scale with **[Microservices](/docs/server/microservices)** |
| 146 | +- Extend with the **[Plugin System](/docs/server/plugins)** |
| 147 | +- Review **[API Reference](/docs/reference/api)** for complete documentation |
0 commit comments