Add Author module with controller and service
This commit introduces a new Author module in the backend application. It includes the AuthorController with basic endpoints and the AuthorService for handling author-related logic. Basic test files for both the controller and the service are also added.
This commit is contained in:
parent
1881a7e6c4
commit
44b783561b
20
apps/backend/src/app/author/author.controller.spec.ts
Normal file
20
apps/backend/src/app/author/author.controller.spec.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AuthorController } from './author.controller';
|
||||||
|
import { AuthorService } from './author.service';
|
||||||
|
|
||||||
|
describe('AuthorController', () => {
|
||||||
|
let controller: AuthorController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [AuthorController],
|
||||||
|
providers: [AuthorService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<AuthorController>(AuthorController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
41
apps/backend/src/app/author/author.controller.ts
Normal file
41
apps/backend/src/app/author/author.controller.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Controller, DefaultValuePipe, Delete, Get, Param, ParseIntPipe, Post, Query } from '@nestjs/common';
|
||||||
|
import { AuthorService } from './author.service';
|
||||||
|
|
||||||
|
@Controller('author')
|
||||||
|
export class AuthorController {
|
||||||
|
constructor(private readonly authorService: AuthorService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findMany(
|
||||||
|
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
||||||
|
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
||||||
|
@Query("search", new DefaultValuePipe("")) search: string
|
||||||
|
) {
|
||||||
|
const query = {limit, offset, search}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//POST a new group
|
||||||
|
@Post("new")
|
||||||
|
async newAuthor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//DELETE a group
|
||||||
|
@Delete(":authorId")
|
||||||
|
async deleteAuthor(@Param('authorId') authorId: string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET files associated to author with limit and offset
|
||||||
|
@Get(":authorId")
|
||||||
|
async getForAuthor(
|
||||||
|
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
||||||
|
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
||||||
|
@Query("search", new DefaultValuePipe("")) search: string,
|
||||||
|
@Param('authorId') authorId: string
|
||||||
|
) {
|
||||||
|
const query = {limit, offset, search}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
9
apps/backend/src/app/author/author.module.ts
Normal file
9
apps/backend/src/app/author/author.module.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { AuthorService } from './author.service';
|
||||||
|
import { AuthorController } from './author.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [AuthorController],
|
||||||
|
providers: [AuthorService],
|
||||||
|
})
|
||||||
|
export class AuthorModule {}
|
18
apps/backend/src/app/author/author.service.spec.ts
Normal file
18
apps/backend/src/app/author/author.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AuthorService } from './author.service';
|
||||||
|
|
||||||
|
describe('AuthorService', () => {
|
||||||
|
let service: AuthorService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [AuthorService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<AuthorService>(AuthorService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
4
apps/backend/src/app/author/author.service.ts
Normal file
4
apps/backend/src/app/author/author.service.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AuthorService {}
|
Loading…
x
Reference in New Issue
Block a user