Feature/1 add projects and about pages (#2)

* adding api

* adding projects page

* adding project page

* updating terraform

* updating terraform

* adding github workflows
This commit was merged in pull request #2.
This commit is contained in:
2025-02-23 20:45:04 +00:00
committed by GitHub
parent 2d9cd07358
commit 6deca4c7ea
95 changed files with 14643 additions and 1500 deletions

View File

@@ -0,0 +1,94 @@
import {
Body,
Controller,
Delete,
Get,
HttpException,
Param,
Post,
Put,
UseGuards
} from '@nestjs/common';
import { ProjectDto } from './project.dto';
import { Project } from './project.entity';
import { ProjectService } from './project.service';
import { CustomError, Public } from '@noahspan/noahspan-modules';
@Controller('projects')
export class ProjectController {
constructor(private readonly projectService: ProjectService) {}
@Get(':partitionKey/:rowKey')
async find(
@Param('partitionKey') partitionKey: string,
@Param('rowKey') rowKey: string
) {
try {
return await this.projectService.find(partitionKey, rowKey);
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
@Public()
@Get()
async findAll() {
try {
return await this.projectService.findAll();
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
@Post()
async create(@Body() projectDto: ProjectDto) {
try {
const project = new Project();
Object.assign(project, projectDto);
return await this.projectService.create(project);
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
@Put(':partitionKey/:rowKey')
async update(
@Param('partitionKey') partitionKey: string,
@Param('rowKey') rowKey: string,
@Body() projectDto: ProjectDto
) {
try {
const project = new Project();
Object.assign(project, projectDto);
return await this.projectService.update(partitionKey, rowKey, project);
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
@Delete(':partitionKey/:rowKey')
async delete(
@Param('partitionKey') partitionKey: string,
@Param('rowKey') rowKey: string
) {
try {
return await this.projectService.delete(partitionKey, rowKey);
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
}