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:
Mathis H (Avnyr) 2024-09-23 12:08:38 +02:00
parent 1881a7e6c4
commit 44b783561b
Signed by: Mathis
GPG Key ID: DD9E0666A747D126
5 changed files with 92 additions and 0 deletions

View 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();
});
});

View 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}
}
}

View 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 {}

View 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();
});
});

View File

@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AuthorService {}