Loading backend/src/admin/dto/create-admin.dto.ts +3 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,9 @@ export class CreateAdminDto { @ApiProperty() email: string; @ApiProperty() idTown: number; @ApiProperty() password: string; Loading backend/src/admin/entities/admin.entity.ts +6 −1 Original line number Diff line number Diff line import { ADMIN_ROLE } from 'src/shared/enum/admin-role.enum'; import { UserStatus } from 'src/shared/enum/user-status.enum'; import { Entity, Column, PrimaryColumn } from 'typeorm'; import { Town } from 'src/town/entities/town.entity'; import { Entity, Column, PrimaryColumn, JoinColumn, ManyToOne } from 'typeorm'; @Entity() export class Admin { @PrimaryColumn() email: string; @JoinColumn({ name: 'idTown' }) @ManyToOne(() => Town, { nullable: true }) idTown: number; @Column() name: string; Loading backend/src/app.module.ts +21 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,13 @@ import { TownTraduction } from './town/entities/town-traduction.entity'; import { AuthModule } from './shared/service/auth.module'; import { APP_GUARD } from '@nestjs/core'; import { AuthGuard } from './auth/admin/auth.guard'; import { PlaceModule } from './place/place.module'; import { Place } from './place/entities/place.entity'; import { PointOfInterestModule } from './pointOfInterest/PointOfInterest.module'; import { PointOfInterest } from './pointOfInterest/entities/PointOfInterest.entity'; import { AvailableDate } from './place/entities/available-date.entity'; import { PointOfInterestTraduction } from './pointOfInterest/entities/PointOfInterestTraduction.entity'; import { PlaceTraduction } from './place/entities/place-traduction.entity'; @Module({ imports: [ Loading @@ -30,7 +37,18 @@ import { AuthGuard } from './auth/admin/auth.guard'; username: DbConstants.DB_USER, password: DbConstants.DB_PASSWORD, database: DbConstants.DB_NAME, entities: [Admin, User, State, Town, TownTraduction], entities: [ Admin, User, State, Town, TownTraduction, Place, PointOfInterest, AvailableDate, PointOfInterestTraduction, PlaceTraduction, ], synchronize: DbConstants.DB_SYNC, logging: true, }), Loading @@ -42,9 +60,11 @@ import { AuthGuard } from './auth/admin/auth.guard'; DatabaseSeederModule, TownModule, AuthModule, PlaceModule, ServeStaticModule.forRoot({ rootPath: join(__dirname, '..', 'static'), }), PointOfInterestModule, ], controllers: [AppController], providers: [AppService, DatabaseSeederModule, { provide: APP_GUARD, useClass: AuthGuard }], Loading backend/src/constants/server.contants.ts +14 −1 Original line number Diff line number Diff line import * as dotenv from 'dotenv'; dotenv.config(); import * as os from 'os'; let ip = ''; const interfaces = os.networkInterfaces(); for (const interfaceName in interfaces) { const networkInterfaces = interfaces[interfaceName]; for (const networkInterface of networkInterfaces) { if (networkInterface.family === 'IPv4' && !networkInterface.internal) { ip = networkInterface.address; } } } export class ServerConstants { static PORT: number = process.env.SERVER_PORT ? parseInt(process.env.SERVER_PORT) : 3003; static HOST: string = `${process.env.SERVER_HOST || 'http://localhost'}:${this.PORT}`; static IP: string = ip; static HOST: string = `${ip || 'http://localhost'}:${this.PORT}`; } backend/src/database-seeder/database-seeder.module.ts +36 −3 Original line number Diff line number Diff line import { Module } from '@nestjs/common'; import { DatabaseSeederService } from './database-seeder.service'; import { TypeOrmModule } from '@nestjs/typeorm'; import { DatabaseSeederService } from './database-seeder.service'; import { State } from 'src/state/entities/state.entity'; import { StateService } from 'src/state/state.service'; import { Town } from 'src/town/entities/town.entity'; Loading @@ -9,9 +10,41 @@ import { AuthAdminService } from 'src/auth/admin/authAdminservice'; import { AdminService } from 'src/admin/admin.service'; import { JwtService } from '@nestjs/jwt'; import { EncryptionService } from 'src/auth/encryption/encryption.service'; import { TownService } from 'src/town/town.service'; import { TownTraduction } from 'src/town/entities/town-traduction.entity'; import { PointOfInterestService } from 'src/pointOfInterest/PointOfInterest.service'; import { PlaceService } from 'src/place/place.service'; import { Place } from 'src/place/entities/place.entity'; import { PointOfInterest } from 'src/pointOfInterest/entities/PointOfInterest.entity'; import { AvailableDate } from 'src/place/entities/available-date.entity'; import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfInterestTraduction.entity'; @Module({ providers: [DatabaseSeederService, StateService, AuthAdminService, AdminService, JwtService, EncryptionService], imports: [TypeOrmModule.forFeature([State, Town, Admin])], providers: [ DatabaseSeederService, StateService, AuthAdminService, AdminService, JwtService, EncryptionService, TownService, PointOfInterestService, PlaceService, ], imports: [ TypeOrmModule.forFeature([ State, Town, Admin, Town, TownTraduction, Place, PointOfInterest, AvailableDate, PlaceTraduction, PointOfInterestTraduction, ]), ], }) export class DatabaseSeederModule {} Loading
backend/src/admin/dto/create-admin.dto.ts +3 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,9 @@ export class CreateAdminDto { @ApiProperty() email: string; @ApiProperty() idTown: number; @ApiProperty() password: string; Loading
backend/src/admin/entities/admin.entity.ts +6 −1 Original line number Diff line number Diff line import { ADMIN_ROLE } from 'src/shared/enum/admin-role.enum'; import { UserStatus } from 'src/shared/enum/user-status.enum'; import { Entity, Column, PrimaryColumn } from 'typeorm'; import { Town } from 'src/town/entities/town.entity'; import { Entity, Column, PrimaryColumn, JoinColumn, ManyToOne } from 'typeorm'; @Entity() export class Admin { @PrimaryColumn() email: string; @JoinColumn({ name: 'idTown' }) @ManyToOne(() => Town, { nullable: true }) idTown: number; @Column() name: string; Loading
backend/src/app.module.ts +21 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,13 @@ import { TownTraduction } from './town/entities/town-traduction.entity'; import { AuthModule } from './shared/service/auth.module'; import { APP_GUARD } from '@nestjs/core'; import { AuthGuard } from './auth/admin/auth.guard'; import { PlaceModule } from './place/place.module'; import { Place } from './place/entities/place.entity'; import { PointOfInterestModule } from './pointOfInterest/PointOfInterest.module'; import { PointOfInterest } from './pointOfInterest/entities/PointOfInterest.entity'; import { AvailableDate } from './place/entities/available-date.entity'; import { PointOfInterestTraduction } from './pointOfInterest/entities/PointOfInterestTraduction.entity'; import { PlaceTraduction } from './place/entities/place-traduction.entity'; @Module({ imports: [ Loading @@ -30,7 +37,18 @@ import { AuthGuard } from './auth/admin/auth.guard'; username: DbConstants.DB_USER, password: DbConstants.DB_PASSWORD, database: DbConstants.DB_NAME, entities: [Admin, User, State, Town, TownTraduction], entities: [ Admin, User, State, Town, TownTraduction, Place, PointOfInterest, AvailableDate, PointOfInterestTraduction, PlaceTraduction, ], synchronize: DbConstants.DB_SYNC, logging: true, }), Loading @@ -42,9 +60,11 @@ import { AuthGuard } from './auth/admin/auth.guard'; DatabaseSeederModule, TownModule, AuthModule, PlaceModule, ServeStaticModule.forRoot({ rootPath: join(__dirname, '..', 'static'), }), PointOfInterestModule, ], controllers: [AppController], providers: [AppService, DatabaseSeederModule, { provide: APP_GUARD, useClass: AuthGuard }], Loading
backend/src/constants/server.contants.ts +14 −1 Original line number Diff line number Diff line import * as dotenv from 'dotenv'; dotenv.config(); import * as os from 'os'; let ip = ''; const interfaces = os.networkInterfaces(); for (const interfaceName in interfaces) { const networkInterfaces = interfaces[interfaceName]; for (const networkInterface of networkInterfaces) { if (networkInterface.family === 'IPv4' && !networkInterface.internal) { ip = networkInterface.address; } } } export class ServerConstants { static PORT: number = process.env.SERVER_PORT ? parseInt(process.env.SERVER_PORT) : 3003; static HOST: string = `${process.env.SERVER_HOST || 'http://localhost'}:${this.PORT}`; static IP: string = ip; static HOST: string = `${ip || 'http://localhost'}:${this.PORT}`; }
backend/src/database-seeder/database-seeder.module.ts +36 −3 Original line number Diff line number Diff line import { Module } from '@nestjs/common'; import { DatabaseSeederService } from './database-seeder.service'; import { TypeOrmModule } from '@nestjs/typeorm'; import { DatabaseSeederService } from './database-seeder.service'; import { State } from 'src/state/entities/state.entity'; import { StateService } from 'src/state/state.service'; import { Town } from 'src/town/entities/town.entity'; Loading @@ -9,9 +10,41 @@ import { AuthAdminService } from 'src/auth/admin/authAdminservice'; import { AdminService } from 'src/admin/admin.service'; import { JwtService } from '@nestjs/jwt'; import { EncryptionService } from 'src/auth/encryption/encryption.service'; import { TownService } from 'src/town/town.service'; import { TownTraduction } from 'src/town/entities/town-traduction.entity'; import { PointOfInterestService } from 'src/pointOfInterest/PointOfInterest.service'; import { PlaceService } from 'src/place/place.service'; import { Place } from 'src/place/entities/place.entity'; import { PointOfInterest } from 'src/pointOfInterest/entities/PointOfInterest.entity'; import { AvailableDate } from 'src/place/entities/available-date.entity'; import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfInterestTraduction.entity'; @Module({ providers: [DatabaseSeederService, StateService, AuthAdminService, AdminService, JwtService, EncryptionService], imports: [TypeOrmModule.forFeature([State, Town, Admin])], providers: [ DatabaseSeederService, StateService, AuthAdminService, AdminService, JwtService, EncryptionService, TownService, PointOfInterestService, PlaceService, ], imports: [ TypeOrmModule.forFeature([ State, Town, Admin, Town, TownTraduction, Place, PointOfInterest, AvailableDate, PlaceTraduction, PointOfInterestTraduction, ]), ], }) export class DatabaseSeederModule {}