Commit 5531e5bf authored by Lorenzo Trujillo Rojas's avatar Lorenzo Trujillo Rojas
Browse files
parents c73b53b2 7dd3c1d4
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
        "@nestjs/jwt": "^10.2.0",
        "@nestjs/mapped-types": "*",
        "@nestjs/platform-express": "^10.0.0",
        "@nestjs/serve-static": "^4.0.2",
        "@nestjs/swagger": "^7.3.0",
        "@nestjs/typeorm": "^10.0.2",
        "bcrypt": "^5.1.1",
@@ -2040,6 +2041,37 @@
      "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==",
      "dev": true
    },
    "node_modules/@nestjs/serve-static": {
      "version": "4.0.2",
      "resolved": "https://registry.npmjs.org/@nestjs/serve-static/-/serve-static-4.0.2.tgz",
      "integrity": "sha512-cT0vdWN5ar7jDI2NKbhf4LcwJzU4vS5sVpMkVrHuyLcltbrz6JdGi1TfIMMatP2pNiq5Ie/uUdPSFDVaZX/URQ==",
      "dependencies": {
        "path-to-regexp": "0.2.5"
      },
      "peerDependencies": {
        "@fastify/static": "^6.5.0 || ^7.0.0",
        "@nestjs/common": "^9.0.0 || ^10.0.0",
        "@nestjs/core": "^9.0.0 || ^10.0.0",
        "express": "^4.18.1",
        "fastify": "^4.7.0"
      },
      "peerDependenciesMeta": {
        "@fastify/static": {
          "optional": true
        },
        "express": {
          "optional": true
        },
        "fastify": {
          "optional": true
        }
      }
    },
    "node_modules/@nestjs/serve-static/node_modules/path-to-regexp": {
      "version": "0.2.5",
      "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.2.5.tgz",
      "integrity": "sha512-l6qtdDPIkmAmzEO6egquYDfqQGPMRNGjYtrU13HAXb3YSRrt7HSb1sJY0pKp6o2bAa86tSB6iwaW2JbthPKr7Q=="
    },
    "node_modules/@nestjs/swagger": {
      "version": "7.3.0",
      "resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-7.3.0.tgz",
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
    "@nestjs/jwt": "^10.2.0",
    "@nestjs/mapped-types": "*",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/serve-static": "^4.0.2",
    "@nestjs/swagger": "^7.3.0",
    "@nestjs/typeorm": "^10.0.2",
    "bcrypt": "^5.1.1",
+12 −2
Original line number Diff line number Diff line
@@ -9,6 +9,11 @@ import { AuthAdminModule } from './auth/admin/authAdmin.module';
import { UserModule } from './user/user.module';
import { User } from './user/entities/user.entity';
import { AuthUserModule } from './auth/user/authUser.module';
import { StateModule } from './state/state.module';
import { DatabaseSeederModule } from './database-seeder/database-seeder.module';
import { State } from './state/entities/state.entity';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
@Module({
  imports: [
    TypeOrmModule.forRoot({
@@ -18,15 +23,20 @@ import { AuthUserModule } from './auth/user/authUser.module';
      username: DbConstants.DB_USER,
      password: DbConstants.DB_PASSWORD,
      database: DbConstants.DB_NAME,
      entities: [Admin, User],
      entities: [Admin, User, State],
      synchronize: DbConstants.DB_SYNC,
    }),
    AuthAdminModule,
    AdminModule,
    UserModule,
    AuthUserModule,
    StateModule,
    DatabaseSeederModule,
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'static'),
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
  providers: [AppService, DatabaseSeederModule],
})
export class AppModule {}
+9 −1
Original line number Diff line number Diff line
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import {
  BadRequestException,
  HttpException,
  HttpStatus,
  Injectable,
} from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { EncryptionService } from '../encryption/encryption.service';
import { JwtConstants } from 'src/constants/jwt.constants';
@@ -25,6 +30,9 @@ export class AuthUserService {
      createAdminDto.password,
    );
    createAdminDto.password = hashedPwd;
    if (this.userService.userExists(createAdminDto.email)) {
      throw new BadRequestException('User already exists');
    }
    await this.userService.create(createAdminDto);

    const adminSigninResDto: UserSigninResDto =
+1 −0
Original line number Diff line number Diff line
@@ -5,4 +5,5 @@ 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}`;
}
Loading