branch dev
This commit is contained in:
@@ -18,7 +18,7 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/interface-name-prefix': 'off',
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
11011
package-lock.json
generated
11011
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -8,12 +8,11 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rimraf dist",
|
"prebuild": "rimraf dist",
|
||||||
"build": "nest build",
|
"build": "nest build",
|
||||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
"format": "prettier --write \"../../**/*.ts\" \"test/**/*.ts\"",
|
||||||
"start": "nest start",
|
"start": "nest start",
|
||||||
"start:dev": "nest start --watch",
|
"start:dev": "nest start --watch",
|
||||||
"start:debug": "nest start --debug --watch",
|
"start:debug": "nest start --debug --watch",
|
||||||
"start:prod": "node dist/main",
|
"start:prod": "node dist/main",
|
||||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
"test:cov": "jest --coverage",
|
"test:cov": "jest --coverage",
|
||||||
@@ -28,6 +27,8 @@
|
|||||||
"@nestjs/passport": "^10.0.3",
|
"@nestjs/passport": "^10.0.3",
|
||||||
"@nestjs/platform-express": "^7.5.1",
|
"@nestjs/platform-express": "^7.5.1",
|
||||||
"@nestjs/typeorm": "^10.0.2",
|
"@nestjs/typeorm": "^10.0.2",
|
||||||
|
"@types/eslint": "^9.6.1",
|
||||||
|
"@types/estree": "^1.0.7",
|
||||||
"aws-sdk": "^2.1692.0",
|
"aws-sdk": "^2.1692.0",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
@@ -54,11 +55,8 @@
|
|||||||
"@types/express": "^4.17.8",
|
"@types/express": "^4.17.8",
|
||||||
"@types/jest": "^26.0.15",
|
"@types/jest": "^26.0.15",
|
||||||
"@types/multer": "^1.4.12",
|
"@types/multer": "^1.4.12",
|
||||||
"@types/node": "^14.14.6",
|
"@types/node": "^22.13.14",
|
||||||
"@types/supertest": "^2.0.10",
|
"@types/supertest": "^2.0.10",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.6.1",
|
|
||||||
"@typescript-eslint/parser": "^4.6.1",
|
|
||||||
"eslint": "^7.12.1",
|
|
||||||
"eslint-config-prettier": "^6.15.0",
|
"eslint-config-prettier": "^6.15.0",
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
@@ -68,7 +66,7 @@
|
|||||||
"ts-loader": "^8.0.8",
|
"ts-loader": "^8.0.8",
|
||||||
"ts-node": "^9.0.0",
|
"ts-node": "^9.0.0",
|
||||||
"tsconfig-paths": "^3.9.0",
|
"tsconfig-paths": "^3.9.0",
|
||||||
"typescript": "^4.0.5"
|
"typescript": "^5.8.2"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"moduleFileExtensions": [
|
"moduleFileExtensions": [
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
import { UsersService } from '../users/users.service';
|
import { UsersService } from '../users/users.service';
|
||||||
import { UserModel } from 'src/core/models/user.model';
|
import { UserModel } from '../../core/models/user.model';
|
||||||
import { ResultModel } from 'src/core/models/result.model';
|
import { ResultModel } from '../../core/models/result.model';
|
||||||
import { ResetPasswordModel } from 'src/core/models/reset-password.model';
|
import { ResetPasswordModel } from '../../core/models/reset-password.model';
|
||||||
import { ChangePasswordModel } from 'src/core/models/change-password.model';
|
import { ChangePasswordModel } from '../../core/models/change-password.model';
|
||||||
|
|
||||||
@Controller('api/v1/auth')
|
@Controller('api/v1/auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
|||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import md5 = require('md5');
|
import md5 = require('md5');
|
||||||
import { Guid } from "guid-typescript";
|
import { Guid } from "guid-typescript";
|
||||||
import { typeOrmConfig } from 'src/core/configs/typeorm.config';
|
import { typeOrmConfig } from '../../core/configs/typeorm.config';
|
||||||
import { UserModel } from 'src/core/models/user.model';
|
import { UserModel } from '../../core/models/user.model';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
export class Invoice {
|
export class Invoice {
|
||||||
customer: string;
|
customer: string;
|
||||||
invoiceNumber: number;
|
invoiceNumber: number;
|
||||||
loadingNumber: number;
|
loadingNumber: number;
|
||||||
reasonId: number;
|
reasonId: number;
|
||||||
reasonText: string;
|
reasonText: string;
|
||||||
status: string;
|
status: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CarInDelivery {
|
export class CarInDelivery {
|
||||||
finalKm: number;
|
finalKm: number;
|
||||||
invoices: Invoice[];
|
invoices: Invoice[];
|
||||||
licensePlate: string;
|
licensePlate: string;
|
||||||
loadingNumber: number;
|
loadingNumber: number;
|
||||||
observation: string;
|
observation: string;
|
||||||
images: string[];
|
images: string[];
|
||||||
userId: number;
|
userId: number;
|
||||||
qtdPaletesPbr: number;
|
qtdPaletesPbr: number;
|
||||||
qtdPaletesCim: number;
|
qtdPaletesCim: number;
|
||||||
qtdPaletesDes: number;
|
qtdPaletesDes: number;
|
||||||
remnant: string;
|
remnant: string;
|
||||||
observationRemnant: string;
|
observationRemnant: string;
|
||||||
imagesRemnant: string[];
|
imagesRemnant: string[];
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
export class CarOutDelivery {
|
export class CarOutDelivery {
|
||||||
helpers: Helper[]; // Array de objetos auxiliares
|
helpers: Helper[]; // Array de objetos auxiliares
|
||||||
licensePlate: string; // Placa do veículo
|
licensePlate: string; // Placa do veículo
|
||||||
numberLoading: number[]; // Número do carregamento
|
numberLoading: number[]; // Número do carregamento
|
||||||
palletCount: number; // Quantidade de pallets
|
palletCount: number; // Quantidade de pallets
|
||||||
photos: string[]; // Array de URLs das fotos
|
photos: string[]; // Array de URLs das fotos
|
||||||
startKm: number; // Quilometragem de início (como string)
|
startKm: number; // Quilometragem de início (como string)
|
||||||
userCode: number; // Código do usuário
|
userCode: number; // Código do usuário
|
||||||
vehicleCode: number; // Código do veículo
|
vehicleCode: number; // Código do veículo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class Helper {
|
export class Helper {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,21 +4,29 @@ https://docs.nestjs.com/controllers#controllers
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Body, Controller, Get, HttpException, HttpStatus, Post, Query, Req, UseInterceptors,
|
Body,
|
||||||
UploadedFile
|
Controller,
|
||||||
|
Get,
|
||||||
|
HttpException,
|
||||||
|
HttpStatus,
|
||||||
|
Post,
|
||||||
|
Query,
|
||||||
|
Req,
|
||||||
|
UseInterceptors,
|
||||||
|
UploadedFile,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { BaseService } from './base.service';
|
import { BaseService } from './base.service';
|
||||||
import { FileInterceptor } from '@nestjs/platform-express';
|
import { FileInterceptor } from '@nestjs/platform-express';
|
||||||
import { diskStorage } from 'multer';
|
import { diskStorage } from 'multer';
|
||||||
import { extname } from 'path';
|
import { extname } from 'path';
|
||||||
import * as fs from "fs";
|
import * as fs from 'fs';
|
||||||
|
|
||||||
@Controller('api/v1/base')
|
@Controller('api/v1/base')
|
||||||
export class BaseController {
|
export class BaseController {
|
||||||
constructor(public readonly baseService: BaseService) { }
|
constructor(public readonly baseService: BaseService) {}
|
||||||
// @UseGuards(JwtAuthGuard)
|
// @UseGuards(JwtAuthGuard)
|
||||||
@Get('execute-view')
|
@Get('execute-view')
|
||||||
/* @ApiOperation({
|
/* @ApiOperation({
|
||||||
summary: 'Executa uma view com ou sem parâmetros',
|
summary: 'Executa uma view com ou sem parâmetros',
|
||||||
})
|
})
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
@@ -33,62 +41,61 @@ export class BaseController {
|
|||||||
status: 500,
|
status: 500,
|
||||||
description: 'Erro ao executar a view.',
|
description: 'Erro ao executar a view.',
|
||||||
})*/
|
})*/
|
||||||
async executeView(
|
async executeView(
|
||||||
@Query('viewName') viewName: string,
|
@Query('viewName') viewName: string,
|
||||||
@Query() params: Record<string, any>,
|
@Query() params: Record<string, any>,
|
||||||
) {
|
) {
|
||||||
if (!viewName) {
|
if (!viewName) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'O nome da view é obrigatório.',
|
'O nome da view é obrigatório.',
|
||||||
HttpStatus.BAD_REQUEST,
|
HttpStatus.BAD_REQUEST,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return await this.baseService.executeView(viewName, params);
|
return await this.baseService.executeView(viewName, params);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
`Erro ao executar a view: ${error.message}`,
|
`Erro ao executar a view: ${error.message}`,
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('send-image')
|
||||||
|
@UseInterceptors(
|
||||||
|
FileInterceptor('file', {
|
||||||
|
storage: diskStorage({
|
||||||
|
// Pasta onde os arquivos serão salvos; certifique-se que essa pasta exista ou crie-a automaticamente
|
||||||
|
destination: './uploads',
|
||||||
|
filename: (req, file, callback) => {
|
||||||
|
// Gera um nome único para o arquivo
|
||||||
|
const uniqueSuffix =
|
||||||
|
Date.now() + '-' + Math.round(Math.random() * 1e9);
|
||||||
|
const fileExtName = extname(file.originalname);
|
||||||
|
callback(null, `${file.fieldname}-${uniqueSuffix}${fileExtName}`);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
// Opcional: definir limites (ex.: tamanho máximo do arquivo)
|
||||||
|
limits: { fileSize: 5 * 1024 * 1024 }, // 5MB
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
async sendImage(
|
||||||
|
@UploadedFile() file: Express.Multer.File,
|
||||||
|
@Body('licensePlate') licensePlate: string,
|
||||||
|
) {
|
||||||
|
if (!file) {
|
||||||
|
throw new HttpException('Nenhum arquivo enviado', HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('send-image')
|
// Aqui você pode processar o arquivo (ex.: enviar para o S3) ou armazená-lo no disco mesmo.
|
||||||
@UseInterceptors(
|
// Neste exemplo, retornamos a URL do arquivo salvo localmente.
|
||||||
FileInterceptor('file', {
|
this.baseService.sendImages('./uploads/' + file.filename);
|
||||||
storage: diskStorage({
|
fs.unlink('./uploads/' + file.filename, () => {});
|
||||||
// Pasta onde os arquivos serão salvos; certifique-se que essa pasta exista ou crie-a automaticamente
|
return {
|
||||||
destination: './uploads',
|
success: true,
|
||||||
filename: (req, file, callback) => {
|
message: 'Upload realizado com sucesso',
|
||||||
// Gera um nome único para o arquivo
|
url: `https://jur-saidaretornoveiculo.s3.sa-east-1.amazonaws.com/${file.filename}`,
|
||||||
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1e9);
|
licensePlate,
|
||||||
const fileExtName = extname(file.originalname);
|
};
|
||||||
callback(null, `${file.fieldname}-${uniqueSuffix}${fileExtName}`);
|
}
|
||||||
},
|
|
||||||
}),
|
|
||||||
// Opcional: definir limites (ex.: tamanho máximo do arquivo)
|
|
||||||
limits: { fileSize: 5 * 1024 * 1024 }, // 5MB
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
async sendImage(
|
|
||||||
@UploadedFile() file: Express.Multer.File,
|
|
||||||
@Body('licensePlate') licensePlate: string,
|
|
||||||
) {
|
|
||||||
if (!file) {
|
|
||||||
throw new HttpException('Nenhum arquivo enviado', HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aqui você pode processar o arquivo (ex.: enviar para o S3) ou armazená-lo no disco mesmo.
|
|
||||||
// Neste exemplo, retornamos a URL do arquivo salvo localmente.
|
|
||||||
this.baseService.sendImages('./uploads/'+file.filename);
|
|
||||||
fs.unlink('./uploads/'+file.filename, () => {});
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
message: 'Upload realizado com sucesso',
|
|
||||||
url: `https://jur-saidaretornoveiculo.s3.sa-east-1.amazonaws.com/${file.filename}`,
|
|
||||||
licensePlate,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ import { Module } from '@nestjs/common';
|
|||||||
import { BaseService } from './base.service';
|
import { BaseService } from './base.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [],
|
imports: [],
|
||||||
controllers: [
|
controllers: [BaseController],
|
||||||
BaseController,],
|
providers: [BaseService],
|
||||||
providers: [BaseService,],
|
|
||||||
})
|
})
|
||||||
export class BaseModule { }
|
export class BaseModule {}
|
||||||
|
|||||||
@@ -1,289 +1,331 @@
|
|||||||
import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common';
|
import {
|
||||||
|
Inject,
|
||||||
|
Injectable,
|
||||||
|
InternalServerErrorException,
|
||||||
|
} from '@nestjs/common';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import { typeOrmConfig } from '../configs/typeorm.config';
|
import { typeOrmConfig } from '../configs/typeorm.config';
|
||||||
import { S3 } from 'aws-sdk';
|
import { S3 } from 'aws-sdk';
|
||||||
import * as fs from "fs";
|
import * as fs from 'fs';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BaseService {
|
export class BaseService {
|
||||||
constructor() { }
|
constructor() {}
|
||||||
|
|
||||||
async findAll(table: string) {
|
async findAll(table: string) {
|
||||||
const dataSource = new DataSource(typeOrmConfig);
|
const dataSource = new DataSource(typeOrmConfig);
|
||||||
await dataSource.initialize();
|
await dataSource.initialize();
|
||||||
const queryRunner = dataSource.createQueryRunner();
|
const queryRunner = dataSource.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
const [rows] = await queryRunner.query(`SELECT * FROM ${table}`);
|
const [rows] = await queryRunner.query(`SELECT * FROM ${table}`);
|
||||||
return rows;
|
return rows;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.handleDatabaseError(error, `Erro ao buscar todos os registros da tabela ${table}`);
|
this.handleDatabaseError(
|
||||||
} finally {
|
error,
|
||||||
queryRunner.release();
|
`Erro ao buscar todos os registros da tabela ${table}`,
|
||||||
dataSource.destroy();
|
);
|
||||||
}
|
} finally {
|
||||||
|
queryRunner.release();
|
||||||
|
dataSource.destroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async findOne(table: string, id: any) {
|
async findOne(table: string, id: any) {
|
||||||
const dataSource = new DataSource(typeOrmConfig);
|
const dataSource = new DataSource(typeOrmConfig);
|
||||||
await dataSource.initialize();
|
await dataSource.initialize();
|
||||||
const queryRunner = dataSource.createQueryRunner();
|
const queryRunner = dataSource.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
const [rows] = await queryRunner.query(`SELECT * FROM ${table} WHERE id = '${id}'`);
|
const [rows] = await queryRunner.query(
|
||||||
return rows[0];
|
`SELECT * FROM ${table} WHERE id = '${id}'`,
|
||||||
} catch (error) {
|
);
|
||||||
this.handleDatabaseError(error, `Erro ao buscar o registro com ID ${id} na tabela ${table}`);
|
return rows[0];
|
||||||
} finally {
|
} catch (error) {
|
||||||
queryRunner.release();
|
this.handleDatabaseError(
|
||||||
dataSource.destroy();
|
error,
|
||||||
}
|
`Erro ao buscar o registro com ID ${id} na tabela ${table}`,
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
queryRunner.release();
|
||||||
|
dataSource.destroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async create(table: string, data: any) {
|
async create(table: string, data: any) {
|
||||||
const dataSource = new DataSource(typeOrmConfig);
|
const dataSource = new DataSource(typeOrmConfig);
|
||||||
await dataSource.initialize();
|
await dataSource.initialize();
|
||||||
const queryRunner = dataSource.createQueryRunner();
|
const queryRunner = dataSource.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
const columns = Object.keys(data).map((key) => `${key}`).join(', ');
|
const columns = Object.keys(data)
|
||||||
const values = Object.values(data);
|
.map((key) => `${key}`)
|
||||||
const placeholders = values.map(() => '?').join(', ');
|
.join(', ');
|
||||||
|
const values = Object.values(data);
|
||||||
|
const placeholders = values.map(() => '?').join(', ');
|
||||||
|
|
||||||
const query = `INSERT INTO ${table} (${columns}) VALUES (${placeholders})`;
|
const query = `INSERT INTO ${table} (${columns}) VALUES (${placeholders})`;
|
||||||
|
|
||||||
const [result] = await queryRunner.query(query, values);
|
const [result] = await queryRunner.query(query, values);
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.handleDatabaseError(error, `Erro ao criar um registro na tabela ${table}`);
|
this.handleDatabaseError(
|
||||||
} finally {
|
error,
|
||||||
queryRunner.release();
|
`Erro ao criar um registro na tabela ${table}`,
|
||||||
dataSource.destroy();
|
);
|
||||||
}
|
} finally {
|
||||||
|
queryRunner.release();
|
||||||
|
dataSource.destroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async update(table: string, where: any, data: any) {
|
async update(table: string, where: any, data: any) {
|
||||||
const dataSource = new DataSource(typeOrmConfig);
|
const dataSource = new DataSource(typeOrmConfig);
|
||||||
await dataSource.initialize();
|
await dataSource.initialize();
|
||||||
const queryRunner = dataSource.createQueryRunner();
|
const queryRunner = dataSource.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
const [result] = await queryRunner.query(`UPDATE ${table} SET ${data} WHERE ${where}`);
|
const [result] = await queryRunner.query(
|
||||||
return result;
|
`UPDATE ${table} SET ${data} WHERE ${where}`,
|
||||||
} catch (error) {
|
);
|
||||||
this.handleDatabaseError(error, `Erro ao atualizar o registro com ${where} na tabela ${table}`);
|
return result;
|
||||||
} finally {
|
} catch (error) {
|
||||||
queryRunner.release();
|
this.handleDatabaseError(
|
||||||
dataSource.destroy();
|
error,
|
||||||
}
|
`Erro ao atualizar o registro com ${where} na tabela ${table}`,
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
queryRunner.release();
|
||||||
|
dataSource.destroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async delete(table: string, where: any) {
|
async delete(table: string, where: any) {
|
||||||
const dataSource = new DataSource(typeOrmConfig);
|
const dataSource = new DataSource(typeOrmConfig);
|
||||||
await dataSource.initialize();
|
await dataSource.initialize();
|
||||||
const queryRunner = dataSource.createQueryRunner();
|
const queryRunner = dataSource.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
const [result] = await queryRunner.query(`DELETE FROM ${table} WHERE ${where}`);
|
const [result] = await queryRunner.query(
|
||||||
return result;
|
`DELETE FROM ${table} WHERE ${where}`,
|
||||||
} catch (error) {
|
);
|
||||||
this.handleDatabaseError(error, `Erro ao deletar o registro com ID ${where} na tabela ${table}`);
|
return result;
|
||||||
} finally {
|
} catch (error) {
|
||||||
queryRunner.release();
|
this.handleDatabaseError(
|
||||||
dataSource.destroy();
|
error,
|
||||||
}
|
`Erro ao deletar o registro com ID ${where} na tabela ${table}`,
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
queryRunner.release();
|
||||||
|
dataSource.destroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async query(queryString: string, params: any[]): Promise<any[]> {
|
async query(queryString: string, params: any[]): Promise<any[]> {
|
||||||
const dataSource = new DataSource(typeOrmConfig);
|
const dataSource = new DataSource(typeOrmConfig);
|
||||||
await dataSource.initialize();
|
await dataSource.initialize();
|
||||||
const queryRunner = dataSource.createQueryRunner();
|
const queryRunner = dataSource.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
const [rows] = await queryRunner.query(queryString, params);
|
const [rows] = await queryRunner.query(queryString, params);
|
||||||
return rows as any[];
|
return rows as any[];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.handleDatabaseError(error, `Erro ao executar a consulta SQL personalizada`);
|
this.handleDatabaseError(
|
||||||
} finally {
|
error,
|
||||||
queryRunner.release();
|
`Erro ao executar a consulta SQL personalizada`,
|
||||||
dataSource.destroy();
|
);
|
||||||
}
|
} finally {
|
||||||
|
queryRunner.release();
|
||||||
|
dataSource.destroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async executeView(viewName: string, params: Record<string, any>) {
|
async executeView(viewName: string, params: Record<string, any>) {
|
||||||
const dataSource = new DataSource(typeOrmConfig);
|
const dataSource = new DataSource(typeOrmConfig);
|
||||||
await dataSource.initialize();
|
await dataSource.initialize();
|
||||||
const queryRunner = dataSource.createQueryRunner();
|
const queryRunner = dataSource.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
// Valida se o nome da view foi fornecido
|
// Valida se o nome da view foi fornecido
|
||||||
if (!viewName) {
|
if (!viewName) {
|
||||||
throw new Error('O nome da view é obrigatório.');
|
throw new Error('O nome da view é obrigatório.');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Iniciando execução da view: ${viewName}`);
|
console.log(`Iniciando execução da view: ${viewName}`);
|
||||||
console.log('Parâmetros recebidos:', params);
|
console.log('Parâmetros recebidos:', params);
|
||||||
|
|
||||||
const conditions: string[] = [];
|
const conditions: string[] = [];
|
||||||
const values: any[] = [];
|
const values: any[] = [];
|
||||||
|
|
||||||
// Remove o parâmetro viewName dos parâmetros antes de processar
|
// Remove o parâmetro viewName dos parâmetros antes de processar
|
||||||
const filteredParams = { ...params };
|
const filteredParams = { ...params };
|
||||||
delete filteredParams.viewName;
|
delete filteredParams.viewName;
|
||||||
|
|
||||||
// Adiciona as condições baseadas nos parâmetros fornecidos
|
// Adiciona as condições baseadas nos parâmetros fornecidos
|
||||||
if (filteredParams && Object.keys(filteredParams).length > 0) {
|
if (filteredParams && Object.keys(filteredParams).length > 0) {
|
||||||
console.log('Adicionando condições para os parâmetros fornecidos...');
|
console.log('Adicionando condições para os parâmetros fornecidos...');
|
||||||
for (const [key, value] of Object.entries(filteredParams)) {
|
for (const [key, value] of Object.entries(filteredParams)) {
|
||||||
// Verifica se a chave e o valor são válidos
|
// Verifica se a chave e o valor são válidos
|
||||||
if (value !== undefined && value !== null && value !== '') {
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
console.log(`Parâmetro válido: ${key} = '${value}'`);
|
console.log(`Parâmetro válido: ${key} = '${value}'`);
|
||||||
conditions.push(`${key} = '${value}'`); // Adiciona aspas para evitar problemas de SQL injection
|
conditions.push(`${key} = '${value}'`); // Adiciona aspas para evitar problemas de SQL injection
|
||||||
values.push(value);
|
values.push(value);
|
||||||
} else {
|
} else {
|
||||||
console.warn(`Parâmetro ignorado: ${key} = '${value}'`);
|
console.warn(`Parâmetro ignorado: ${key} = '${value}'`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Nenhum parâmetro válido foi fornecido.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monta a cláusula WHERE somente se houver condições
|
||||||
|
const whereClause =
|
||||||
|
conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
|
||||||
|
const query = `SELECT * FROM ${viewName} ${whereClause}`;
|
||||||
|
|
||||||
|
console.log(`Consulta SQL montada: ${query}`);
|
||||||
|
console.log(`{Valores para a consulta:, ${values}`);
|
||||||
|
|
||||||
|
// Executa a consulta
|
||||||
|
const rows = await queryRunner.query(query);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`Consulta executada com sucesso.Linhas retornadas: ${JSON.stringify(
|
||||||
|
rows,
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
|
return rows;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Erro ao executar a view ${viewName}: `, error.message);
|
||||||
|
this.handleDatabaseError(
|
||||||
|
error,
|
||||||
|
`Erro ao executar a view ${viewName} com parâmetros.`,
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await queryRunner.release();
|
||||||
|
await dataSource.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async executeProcedure(procedureName: string, params: Record<string, any>) {
|
||||||
|
const dataSource = new DataSource(typeOrmConfig);
|
||||||
|
await dataSource.initialize();
|
||||||
|
const queryRunner = dataSource.createQueryRunner();
|
||||||
|
await queryRunner.connect();
|
||||||
|
await queryRunner.startTransaction();
|
||||||
|
try {
|
||||||
|
const placeholders = Object.keys(params)
|
||||||
|
.map(() => '?')
|
||||||
|
.join(', ');
|
||||||
|
const values = Object.values(params);
|
||||||
|
|
||||||
|
const query = `EXECUTE IMMEDIATE ${procedureName}(${placeholders})`;
|
||||||
|
|
||||||
|
// Log da query e dos valores
|
||||||
|
console.log('Query executada:', query);
|
||||||
|
console.log('Valores:', values);
|
||||||
|
|
||||||
|
const [result] = await queryRunner.query(query, values);
|
||||||
|
|
||||||
|
// Verifica e converte campos que contenham JSON strings para objetos
|
||||||
|
const parsedResult = Array.isArray(result)
|
||||||
|
? result.map((row) => {
|
||||||
|
const parsedRow = { ...row };
|
||||||
|
for (const [key, value] of Object.entries(parsedRow)) {
|
||||||
|
try {
|
||||||
|
// Tenta converter strings JSON para objetos
|
||||||
|
if (
|
||||||
|
typeof value === 'string' &&
|
||||||
|
value.trim().startsWith('{') &&
|
||||||
|
value.trim().endsWith('}')
|
||||||
|
) {
|
||||||
|
parsedRow[key] = JSON.parse(value);
|
||||||
}
|
}
|
||||||
} else {
|
} catch (error) {
|
||||||
console.log('Nenhum parâmetro válido foi fornecido.');
|
// Ignora se a conversão falhar
|
||||||
|
console.warn(
|
||||||
|
`Campo ${key} não é um JSON válido.Mantendo como string.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return parsedRow;
|
||||||
|
})
|
||||||
|
: result;
|
||||||
|
|
||||||
// Monta a cláusula WHERE somente se houver condições
|
// Retorna os valores e o resultado
|
||||||
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
|
return {
|
||||||
const query = `SELECT * FROM ${ viewName } ${whereClause}`;
|
message: 'Procedure executada com sucesso.',
|
||||||
|
executedQuery: query,
|
||||||
|
values: values,
|
||||||
|
result: parsedResult,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
this.handleDatabaseError(
|
||||||
|
error,
|
||||||
|
`Erro ao executar a procedure ${procedureName} com parâmetros.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`Consulta SQL montada: ${ query }`);
|
private handleDatabaseError(error: any, message: string): never {
|
||||||
console.log(`{Valores para a consulta:, ${values}`);
|
console.error(message, error); // Log detalhado do erro
|
||||||
|
throw new InternalServerErrorException({
|
||||||
|
message,
|
||||||
|
sqlMessage: error.sqlMessage || error.message,
|
||||||
|
sqlState: error.sqlState,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Executa a consulta
|
async sendImages(file: string) {
|
||||||
const rows = await queryRunner.query(query);
|
// for (const file of files) {
|
||||||
|
// const file = 'C:\\Temp\\brasil_2.jpg'
|
||||||
console.log(`Consulta executada com sucesso.Linhas retornadas: ${ JSON.stringify(rows) }`);
|
if (file.endsWith('.jpg')) {
|
||||||
return rows;
|
const fileName = file; //directoryImages + '\\' + file;
|
||||||
} catch (error) {
|
fs.readFile(fileName, (err, data) => {
|
||||||
console.error(`Erro ao executar a view ${ viewName }: `, error.message);
|
if (err) throw err;
|
||||||
this.handleDatabaseError(
|
if (err) {
|
||||||
error,
|
console.log(`WRITE ERROR: ${err}`);
|
||||||
`Erro ao executar a view ${ viewName } com parâmetros.`,
|
} else {
|
||||||
);
|
this.uploadS3(
|
||||||
} finally {
|
data,
|
||||||
await queryRunner.release();
|
'jur-saidaretornoveiculo',
|
||||||
await dataSource.destroy();
|
file.replace('./uploads/', ''),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
async executeProcedure(procedureName: string, params: Record<string, any>) {
|
async uploadS3(file, bucket, name) {
|
||||||
const dataSource = new DataSource(typeOrmConfig);
|
const s3 = this.getS3();
|
||||||
await dataSource.initialize();
|
const params = {
|
||||||
const queryRunner = dataSource.createQueryRunner();
|
Bucket: bucket,
|
||||||
await queryRunner.connect();
|
Key: String(name),
|
||||||
await queryRunner.startTransaction();
|
Body: file,
|
||||||
try {
|
};
|
||||||
const placeholders = Object.keys(params)
|
return new Promise((resolve, reject) => {
|
||||||
.map(() => '?')
|
s3.upload(params, (err, data) => {
|
||||||
.join(', ');
|
if (err) {
|
||||||
const values = Object.values(params);
|
console.log(JSON.stringify(err));
|
||||||
|
reject(err.message);
|
||||||
const query = `EXECUTE IMMEDIATE ${ procedureName }(${ placeholders })`;
|
|
||||||
|
|
||||||
// Log da query e dos valores
|
|
||||||
console.log('Query executada:', query);
|
|
||||||
console.log('Valores:', values);
|
|
||||||
|
|
||||||
const [result] = await queryRunner.query(query, values);
|
|
||||||
|
|
||||||
// Verifica e converte campos que contenham JSON strings para objetos
|
|
||||||
const parsedResult = Array.isArray(result)
|
|
||||||
? result.map((row) => {
|
|
||||||
const parsedRow = { ...row };
|
|
||||||
for (const [key, value] of Object.entries(parsedRow)) {
|
|
||||||
try {
|
|
||||||
// Tenta converter strings JSON para objetos
|
|
||||||
if (typeof value === 'string' && value.trim().startsWith('{') && value.trim().endsWith('}')) {
|
|
||||||
parsedRow[key] = JSON.parse(value);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
// Ignora se a conversão falhar
|
|
||||||
console.warn(`Campo ${ key } não é um JSON válido.Mantendo como string.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return parsedRow;
|
|
||||||
})
|
|
||||||
: result;
|
|
||||||
|
|
||||||
// Retorna os valores e o resultado
|
|
||||||
return {
|
|
||||||
message: 'Procedure executada com sucesso.',
|
|
||||||
executedQuery: query,
|
|
||||||
values: values,
|
|
||||||
result: parsedResult,
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
this.handleDatabaseError(
|
|
||||||
error,
|
|
||||||
`Erro ao executar a procedure ${ procedureName } com parâmetros.`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
resolve(data);
|
||||||
|
});
|
||||||
private handleDatabaseError(error: any, message: string): never {
|
});
|
||||||
console.error(message, error); // Log detalhado do erro
|
}
|
||||||
throw new InternalServerErrorException({
|
|
||||||
message,
|
|
||||||
sqlMessage: error.sqlMessage || error.message,
|
|
||||||
sqlState: error.sqlState,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async sendImages(file: string) {
|
|
||||||
// for (const file of files) {
|
|
||||||
// const file = 'C:\\Temp\\brasil_2.jpg'
|
|
||||||
if (file.endsWith(".jpg")) {
|
|
||||||
const fileName = file; //directoryImages + '\\' + file;
|
|
||||||
fs.readFile(fileName, (err, data) => {
|
|
||||||
if (err) throw err;
|
|
||||||
if (err) {
|
|
||||||
console.log(`WRITE ERROR: ${err}`);
|
|
||||||
} else {
|
|
||||||
this.uploadS3(data, 'jur-saidaretornoveiculo', file.replace('./uploads/', ''));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
async uploadS3(file, bucket, name) {
|
|
||||||
const s3 = this.getS3();
|
|
||||||
const params = {
|
|
||||||
Bucket: bucket,
|
|
||||||
Key: String(name),
|
|
||||||
Body: file,
|
|
||||||
|
|
||||||
};
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
s3.upload(params, (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
console.log(JSON.stringify(err));
|
|
||||||
reject(err.message);
|
|
||||||
}
|
|
||||||
resolve(data);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getS3() {
|
|
||||||
return new S3({
|
|
||||||
accessKeyId: "AKIAVHJOO6W765ZT2PNI", //process.env.AWS_ACCESS_KEY_ID,
|
|
||||||
secretAccessKey: "IFtP6Foc7JlE6TfR3psBAERUCMlH+4cRMx0GVIx2", // process.env.AWS_SECRET_ACCESS_KEY,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
getS3() {
|
||||||
|
return new S3({
|
||||||
|
accessKeyId: 'AKIAVHJOO6W765ZT2PNI', //process.env.AWS_ACCESS_KEY_ID,
|
||||||
|
secretAccessKey: 'IFtP6Foc7JlE6TfR3psBAERUCMlH+4cRMx0GVIx2', // process.env.AWS_SECRET_ACCESS_KEY,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ https://docs.nestjs.com/providers#services
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { typeOrmConfig } from 'src/core/configs/typeorm.config';
|
import { typeOrmConfig } from '../core/configs/typeorm.config';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ https://docs.nestjs.com/controllers#controllers
|
|||||||
|
|
||||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||||
import { LogisticService } from './logistic.service';
|
import { LogisticService } from './logistic.service';
|
||||||
import { CarOutDelivery } from 'src/core/models/car-out-delivery.model';
|
import { CarOutDelivery } from '../core/models/car-out-delivery.model';
|
||||||
import { CarInDelivery } from 'src/core/models/car-in-delivery.model';
|
import { CarInDelivery } from '../core/models/car-in-delivery.model';
|
||||||
|
|
||||||
@Controller('api/v1/logistic')
|
@Controller('api/v1/logistic')
|
||||||
export class LogisticController {
|
export class LogisticController {
|
||||||
|
|||||||
@@ -1,16 +1,8 @@
|
|||||||
import { Length } from './../../node_modules/aws-sdk/clients/quicksight.d';
|
|
||||||
import { count } from './../../node_modules/aws-sdk/clients/health.d';
|
|
||||||
/* eslint-disable prettier/prettier */
|
|
||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
||||||
|
|
||||||
|
|
||||||
import { Get, HttpException, HttpStatus, Injectable, Query, UseGuards } from '@nestjs/common';
|
import { Get, HttpException, HttpStatus, Injectable, Query, UseGuards } from '@nestjs/common';
|
||||||
import { stringify } from 'querystring';
|
import { typeOrmConfig, typeOrmPgConfig } from '../core/configs/typeorm.config';
|
||||||
import { typeOrmConfig, typeOrmPgConfig } from 'src/core/configs/typeorm.config';
|
import { CarOutDelivery } from '../core/models/car-out-delivery.model';
|
||||||
import { CarOutDelivery } from 'src/core/models/car-out-delivery.model';
|
|
||||||
import { BaseService } from 'src/core/services/base.service';
|
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import { CarInDelivery } from 'src/core/models/car-in-delivery.model';
|
import { CarInDelivery } from '../core/models/car-in-delivery.model';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LogisticService {
|
export class LogisticService {
|
||||||
@@ -205,13 +197,13 @@ export class LogisticService {
|
|||||||
const sqlSequence = `SELECT ESS_SAIDAVEICULO.NEXTVAL as "id" FROM DUAL`;
|
const sqlSequence = `SELECT ESS_SAIDAVEICULO.NEXTVAL as "id" FROM DUAL`;
|
||||||
const dataSequence = await queryRunner.query(sqlSequence);
|
const dataSequence = await queryRunner.query(sqlSequence);
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let helperId1: number = 0;
|
let helperId1 = 0;
|
||||||
let helperId2: number = 0;
|
let helperId2 = 0;
|
||||||
let helperId3: number = 0;
|
let helperId3 = 0;
|
||||||
let image1: string = '';
|
const image1 = '';
|
||||||
let image2: string = '';
|
const image2 = '';
|
||||||
let image3: string = '';
|
const image3 = '';
|
||||||
let image4: string = '';
|
const image4 = '';
|
||||||
|
|
||||||
data.helpers.forEach(helper => {
|
data.helpers.forEach(helper => {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
@@ -290,11 +282,11 @@ export class LogisticService {
|
|||||||
throw new HttpException('Não foi localiza viagens em aberto para este veículo.', HttpStatus.BAD_REQUEST );
|
throw new HttpException('Não foi localiza viagens em aberto para este veículo.', HttpStatus.BAD_REQUEST );
|
||||||
}
|
}
|
||||||
|
|
||||||
let i = 0;
|
const i = 0;
|
||||||
let image1: string = '';
|
const image1 = '';
|
||||||
let image2: string = '';
|
const image2 = '';
|
||||||
let image3: string = '';
|
const image3 = '';
|
||||||
let image4: string = '';
|
const image4 = '';
|
||||||
|
|
||||||
for (let y = 0; y < data.invoices.length; y++) {
|
for (let y = 0; y < data.invoices.length; y++) {
|
||||||
const invoice = data.invoices[y];
|
const invoice = data.invoices[y];
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ https://docs.nestjs.com/providers#services
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { typeOrmConfig } from 'src/core/configs/typeorm.config';
|
import { typeOrmConfig } from '../core/configs/typeorm.config';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ https://docs.nestjs.com/providers#services
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
import { typeOrmConfig } from 'src/core/configs/typeorm.config';
|
import { typeOrmConfig } from '../core/configs/typeorm.config';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ https://docs.nestjs.com/controllers#controllers
|
|||||||
|
|
||||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||||
import { ProductsService } from './products.service';
|
import { ProductsService } from './products.service';
|
||||||
import { ExposedProduct } from 'src/core/models/exposed-product.model';
|
import { ExposedProduct } from '../core/models/exposed-product.model';
|
||||||
|
|
||||||
@Controller('api/v1/products')
|
@Controller('api/v1/products')
|
||||||
export class ProductsController {
|
export class ProductsController {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ https://docs.nestjs.com/providers#services
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
import { typeOrmConfig } from 'src/core/configs/typeorm.config';
|
import { typeOrmConfig } from '../core/configs/typeorm.config';
|
||||||
import { ExposedProduct } from 'src/core/models/exposed-product.model';
|
import { ExposedProduct } from '../core/models/exposed-product.model';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { INestApplication } from '@nestjs/common';
|
import { INestApplication } from '@nestjs/common';
|
||||||
import * as request from 'supertest';
|
import * as request from 'supertest';
|
||||||
import { AppModule } from './../src/app.module';
|
import { AppModule } from './../../../app.module';
|
||||||
|
|
||||||
describe('AppController (e2e)', () => {
|
describe('AppController (e2e)', () => {
|
||||||
let app: INestApplication;
|
let app: INestApplication;
|
||||||
|
|||||||
Reference in New Issue
Block a user