* Add self billing feature flag * Add two core tables for billing * Remove useless imports * Remove graphql decorators * Rename subscriptionProduct table * WIP: Add stripe config * Add controller to get product prices * Add billing service * Remove unecessary package * Simplify stripe service * Code review returns * Use nestjs param * Rename subscription to basePlan * Rename env variable * Add checkout endpoint * Remove resolver * Merge controllers * Fix security issue * Handle missing url error * Add workspaceId in checkout metadata * Add BILLING_STRIPE_WEBHOOK_SECRET env variable * WIP: add webhook endpoint * Fix body parser * Create Billing Subscription on payment success * Set subscriptionStatus active on webhook * Add useful log --------- Co-authored-by: Charles Bochet <charles@twenty.com>
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
|
|
import { graphqlUploadExpress } from 'graphql-upload';
|
|
import bytes from 'bytes';
|
|
import { useContainer } from 'class-validator';
|
|
import '@sentry/tracing';
|
|
|
|
import { AppModule } from './app.module';
|
|
|
|
import { settings } from './constants/settings';
|
|
import { LoggerService } from './integrations/logger/logger.service';
|
|
import { EnvironmentService } from './integrations/environment/environment.service';
|
|
|
|
const bootstrap = async () => {
|
|
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
|
cors: true,
|
|
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
|
|
rawBody: true,
|
|
});
|
|
const logger = app.get(LoggerService);
|
|
|
|
// Apply class-validator container so that we can use injection in validators
|
|
useContainer(app.select(AppModule), { fallbackOnErrors: true });
|
|
|
|
// Use our logger
|
|
app.useLogger(logger);
|
|
|
|
// Apply validation pipes globally
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
transform: true,
|
|
}),
|
|
);
|
|
app.useBodyParser('json', { limit: settings.storage.maxFileSize });
|
|
app.useBodyParser('urlencoded', {
|
|
limit: settings.storage.maxFileSize,
|
|
extended: true,
|
|
});
|
|
|
|
// Graphql file upload
|
|
app.use(
|
|
graphqlUploadExpress({
|
|
maxFieldSize: bytes(settings.storage.maxFileSize),
|
|
maxFiles: 10,
|
|
}),
|
|
);
|
|
|
|
await app.listen(app.get(EnvironmentService).getPort());
|
|
};
|
|
|
|
bootstrap();
|