installed typeorm and added initial merchant resource
This commit is contained in:
parent
746adcd2fd
commit
ccc6540ae8
15 changed files with 1972 additions and 321 deletions
1
src/merchants/dto/create-merchant.dto.ts
Normal file
1
src/merchants/dto/create-merchant.dto.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export class CreateMerchantDto {}
|
||||
4
src/merchants/dto/update-merchant.dto.ts
Normal file
4
src/merchants/dto/update-merchant.dto.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateMerchantDto } from './create-merchant.dto';
|
||||
|
||||
export class UpdateMerchantDto extends PartialType(CreateMerchantDto) {}
|
||||
1
src/merchants/entities/merchant.entity.ts
Normal file
1
src/merchants/entities/merchant.entity.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export class Merchant {}
|
||||
20
src/merchants/merchants.controller.spec.ts
Normal file
20
src/merchants/merchants.controller.spec.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { MerchantsController } from './merchants.controller';
|
||||
import { MerchantsService } from './merchants.service';
|
||||
|
||||
describe('MerchantsController', () => {
|
||||
let controller: MerchantsController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [MerchantsController],
|
||||
providers: [MerchantsService]
|
||||
}).compile();
|
||||
|
||||
controller = module.get<MerchantsController>(MerchantsController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
34
src/merchants/merchants.controller.ts
Normal file
34
src/merchants/merchants.controller.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { MerchantsService } from './merchants.service';
|
||||
import { CreateMerchantDto } from './dto/create-merchant.dto';
|
||||
import { UpdateMerchantDto } from './dto/update-merchant.dto';
|
||||
|
||||
@Controller('merchants')
|
||||
export class MerchantsController {
|
||||
constructor(private readonly merchantsService: MerchantsService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createMerchantDto: CreateMerchantDto) {
|
||||
return this.merchantsService.create(createMerchantDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.merchantsService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.merchantsService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateMerchantDto: UpdateMerchantDto) {
|
||||
return this.merchantsService.update(+id, updateMerchantDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.merchantsService.remove(+id);
|
||||
}
|
||||
}
|
||||
9
src/merchants/merchants.module.ts
Normal file
9
src/merchants/merchants.module.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { MerchantsService } from './merchants.service';
|
||||
import { MerchantsController } from './merchants.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [MerchantsController],
|
||||
providers: [MerchantsService]
|
||||
})
|
||||
export class MerchantsModule {}
|
||||
18
src/merchants/merchants.service.spec.ts
Normal file
18
src/merchants/merchants.service.spec.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { MerchantsService } from './merchants.service';
|
||||
|
||||
describe('MerchantsService', () => {
|
||||
let service: MerchantsService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [MerchantsService]
|
||||
}).compile();
|
||||
|
||||
service = module.get<MerchantsService>(MerchantsService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
26
src/merchants/merchants.service.ts
Normal file
26
src/merchants/merchants.service.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateMerchantDto } from './dto/create-merchant.dto';
|
||||
import { UpdateMerchantDto } from './dto/update-merchant.dto';
|
||||
|
||||
@Injectable()
|
||||
export class MerchantsService {
|
||||
create(createMerchantDto: CreateMerchantDto) {
|
||||
return 'This action adds a new merchant';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all merchants`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} merchant`;
|
||||
}
|
||||
|
||||
update(id: number, updateMerchantDto: UpdateMerchantDto) {
|
||||
return `This action updates a #${id} merchant`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} merchant`;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue