Implement backend API and database services in Docker setup

- Added a new `api` service for the NestJS backend, including health checks and dependencies on PostgreSQL, Redis, and MinIO.
- Introduced PostgreSQL and Redis services with health checks and configurations for data persistence.
- Added MinIO for S3-compatible object storage and a one-shot service to initialize required buckets.
- Updated the Nginx configuration to proxy requests to the new backend API and MinIO storage.
- Enhanced the Dockerfile to support the new API environment variables and configurations.
- Updated the `package.json` and `package-lock.json` to include new dependencies for QR code generation and other utilities.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Dorian
2026-02-12 20:14:39 +00:00
parent f19fd6feef
commit cdd24a5def
478 changed files with 55355 additions and 529 deletions

82
backend/src/main.ts Normal file
View File

@@ -0,0 +1,82 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { ValidationPipe } from '@nestjs/common';
import { useContainer } from 'class-validator';
// Sentry instrumentation removed (see instrument.ts)
import * as express from 'express';
import {
ExpressAdapter,
NestExpressApplication,
} from '@nestjs/platform-express';
import { RawBodyRequest } from './types/raw-body-request';
async function bootstrap() {
const server = express();
const captureRawBody = (
request: RawBodyRequest,
_response: express.Response,
buffer: Buffer,
) => {
request.rawBody = buffer.toString('utf8');
};
server.use(
express.json({
limit: '10mb',
verify: captureRawBody,
}),
);
server.use(
express.urlencoded({
extended: true,
limit: '10mb',
verify: captureRawBody,
}),
);
const app = await NestFactory.create<NestExpressApplication>(
AppModule,
new ExpressAdapter(server),
{
bodyParser: false,
},
);
useContainer(app.select(AppModule), { fallbackOnErrors: true });
if (process.env.ENVIRONMENT === 'development') {
const swagConfig = new DocumentBuilder()
.setTitle('IndeeHub API')
.setDescription('This is the API for the IndeeHub application')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, swagConfig);
SwaggerModule.setup('api', app, document);
}
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
if (process.env.ENVIRONMENT === 'production') {
app.enableCors({
origin: [
'https://indeehub.studio',
'https://www.indeehub.studio',
'https://app.indeehub.studio',
'https://bff.indeehub.studio',
'https://indeehub.retool.com',
'https://www.indeehub.retool.com',
],
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
credentials: true,
});
} else app.enableCors();
await app.listen(process.env.PORT || 4000);
}
// eslint-disable-next-line unicorn/prefer-top-level-await
bootstrap().catch(console.error);