Skip to content

Commit

Permalink
Merge branch 'dependabot/npm_and_yarn/esbuild-0.25.0' of github.com:e…
Browse files Browse the repository at this point in the history
…ver-co/ever-gauzy into dependabot/npm_and_yarn/esbuild-0.25.0
  • Loading branch information
rahul-rocket committed Feb 12, 2025
2 parents 3f1b7a3 + 7b0ba2e commit 87bed10
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 25 deletions.
7 changes: 5 additions & 2 deletions apps/desktop-api/src/app/database.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const dbPath = process.env.GAUZY_USER_PATH ? `${process.env.GAUZY_USER_PATH}/gau
logger: 'file', //Removes console logging, instead logs all queries in a file ormlogs.log
synchronize: true,
entities: coreEntities
})
}),
inject: []
}),
// MikroORM DB Config (SQLite3)
MikroOrmModule.forRootAsync({
Expand All @@ -30,7 +31,9 @@ const dbPath = process.env.GAUZY_USER_PATH ? `${process.env.GAUZY_USER_PATH}/gau
entities: coreEntities,
namingStrategy: EntityCaseNamingStrategy,
debug: ['query'] // by default set to false only
})
}),
driver: BetterSqliteDriver,
inject: []
})
]
})
Expand Down
6 changes: 3 additions & 3 deletions packages/config/src/lib/database.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as path from 'path';
import * as chalk from 'chalk';
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { MikroOrmModuleOptions } from '@mikro-orm/nestjs';
import { EntityCaseNamingStrategy } from '@mikro-orm/core';
Expand All @@ -8,9 +6,11 @@ import { BetterSqliteDriver, Options as MikroOrmBetterSqliteOptions } from '@mik
import { PostgreSqlDriver, Options as MikroOrmPostgreSqlOptions } from '@mikro-orm/postgresql';
import { Options as MikroOrmMySqlOptions, MySqlDriver } from '@mikro-orm/mysql';
import { DataSourceOptions } from 'typeorm';
import { KnexModuleOptions } from 'nest-knexjs';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions';
import { KnexModuleOptions } from 'nest-knexjs';
import * as path from 'path';
import * as chalk from 'chalk';
import { DatabaseTypeEnum, getLoggingMikroOptions, getLoggingOptions, getTlsOptions } from './database-helpers';

/**
Expand Down
8 changes: 3 additions & 5 deletions packages/core/src/lib/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ startTracing(); // Start tracing if OTEL is enabled.
import { ConflictException, INestApplication, Type } from '@nestjs/common';
import { NestFactory, Reflector } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { EventSubscriber } from '@mikro-orm/core';
import { useContainer } from 'class-validator';
import * as helmet from 'helmet';
Expand All @@ -51,6 +50,7 @@ import { SharedModule } from '../shared/shared.module';
import { AppService } from '../app/app.service';
import { AppModule } from '../app/app.module';
import { configureRedisSession } from './redis-store';
import { setupSwagger } from './swagger';

/**
* Bootstrap the NestJS application, configuring various settings and initializing the server.
Expand Down Expand Up @@ -161,10 +161,8 @@ export async function bootstrap(pluginConfig?: Partial<ApplicationPluginConfig>)
console.log(chalk.green(`Configured Port: ${port}`));

// Configure Swagger for API documentation
const options = new DocumentBuilder().setTitle('Gauzy API').setVersion('1.0').addBearerAuth().build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('swg', app, document);
console.log(chalk.green(`Swagger UI available at http://${host}:${port}/swg`));
const swaggerPath = await setupSwagger(app);
console.log(chalk.green(`Swagger documentation available at http://${host}:${port}/${swaggerPath}`));

// Configure Atlassian Connect Express
// const addon = ac(express());
Expand Down
39 changes: 39 additions & 0 deletions packages/core/src/lib/bootstrap/swagger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { INestApplication } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder, SwaggerDocumentOptions, SwaggerCustomOptions } from '@nestjs/swagger';

/**
* Sets up and configures Swagger API documentation for the given NestJS application.
*
* This function creates a Swagger configuration using the DocumentBuilder by setting the title,
* description, version, and enabling bearer authentication. It then generates the Swagger document
* with any additional options and sets up the Swagger UI at the specified endpoint.
*
* @param {INestApplication} app - The NestJS application instance.
* @returns {Promise<string>} A promise that resolves to the Swagger documentation path.
*/
export const setupSwagger = async (app: INestApplication): Promise<string> => {
const config = new DocumentBuilder()
.setTitle('Gauzy API')
.setDescription('Gauzy API Documentation')
.setVersion('1.0')
.addBearerAuth()
.build();

// Swagger document options (if needed, can add additional options here)
const options: SwaggerDocumentOptions = {};

// Generate the Swagger document from the app instance and configuration
const document = SwaggerModule.createDocument(app, config, options);

// Custom options for the Swagger UI (e.g., custom CSS, custom site title, etc.)
const customOptions: SwaggerCustomOptions = {};

// Define the Swagger endpoint path
const swaggerPath = 'docs';

// Setup Swagger UI at the `/docs` endpoint
SwaggerModule.setup(swaggerPath, app, document, customOptions);

// Return the Swagger path
return swaggerPath;
};
18 changes: 9 additions & 9 deletions packages/core/src/lib/database/database.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,39 @@ import { ConnectionEntityManager } from './connection-entity-manager';
* @type {MikroORMModuleOptions}
*/
MikroOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
// Use useFactory, useClass, or useExisting
useFactory: async (configService: ConfigService) => {
const dbMikroOrmConnectionOptions = configService.getConfigValue('dbMikroOrmConnectionOptions');
return dbMikroOrmConnectionOptions;
}
},
imports: [ConfigModule],
inject: [ConfigService]
}),
/**
* Configuration for TypeORM database connection.
*
* @type {TypeOrmModuleOptions}
*/
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
// Use useFactory, useClass, or useExisting
useFactory: async (configService: ConfigService) => {
const dbConnectionOptions = configService.getConfigValue('dbConnectionOptions');
return dbConnectionOptions;
}
},
imports: [ConfigModule],
inject: [ConfigService]
}),
/**
* Configure the Knex.js module for the application using asynchronous options.
*/
KnexModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
// Use useFactory, useClass, or useExisting
useFactory: async (configService: ConfigService) => {
const dbKnexConnectionOptions = configService.getConfigValue('dbKnexConnectionOptions');
return dbKnexConnectionOptions;
}
},
imports: [ConfigModule],
inject: [ConfigService]
})
],
providers: [ConnectionEntityManager],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class InputFilterComponent extends DefaultFilter implements OnInit, OnDes
this.subscription = this.inputControl.valueChanges
.pipe(
// Apply a debounce time to reduce the frequency of value changes
debounceTime(this.delay),
debounceTime(this.debounceTime),
// Ensure distinct values to avoid redundant operations
distinctUntilChanged(),
// Use tap to perform a side effect, invoking the filterFunction of the column
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators';
import { Subscription } from 'rxjs/internal/Subscription';
Expand Down Expand Up @@ -27,7 +27,7 @@ import { DefaultFilter } from 'angular2-smart-table';
</div>
`
})
export class RangeFilterComponent extends DefaultFilter implements OnInit, OnDestroy, OnChanges {
export class RangeFilterComponent extends DefaultFilter implements OnInit, OnDestroy {
public rangeControl = new FormGroup({
min: new FormControl(),
max: new FormControl()
Expand All @@ -42,7 +42,7 @@ export class RangeFilterComponent extends DefaultFilter implements OnInit, OnDes
// Subscribe to both min and max value changes
this.subscription = this.rangeControl.valueChanges
.pipe(
debounceTime(this.delay), // Reduce unnecessary requests
debounceTime(this.debounceTime), // Reduce unnecessary requests
distinctUntilChanged(), // Avoid redundant filtering
tap(({ min, max }) => {
if (min !== null || max !== null) {
Expand All @@ -53,8 +53,6 @@ export class RangeFilterComponent extends DefaultFilter implements OnInit, OnDes
.subscribe();
}

ngOnChanges(changes: SimpleChanges) {}

ngOnDestroy() {
// Cleanup subscription to avoid memory leaks
this.subscription.unsubscribe();
Expand Down

0 comments on commit 87bed10

Please sign in to comment.