chore(repo): multiple datasources
This commit is contained in:
		
							parent
							
								
									577f781556
								
							
						
					
					
						commit
						2c313a0dd0
					
				| @ -1,6 +1,6 @@ | |||||||
| import { Body, Controller, HttpCode, HttpStatus, Post, UnauthorizedException, UseGuards } from '@nestjs/common'; | import { Body, Controller, HttpCode, HttpStatus, Post, UnauthorizedException, UseGuards } from '@nestjs/common'; | ||||||
| import { ApiBearerAuth } from '@nestjs/swagger'; | import { ApiBearerAuth } from '@nestjs/swagger'; | ||||||
| import { AccountsEntity } from '../database/entities'; | import { AccountsEntity } from '../database/connections/ebitemp-api/entities'; | ||||||
| import { LoginDto, LoginResDto } from './auth.dto'; | import { LoginDto, LoginResDto } from './auth.dto'; | ||||||
| import { AuthService } from './auth.service'; | import { AuthService } from './auth.service'; | ||||||
| import { AuthenticatedUser } from './authenticated-user.decorator'; | import { AuthenticatedUser } from './authenticated-user.decorator'; | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| import { createZodDto } from '@anatine/zod-nestjs'; | import { createZodDto } from '@anatine/zod-nestjs'; | ||||||
| import { z } from 'zod'; | import { z } from 'zod'; | ||||||
| import { AccountsEntitySchema } from '../database/entities'; | import { AccountsEntitySchema } from '../database/connections/ebitemp-api/entities'; | ||||||
| 
 | 
 | ||||||
| export const loginSchema = z.object({ | export const loginSchema = z.object({ | ||||||
|   username: AccountsEntitySchema.shape.username, |   username: AccountsEntitySchema.shape.username, | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ import { Module } from '@nestjs/common'; | |||||||
| import { APP_GUARD, Reflector } from '@nestjs/core'; | import { APP_GUARD, Reflector } from '@nestjs/core'; | ||||||
| import { PassportModule } from '@nestjs/passport'; | import { PassportModule } from '@nestjs/passport'; | ||||||
| import { TypeOrmModule } from '@nestjs/typeorm'; | import { TypeOrmModule } from '@nestjs/typeorm'; | ||||||
| import { AccountsEntity } from '../database/entities'; | import { AccountsEntity } from '../database/connections/ebitemp-api/entities'; | ||||||
| import { AuthController } from './auth.controller'; | import { AuthController } from './auth.controller'; | ||||||
| import { AuthService } from './auth.service'; | import { AuthService } from './auth.service'; | ||||||
| import { JwtAccessTokenAuthStrategy } from './strategies/jwt/jwt-access-token-auth.strategy'; | import { JwtAccessTokenAuthStrategy } from './strategies/jwt/jwt-access-token-auth.strategy'; | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ import { Inject, Injectable, Logger, UnauthorizedException } from '@nestjs/commo | |||||||
| import { JwtService } from '@nestjs/jwt'; | import { JwtService } from '@nestjs/jwt'; | ||||||
| import * as bcrypt from 'bcrypt'; | import * as bcrypt from 'bcrypt'; | ||||||
| import { isEmpty } from 'lodash'; | import { isEmpty } from 'lodash'; | ||||||
| import { AccountsEntity } from '../database/entities'; | import { AccountsEntity } from '../database/connections/ebitemp-api/entities'; | ||||||
| import { ACCESS_TOKEN_JWT_SERVICE } from './strategies/jwt/jwt-access-token.module'; | import { ACCESS_TOKEN_JWT_SERVICE } from './strategies/jwt/jwt-access-token.module'; | ||||||
| import { REFRESH_TOKEN_JWT_SERVICE } from './strategies/jwt/jwt-refresh-token.module'; | import { REFRESH_TOKEN_JWT_SERVICE } from './strategies/jwt/jwt-refresh-token.module'; | ||||||
| import { UsersAuthService } from './users/users-auth.service'; | import { UsersAuthService } from './users/users-auth.service'; | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import { FastifyRequest } from "fastify"; | import { FastifyRequest } from "fastify"; | ||||||
| import { AccountsEntity } from "../../database/entities"; | import { AccountsEntity } from "../../database/connections/ebitemp-api/entities"; | ||||||
| 
 | 
 | ||||||
| export interface RequestWithUser extends FastifyRequest { | export interface RequestWithUser extends FastifyRequest { | ||||||
|   user: AccountsEntity; |   user: AccountsEntity; | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; | |||||||
| import { InjectRepository } from '@nestjs/typeorm'; | import { InjectRepository } from '@nestjs/typeorm'; | ||||||
| import bcrypt from 'bcrypt'; | import bcrypt from 'bcrypt'; | ||||||
| import { Repository } from 'typeorm'; | import { Repository } from 'typeorm'; | ||||||
| import { AccountsEntity } from '../../database/entities'; | import { AccountsEntity } from '../../database/connections/ebitemp-api/entities'; | ||||||
| 
 | 
 | ||||||
| @Injectable() | @Injectable() | ||||||
| export class UsersAuthService { | export class UsersAuthService { | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| import { Module } from '@nestjs/common'; | import { Module } from '@nestjs/common'; | ||||||
| import { TypeOrmModule } from '@nestjs/typeorm'; | import { TypeOrmModule } from '@nestjs/typeorm'; | ||||||
| import { UsersAuthService } from './users-auth.service'; | import { UsersAuthService } from './users-auth.service'; | ||||||
| import { AccountsEntity } from '../../database/entities'; | import { AccountsEntity } from '../../database/connections/ebitemp-api/entities'; | ||||||
| 
 | 
 | ||||||
| @Module({ | @Module({ | ||||||
|   imports: [TypeOrmModule.forFeature([AccountsEntity])], |   imports: [TypeOrmModule.forFeature([AccountsEntity])], | ||||||
|  | |||||||
| @ -0,0 +1,10 @@ | |||||||
|  | import coerceRecordTypes from '../../../config/utils/coerce-record-types'; | ||||||
|  | import { databaseConfigFactory, rawDatabaseSchema } from '../../utils/database-config'; | ||||||
|  | 
 | ||||||
|  | const env = coerceRecordTypes(process.env); | ||||||
|  | const envParsed = rawDatabaseSchema.strict().parse({ | ||||||
|  |   connectionString: env['DATABASE_EBITEMPAPI_CONNECTION_STRING'], | ||||||
|  |   secure: env['DATABASE_EBITEMPAPI_SECURE'], | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const databaseConfig = databaseConfigFactory(envParsed); | ||||||
| @ -0,0 +1,29 @@ | |||||||
|  | import { Module } from '@nestjs/common'; | ||||||
|  | import { ConfigModule } from '@nestjs/config'; | ||||||
|  | import { TypeOrmModule } from '@nestjs/typeorm'; | ||||||
|  | import { DatabaseConfig } from '../../utils/database-config'; | ||||||
|  | import { typeormTransactionalDataSourceFactory } from '../../utils/typeorm-data-source-factory'; | ||||||
|  | import { typeormEntitiesFromImport } from '../../utils/typeorm-import-entities'; | ||||||
|  | import { typeormModuleOptionsFactory } from '../../utils/typeorm-module-options-factory'; | ||||||
|  | import { databaseConfig } from './database.config'; | ||||||
|  | 
 | ||||||
|  | @Module({ | ||||||
|  |   imports: [ | ||||||
|  |     ConfigModule.forFeature(databaseConfig), | ||||||
|  |     TypeOrmModule.forRootAsync({ | ||||||
|  |       imports: databaseConfig.asProvider().imports, | ||||||
|  |       dataSourceFactory: typeormTransactionalDataSourceFactory(), | ||||||
|  |       useFactory: async (dbConfig: DatabaseConfig) => { | ||||||
|  |         const config = await typeormModuleOptionsFactory( | ||||||
|  |           dbConfig, | ||||||
|  |           await typeormEntitiesFromImport(await import('./index')) | ||||||
|  |         ); | ||||||
|  |         return config; | ||||||
|  |       }, | ||||||
|  |       inject: [databaseConfig.KEY], | ||||||
|  |     }), | ||||||
|  |   ], | ||||||
|  |   providers: [], | ||||||
|  |   exports: [TypeOrmModule], | ||||||
|  | }) | ||||||
|  | export class EbitempApiDatabaseModule {} | ||||||
| @ -1,5 +1,5 @@ | |||||||
| import { Column, Entity, Index } from 'typeorm'; | import { Column, Entity, Index } from 'typeorm'; | ||||||
| import { Enumify } from '../../enumify/enumify'; | import { Enumify } from '../../../../enumify/enumify'; | ||||||
| 
 | 
 | ||||||
| export class InviaMailSeErrori { | export class InviaMailSeErrori { | ||||||
|   @Column('bit', { name: 'flag', default: () => '(0)' }) |   @Column('bit', { name: 'flag', default: () => '(0)' }) | ||||||
| @ -0,0 +1 @@ | |||||||
|  | export * from './entities'; | ||||||
| @ -0,0 +1,10 @@ | |||||||
|  | import coerceRecordTypes from '../../../config/utils/coerce-record-types'; | ||||||
|  | import { databaseConfigFactory, rawDatabaseSchema } from '../../utils/database-config'; | ||||||
|  | 
 | ||||||
|  | const env = coerceRecordTypes(process.env); | ||||||
|  | const envParsed = rawDatabaseSchema.strict().parse({ | ||||||
|  |   connectionString: env['DATABASE_OCEANO_CONNECTION_STRING'], | ||||||
|  |   secure: env['DATABASE_OCEANO_SECURE'], | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | export const databaseConfig = databaseConfigFactory(envParsed); | ||||||
| @ -0,0 +1,29 @@ | |||||||
|  | import { Module } from '@nestjs/common'; | ||||||
|  | import { ConfigModule } from '@nestjs/config'; | ||||||
|  | import { TypeOrmModule } from '@nestjs/typeorm'; | ||||||
|  | import { DatabaseConfig } from '../../utils/database-config'; | ||||||
|  | import { typeormTransactionalDataSourceFactory } from '../../utils/typeorm-data-source-factory'; | ||||||
|  | import { typeormEntitiesFromImport } from '../../utils/typeorm-import-entities'; | ||||||
|  | import { typeormModuleOptionsFactory } from '../../utils/typeorm-module-options-factory'; | ||||||
|  | import { databaseConfig } from './database.config'; | ||||||
|  | 
 | ||||||
|  | @Module({ | ||||||
|  |   imports: [ | ||||||
|  |     ConfigModule.forFeature(databaseConfig), | ||||||
|  |     TypeOrmModule.forRootAsync({ | ||||||
|  |       imports: databaseConfig.asProvider().imports, | ||||||
|  |       dataSourceFactory: typeormTransactionalDataSourceFactory(), | ||||||
|  |       useFactory: async (dbConfig: DatabaseConfig) => { | ||||||
|  |         const config = await typeormModuleOptionsFactory( | ||||||
|  |           dbConfig, | ||||||
|  |           await typeormEntitiesFromImport(await import('./index')) | ||||||
|  |         ); | ||||||
|  |         return config; | ||||||
|  |       }, | ||||||
|  |       inject: [databaseConfig.KEY], | ||||||
|  |     }), | ||||||
|  |   ], | ||||||
|  |   providers: [], | ||||||
|  |   exports: [TypeOrmModule], | ||||||
|  | }) | ||||||
|  | export class OceanoDatabaseModule {} | ||||||
| @ -0,0 +1,653 @@ | |||||||
|  | import { Column, Entity, Index, JoinColumn, ManyToOne, OneToMany } from 'typeorm'; | ||||||
|  | @Index('PK_gruppo', ['codiceGruppo'], { unique: true }) | ||||||
|  | @Entity('gruppo') | ||||||
|  | export class GruppoEntity { | ||||||
|  |   @Column('bigint', { primary: true, name: 'codiceGruppo' }) | ||||||
|  |   codiceGruppo!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'gruppo', nullable: true, length: 80 }) | ||||||
|  |   gruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'descrizioneGruppo', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 255, | ||||||
|  |   }) | ||||||
|  |   descrizioneGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'noteGruppo', nullable: true }) | ||||||
|  |   noteGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'referenteGruppo', nullable: true, length: 80 }) | ||||||
|  |   referenteGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'telefonoReferente', nullable: true, length: 80 }) | ||||||
|  |   telefonoReferente!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'cellulareReferente', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   cellulareReferente!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'emailReferente', nullable: true, length: 80 }) | ||||||
|  |   emailReferente!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'indirizzoGruppo', nullable: true, length: 80 }) | ||||||
|  |   indirizzoGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'numeroCivicoGruppo', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   numeroCivicoGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'capGruppo', nullable: true, length: 10 }) | ||||||
|  |   capGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'localitaGruppo', nullable: true, length: 80 }) | ||||||
|  |   localitaGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'telefono1Gruppo', nullable: true, length: 80 }) | ||||||
|  |   telefono1Gruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'telefono2Gruppo', nullable: true, length: 80 }) | ||||||
|  |   telefono2Gruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'faxGruppo', nullable: true, length: 80 }) | ||||||
|  |   faxGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'emailGruppo', nullable: true, length: 80 }) | ||||||
|  |   emailGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'sitoWebGruppo', nullable: true, length: 80 }) | ||||||
|  |   sitoWebGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'gruppoAttivo', nullable: true }) | ||||||
|  |   gruppoAttivo!: number | null; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'esolverAttivo', nullable: true }) | ||||||
|  |   esolverAttivo!: number | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'serverEsolver', nullable: true, length: 80 }) | ||||||
|  |   serverEsolver!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'databaseEsolver', nullable: true, length: 80 }) | ||||||
|  |   databaseEsolver!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'usernameEsolver', nullable: true, length: 80 }) | ||||||
|  |   usernameEsolver!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'passwordEsolver', nullable: true, length: 80 }) | ||||||
|  |   passwordEsolver!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'gruppoEsolver', nullable: true, length: 80 }) | ||||||
|  |   gruppoEsolver!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('image', { name: 'logoGruppo', nullable: true }) | ||||||
|  |   logoGruppo!: Buffer | null; | ||||||
|  | 
 | ||||||
|  |   @Column('bigint', { name: 'utenteCreazione', nullable: true }) | ||||||
|  |   utenteCreazione!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'dataCreazione', nullable: true, length: 10 }) | ||||||
|  |   dataCreazione!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'oraCreazione', nullable: true, length: 8 }) | ||||||
|  |   oraCreazione!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('bigint', { name: 'utenteModifica', nullable: true }) | ||||||
|  |   utenteModifica!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'dataModifica', nullable: true, length: 10 }) | ||||||
|  |   dataModifica!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'oraModifica', nullable: true, length: 8 }) | ||||||
|  |   oraModifica!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'direttivaReport', nullable: true, length: 512 }) | ||||||
|  |   direttivaReport!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'direttivaReportPers', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 512, | ||||||
|  |   }) | ||||||
|  |   direttivaReportPers!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('bigint', { name: 'statoGruppo', nullable: true }) | ||||||
|  |   statoGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('bigint', { name: 'provinciaGruppo', nullable: true }) | ||||||
|  |   provinciaGruppo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'fondo', nullable: true }) | ||||||
|  |   fondo!: number | null; | ||||||
|  | 
 | ||||||
|  |   @Column('decimal', { | ||||||
|  |     name: 'tassaIscrizione', | ||||||
|  |     nullable: true, | ||||||
|  |     precision: 18, | ||||||
|  |     scale: 2, | ||||||
|  |   }) | ||||||
|  |   tassaIscrizione!: number | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'codiceFiscale', nullable: true, length: 80 }) | ||||||
|  |   codiceFiscale!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'serverFTP', nullable: true, length: 200 }) | ||||||
|  |   serverFtp!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'usernameFTP', nullable: true, length: 200 }) | ||||||
|  |   usernameFtp!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'passwordFTP', nullable: true, length: 200 }) | ||||||
|  |   passwordFtp!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('decimal', { | ||||||
|  |     name: 'massimalePresaCarico', | ||||||
|  |     nullable: true, | ||||||
|  |     precision: 18, | ||||||
|  |     scale: 2, | ||||||
|  |   }) | ||||||
|  |   massimalePresaCarico!: number | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'elencoLivello1', nullable: true, length: 80 }) | ||||||
|  |   elencoLivello1!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'testoEmailPreventivo', nullable: true }) | ||||||
|  |   testoEmailPreventivo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'emailPreventivoMittente', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   emailPreventivoMittente!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'emailPreventivoNotifica', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   emailPreventivoNotifica!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'desPreventivoMittente', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   desPreventivoMittente!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'desPreventivoNotifica', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   desPreventivoNotifica!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('bigint', { name: 'codiceContrattoIndividuali', nullable: true }) | ||||||
|  |   codiceContrattoIndividuali!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'codiceAziendaBollettini', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   codiceAziendaBollettini!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'rigaTesserino1', nullable: true, length: 80 }) | ||||||
|  |   rigaTesserino1!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'rigaTesserino2', nullable: true, length: 80 }) | ||||||
|  |   rigaTesserino2!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'rigaTesserino3', nullable: true, length: 80 }) | ||||||
|  |   rigaTesserino3!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'cartellaCondivisa', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 512, | ||||||
|  |   }) | ||||||
|  |   cartellaCondivisa!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'serverSMTP', nullable: true, length: 80 }) | ||||||
|  |   serverSmtp!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'usernameSMTP', nullable: true, length: 80 }) | ||||||
|  |   usernameSmtp!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'passwordSMTP', nullable: true, length: 80 }) | ||||||
|  |   passwordSmtp!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'emailIBAN', nullable: true, length: 255 }) | ||||||
|  |   emailIban!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'emailFatture', nullable: true, length: 255 }) | ||||||
|  |   emailFatture!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'emailRA', nullable: true, length: 255 }) | ||||||
|  |   emailRa!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'emailAreaRiservataSoci', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   emailAreaRiservataSoci!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'desAreaRiservataSoci', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   desAreaRiservataSoci!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'usernameSMS', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 255, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   usernameSms!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'passwordSMS', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 255, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   passwordSms!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittenteSMS', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 255, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   mittenteSms!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'sitoWebDati', length: 255, default: () => "''" }) | ||||||
|  |   sitoWebDati!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'identificativoCreditore', | ||||||
|  |     length: 35, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   identificativoCreditore!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'SMSProtocollo', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   smsProtocollo!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailBonifico', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailBonifico!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { | ||||||
|  |     name: 'emailBonifico', | ||||||
|  |     nullable: true, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   emailBonifico!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { | ||||||
|  |     name: 'emailAssegno', | ||||||
|  |     nullable: true, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   emailAssegno!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailAssegno', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailAssegno!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'SMSRimborsoBonifico', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   smsRimborsoBonifico!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'SMSRimborsoAssegno', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   smsRimborsoAssegno!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'emailPIC', nullable: true, length: 255 }) | ||||||
|  |   emailPic!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'stelline', length: 10, default: () => "''" }) | ||||||
|  |   stelline!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'mittentePIC', length: 400, default: () => "''" }) | ||||||
|  |   mittentePic!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'oggettoPIC', default: () => "''" }) | ||||||
|  |   oggettoPic!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'messaggioPIC', default: () => "''" }) | ||||||
|  |   messaggioPic!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'nomeSupportoContrattoPosta', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   nomeSupportoContrattoPosta!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'codiceContrattoPosta', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   codiceContrattoPosta!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'passwordContrattoPosta', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   passwordContrattoPosta!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('bigint', { | ||||||
|  |     name: 'codiceSpedizione', | ||||||
|  |     nullable: true, | ||||||
|  |     default: () => '(0)', | ||||||
|  |   }) | ||||||
|  |   codiceSpedizione!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailBonificoDomiciliato', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailBonificoDomiciliato!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { | ||||||
|  |     name: 'emailBonificoDomiciliato', | ||||||
|  |     nullable: true, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   emailBonificoDomiciliato!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'SMSRimborsoBonificoDomiciliato', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   smsRimborsoBonificoDomiciliato!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'notifichePush', default: () => '(0)' }) | ||||||
|  |   notifichePush!: number; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'controlloCodiceFiscale', default: () => '(-1)' }) | ||||||
|  |   controlloCodiceFiscale!: number; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'emailSuperamentoPIC', default: () => "''" }) | ||||||
|  |   emailSuperamentoPic!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'SMSProtocolloNotificaEsplicita', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   smsProtocolloNotificaEsplicita!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittenteSportello', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   mittenteSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailBonificoDomiciliatoSportello', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailBonificoDomiciliatoSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { | ||||||
|  |     name: 'emailBonificoDomiciliatoSportello', | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   emailBonificoDomiciliatoSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailBonificoSportello', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailBonificoSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'emailBonificoSportello', default: () => "''" }) | ||||||
|  |   emailBonificoSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailSospensioneSportello', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailSospensioneSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'emailSospensioneSportello', default: () => "''" }) | ||||||
|  |   emailSospensioneSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailRespingimentoSportello', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailRespingimentoSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'emailRespingimentoSportello', default: () => "''" }) | ||||||
|  |   emailRespingimentoSportello!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailSospensione', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailSospensione!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'emailSospensione', default: () => "''" }) | ||||||
|  |   emailSospensione!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailRespingimento', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailRespingimento!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'emailRespingimento', default: () => "''" }) | ||||||
|  |   emailRespingimento!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittentePICdisdetta', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 400, | ||||||
|  |   }) | ||||||
|  |   mittentePiCdisdetta!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'oggettoPICdisdetta', nullable: true }) | ||||||
|  |   oggettoPiCdisdetta!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'messaggioPICdisdetta', nullable: true }) | ||||||
|  |   messaggioPiCdisdetta!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'modalitaMassimaleBonifico', default: () => '(0)' }) | ||||||
|  |   modalitaMassimaleBonifico!: number; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { name: 'portaSMTP', length: 10, default: () => "''" }) | ||||||
|  |   portaSmtp!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'useSSL', default: () => '(0)' }) | ||||||
|  |   useSsl!: number; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'serverSMTPSpot', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   serverSmtpSpot!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'usernameSMTPSpot', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   usernameSmtpSpot!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'passwordSMTPSpot', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   passwordSmtpSpot!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'portaSMTPSpot', | ||||||
|  |     length: 10, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   portaSmtpSpot!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'useSSLSpot', default: () => '(0)' }) | ||||||
|  |   useSslSpot!: number; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'cartellaPubblicazioneLocale', | ||||||
|  |     length: 512, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   cartellaPubblicazioneLocale!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { name: 'portaFTP', default: () => '(0)' }) | ||||||
|  |   portaFtp!: number; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'cartellaAllegatiFTP', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   cartellaAllegatiFtp!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittentiEmailNotificaEmissioneRimborsoSocio', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   mittentiEmailNotificaEmissioneRimborsoSocio!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittentiEmailInvioAllegatiPraticaSocio', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   mittentiEmailInvioAllegatiPraticaSocio!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittentiEmailRichiestaDatiBancariSocio', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   mittentiEmailRichiestaDatiBancariSocio!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittentiEmailLettereRichiestaContributiRinnoviIndividuali', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   mittentiEmailLettereRichiestaContributiRinnoviIndividuali!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittentiEmailLettereSoci', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   mittentiEmailLettereSoci!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittentiEmailLettereStrutture', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   mittentiEmailLettereStrutture!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'mittentiEmailLettereContratti', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   mittentiEmailLettereContratti!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'emailNotificaCodiciFiscaliDoppiMittente', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   emailNotificaCodiciFiscaliDoppiMittente!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'emailNotificaCodiciFiscaliDoppiDestinatari', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 80, | ||||||
|  |   }) | ||||||
|  |   emailNotificaCodiciFiscaliDoppiDestinatari!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'emailNotificaCodiciFiscaliDoppiCc', | ||||||
|  |     nullable: true, | ||||||
|  |     length: 200, | ||||||
|  |   }) | ||||||
|  |   emailNotificaCodiciFiscaliDoppiCc!: string | null; | ||||||
|  | 
 | ||||||
|  |   @Column('nvarchar', { | ||||||
|  |     name: 'oggettoEmailRichiestaDatiBancari', | ||||||
|  |     length: 200, | ||||||
|  |     default: () => "''", | ||||||
|  |   }) | ||||||
|  |   oggettoEmailRichiestaDatiBancari!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('ntext', { name: 'emailRichiestaDatiBancari', default: () => "''" }) | ||||||
|  |   emailRichiestaDatiBancari!: string; | ||||||
|  | 
 | ||||||
|  |   @Column('int', { | ||||||
|  |     name: 'flagAllegaModuloIbanEmailRichiestaDatiBancari', | ||||||
|  |     nullable: true, | ||||||
|  |   }) | ||||||
|  |   flagAllegaModuloIbanEmailRichiestaDatiBancari!: number | null; | ||||||
|  | 
 | ||||||
|  |   constructor(init?: Partial<GruppoEntity>) { | ||||||
|  |     Object.assign(this, init); | ||||||
|  |   } | ||||||
|  | } | ||||||
| @ -0,0 +1 @@ | |||||||
|  | export * from './gruppo.entity'; | ||||||
| @ -0,0 +1 @@ | |||||||
|  | export * from './entities'; | ||||||
| @ -1,36 +1,19 @@ | |||||||
| import { Global, Module } from '@nestjs/common'; | import { Global, Module } from '@nestjs/common'; | ||||||
| import { ConfigModule } from '@nestjs/config'; |  | ||||||
| import { TypeOrmModule } from '@nestjs/typeorm'; |  | ||||||
| import { DataSource } from 'typeorm'; |  | ||||||
| import { DatabaseConfig, databaseConfig } from './database.config'; |  | ||||||
| import { APP_DATASOURCES } from './database.constants'; | import { APP_DATASOURCES } from './database.constants'; | ||||||
| import { typeormTransactionalDataSourceFactory } from './utils/typeorm-data-source-factory'; | import { EbitempApiDatabaseModule } from './connections/ebitemp-api/database.module'; | ||||||
| import { typeormModuleOptionsFactory } from './utils/typeorm-module-options-factory'; | import { dataSources } from './utils/typeorm-data-source-factory'; | ||||||
| import { typeormEntitiesFromImport } from './utils/typeorm-import-entities'; |  | ||||||
| 
 |  | ||||||
| const dataSources: DataSource[] = []; |  | ||||||
| 
 |  | ||||||
| const typeormModules = [ |  | ||||||
|   TypeOrmModule.forRootAsync({ |  | ||||||
|     imports: databaseConfig.asProvider().imports, |  | ||||||
|     dataSourceFactory: typeormTransactionalDataSourceFactory(), |  | ||||||
|     useFactory: async (dbConfig: DatabaseConfig) => { |  | ||||||
|       const config = await typeormModuleOptionsFactory(dbConfig, await typeormEntitiesFromImport(await import('./entities'))); |  | ||||||
|       return config; |  | ||||||
|     }, |  | ||||||
|     inject: [databaseConfig.KEY], |  | ||||||
|   }), |  | ||||||
| ]; |  | ||||||
| 
 | 
 | ||||||
| const dataSourcesProvider = { | const dataSourcesProvider = { | ||||||
|   provide: APP_DATASOURCES, |   provide: APP_DATASOURCES, | ||||||
|   useValue: dataSources, |   useValue: dataSources, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | const databaseModules = [EbitempApiDatabaseModule]; | ||||||
|  | 
 | ||||||
| @Global() | @Global() | ||||||
| @Module({ | @Module({ | ||||||
|   imports: [ConfigModule.forFeature(databaseConfig), ...typeormModules], |   imports: [...databaseModules], | ||||||
|   providers: [dataSourcesProvider], |   providers: [dataSourcesProvider], | ||||||
|   exports: [...typeormModules, dataSourcesProvider], |   exports: [dataSourcesProvider, ...databaseModules], | ||||||
| }) | }) | ||||||
| export class AppDatabaseModule {} | export class AppDatabaseModule {} | ||||||
|  | |||||||
| @ -2,7 +2,6 @@ import { registerAs } from '@nestjs/config'; | |||||||
| import { ConnectionString } from 'connection-string'; | import { ConnectionString } from 'connection-string'; | ||||||
| import { first } from 'lodash'; | import { first } from 'lodash'; | ||||||
| import { z } from 'zod'; | import { z } from 'zod'; | ||||||
| import coerceRecordTypes from '../config/utils/coerce-record-types'; |  | ||||||
| 
 | 
 | ||||||
| export const databaseSchema = z.object({ | export const databaseSchema = z.object({ | ||||||
|   connectionString: z.string(), |   connectionString: z.string(), | ||||||
| @ -34,21 +33,16 @@ export const databaseSchema = z.object({ | |||||||
|   database: z.string(), |   database: z.string(), | ||||||
|   secure: z.boolean(), |   secure: z.boolean(), | ||||||
| }); | }); | ||||||
| 
 |  | ||||||
| export type DatabaseConfig = z.TypeOf<typeof databaseSchema>; | export type DatabaseConfig = z.TypeOf<typeof databaseSchema>; | ||||||
| const rawDatabaseSchema = z.object({ | 
 | ||||||
|  | export const rawDatabaseSchema = z.object({ | ||||||
|   connectionString: z.string(), |   connectionString: z.string(), | ||||||
|   secure: z.boolean().default(true), |   secure: z.boolean().default(true), | ||||||
| }); | }); | ||||||
|  | export type RawDatabaseConfigSchema = z.TypeOf<typeof rawDatabaseSchema>; | ||||||
| 
 | 
 | ||||||
| export const databaseConfig = registerAs('database', () => { | export const databaseConfigFactory = (opts: RawDatabaseConfigSchema) => registerAs('database', () => { | ||||||
|   const env = coerceRecordTypes(process.env); |   const connectionString = new ConnectionString(opts.connectionString); | ||||||
|   const envParsed = rawDatabaseSchema.strict().parse({ |  | ||||||
|     connectionString: env['DATABASE_CONNECTION_STRING'], |  | ||||||
|     secure: env['DATABASE_SECURE'], |  | ||||||
|   }); |  | ||||||
| 
 |  | ||||||
|   const connectionString = new ConnectionString(envParsed.connectionString); |  | ||||||
|   const config: DatabaseConfig = databaseSchema.strict().parse({ |   const config: DatabaseConfig = databaseSchema.strict().parse({ | ||||||
|     connectionString: connectionString.toString(), |     connectionString: connectionString.toString(), | ||||||
|     type: connectionString.protocol, |     type: connectionString.protocol, | ||||||
| @ -57,7 +51,7 @@ export const databaseConfig = registerAs('database', () => { | |||||||
|     username: connectionString.user, |     username: connectionString.user, | ||||||
|     password: connectionString.password, |     password: connectionString.password, | ||||||
|     database: first(connectionString.path), |     database: first(connectionString.path), | ||||||
|     secure: envParsed.secure, |     secure: opts.secure, | ||||||
|   }); |   }); | ||||||
|   return config; |   return config; | ||||||
| }); | }); | ||||||
| @ -1,6 +1,6 @@ | |||||||
| import { TypeOrmModuleOptions } from '@nestjs/typeorm'; | import { TypeOrmModuleOptions } from '@nestjs/typeorm'; | ||||||
| import { DatabaseConfig } from '../database.config'; |  | ||||||
| import { SnakeNamingStrategy } from 'typeorm-naming-strategies'; | import { SnakeNamingStrategy } from 'typeorm-naming-strategies'; | ||||||
|  | import { DatabaseConfig } from './database-config'; | ||||||
| 
 | 
 | ||||||
| export const typeormModuleOptionsFactory = async ( | export const typeormModuleOptionsFactory = async ( | ||||||
|   databaseConfig: DatabaseConfig, |   databaseConfig: DatabaseConfig, | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ import { registerAs } from '@nestjs/config'; | |||||||
| import { z } from 'zod'; | import { z } from 'zod'; | ||||||
| 
 | 
 | ||||||
| export const enumifySchema = z.object({ | export const enumifySchema = z.object({ | ||||||
|   shouldUpdateEnumFromDbOnStartup: z.boolean().default(false), |   shouldUpdateEnumFromDbOnStartup: z.boolean().default(true), | ||||||
| }); | }); | ||||||
| export type EnumifyConfig = z.infer<typeof enumifySchema>; | export type EnumifyConfig = z.infer<typeof enumifySchema>; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import { Module } from '@nestjs/common'; | import { Module } from '@nestjs/common'; | ||||||
| import { ScheduleModule } from '@nestjs/schedule'; | import { ScheduleModule } from '@nestjs/schedule'; | ||||||
| import { TypeOrmModule } from '@nestjs/typeorm'; | import { TypeOrmModule } from '@nestjs/typeorm'; | ||||||
| import { TipiJobsEntity } from '../database/entities'; | import { TipiJobsEntity } from '../database/connections/ebitemp-api/entities'; | ||||||
| import { SchedulerService } from './schedule.service'; | import { SchedulerService } from './schedule.service'; | ||||||
| 
 | 
 | ||||||
| @Module({ | @Module({ | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ import { SchedulerRegistry } from '@nestjs/schedule'; | |||||||
| import { InjectRepository } from '@nestjs/typeorm'; | import { InjectRepository } from '@nestjs/typeorm'; | ||||||
| import { CronJob, CronTime } from 'cron'; | import { CronJob, CronTime } from 'cron'; | ||||||
| import { Repository } from 'typeorm'; | import { Repository } from 'typeorm'; | ||||||
| import { TipiJobsEntity } from '../database/entities/tipi_jobs.entity'; | import { TipiJobsEntity } from '../database/connections/ebitemp-api/entities/tipi_jobs.entity'; | ||||||
| import { isError } from '@stdlib/assert'; | import { isError } from '@stdlib/assert'; | ||||||
| 
 | 
 | ||||||
| @Injectable() | @Injectable() | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user