-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jhonatan David <[email protected]> Co-authored-by: MatheusDubin <[email protected]> Co-authored-by: Lipe <[email protected]> Co-authored-by: Gustavo Clemente <[email protected]> Co-authored-by: kelvinsb <[email protected]> Co-authored-by: Tatiane <[email protected]> Co-authored-by: Sombrio <[email protected]> Co-authored-by: AlbuquerqueRafael <[email protected]> Co-authored-by: Arthur <[email protected]> Co-authored-by: Giovanni Bassi <[email protected]> Co-authored-by: LeoFC97 <[email protected]> Co-authored-by: Rogério Piatek <[email protected]> Co-authored-by: Anderson Rocha <[email protected]> Co-authored-by: Pedro Perrone <[email protected]> Co-authored-by: Kevin Eduard Piske <[email protected]> Co-authored-by: Kevin Eduard Piske <[email protected]> Co-authored-by: Wesley Araujo <[email protected]>
- Loading branch information
1 parent
af6303a
commit 8de74f3
Showing
36 changed files
with
465 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Config } from 'jest'; | ||
|
||
const config: Config = { | ||
moduleFileExtensions: ['js', 'json', 'ts'], | ||
rootDir: 'src', | ||
testRegex: '.*\\.spec\\.ts$', | ||
transform: { | ||
'^.+\\.(t|j)s$': 'ts-jest', | ||
}, | ||
collectCoverageFrom: ['**/*.(t|j)s'], | ||
coverageDirectory: '../coverage', | ||
moduleNameMapper: { | ||
'^src/(.*)$': '<rootDir>/$1', | ||
'^@/(.*)$': '<rootDir>/$1', | ||
'^test/(.*)$': '<rootDir>/../$1', | ||
}, | ||
testEnvironment: 'node', | ||
}; | ||
|
||
export default config; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- CreateTable | ||
CREATE TABLE "partners" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"link" TEXT NOT NULL, | ||
"iconName" TEXT NOT NULL DEFAULT 'Handshake', | ||
"created_at" VARCHAR(32) NOT NULL, | ||
"updated_at" VARCHAR(32), | ||
|
||
CONSTRAINT "partners_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "partners_name_key" ON "partners"("name"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `iconName` on the `partners` table. All the data in the column will be lost. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "partners" DROP COLUMN "iconName"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { PartnersController } from './partners.controller'; | ||
import { PartnersService } from './partners.service'; | ||
import { PrismaService } from '../prisma/prisma.service'; | ||
|
||
describe('PartnersController', () => { | ||
let controller: PartnersController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [PartnersController], | ||
providers: [PartnersService], | ||
}) | ||
.useMocker((token) => { | ||
if (token === PrismaService) { | ||
return { | ||
supplyCategory: { findMany: jest.fn().mockResolvedValue(0) }, | ||
}; | ||
} | ||
}) | ||
.compile(); | ||
|
||
controller = module.get<PartnersController>(PartnersController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Controller, Get, HttpException, Logger } from '@nestjs/common'; | ||
import { PartnersService } from './partners.service'; | ||
import { ServerResponse } from '../utils'; | ||
|
||
@Controller('partners') | ||
export class PartnersController { | ||
private logger = new Logger(PartnersController.name); | ||
|
||
constructor(private readonly partnersService: PartnersService) {} | ||
|
||
@Get('') | ||
async index() { | ||
try { | ||
const data = await this.partnersService.index(); | ||
return new ServerResponse(200, 'Successfully get partners', data); | ||
} catch (err: any) { | ||
this.logger.error(`Failed to get partners: ${err}`); | ||
throw new HttpException(err?.code ?? err?.name ?? `${err}`, 400); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { PartnersService } from './partners.service'; | ||
import { PartnersController } from './partners.controller'; | ||
import { PrismaModule } from '../prisma/prisma.module'; | ||
|
||
@Module({ | ||
imports: [PrismaModule], | ||
providers: [PartnersService], | ||
controllers: [PartnersController], | ||
}) | ||
export class PartnersModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
|
||
import { PartnersService } from './partners.service'; | ||
import { PrismaService } from '../prisma/prisma.service'; | ||
|
||
describe('PartnersService', () => { | ||
let service: PartnersService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [PartnersService], | ||
}) | ||
.useMocker((token) => { | ||
if (token === PrismaService) { | ||
return { | ||
supplyCategory: { findMany: jest.fn().mockResolvedValue(0) }, | ||
}; | ||
} | ||
}) | ||
.compile(); | ||
|
||
service = module.get<PartnersService>(PartnersService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
|
||
import { PrismaService } from '../prisma/prisma.service'; | ||
|
||
@ApiTags('Parceiros') | ||
@Injectable() | ||
export class PartnersService { | ||
constructor(private readonly prismaService: PrismaService) {} | ||
|
||
async index() { | ||
return await this.prismaService.partners.findMany({}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.