Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"
FRONTEND_HOST="http://localhost:3000"
3 changes: 1 addition & 2 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@nestjs/core": "^10.3.8",
"@nestjs/platform-express": "^10.3.8",
"@nestjs/swagger": "^7.3.1",
"@prisma/client": "^5.18.0",
"@prisma/client": "^5.13.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"nestjs-prisma": "^0.23.0",
Expand All @@ -35,7 +35,6 @@
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"prisma": "^5.18.0",
"source-map-support": "^0.5.21",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
Expand Down
7 changes: 0 additions & 7 deletions apps/backend/src/event/entity/event.details.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/backend/src/event/entity/event.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class Event {
color: Color;

@IsNotEmpty()
@IsEnum(Status)
status: Status;

@IsString()
Expand Down
29 changes: 4 additions & 25 deletions apps/backend/src/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,19 @@ import { PrismaService } from 'nestjs-prisma';

import { CreateEventDto } from './dto/create-event.dto';
import { UpdateEventDto } from './dto/update-event.dto';
import { EventDetailsDto } from './entity/event.details';
import { Event } from './entity/event.entity';

@Injectable()
export class EventService {
constructor(private readonly prisma: PrismaService) {}

async create(data: CreateEventDto): Promise<Event> {
const { ownerId, ...restOfData } = data;
try {
return await this.prisma.event.create({
data: {
...restOfData,
owner: {
connect: {
authSchId: ownerId,
},
},
},
});
return await this.prisma.event.create({ data });
} catch (error) {
if (error instanceof PrismaClientValidationError) {
throw new BadRequestException(`Invalid data`);
}
if (error instanceof PrismaClientKnownRequestError) {
if (error.code === 'P2002') throw new BadRequestException(`Invalid data: user not found`);
}
throw error;
}
}
Expand All @@ -39,15 +25,9 @@ export class EventService {
return this.prisma.event.findMany();
}

async findOne(id: string): Promise<EventDetailsDto> {
async findOne(id: string): Promise<Event> {
try {
return await this.prisma.event.findUnique({
where: { id },
include: {
owner: true,
organizers: true,
},
});
return await this.prisma.event.findUnique({ where: { id } });
} catch {
throw new NotFoundException(`Event not found`);
}
Expand All @@ -58,8 +38,7 @@ export class EventService {
return await this.prisma.event.update({ where: { id }, data });
} catch (error) {
if (error instanceof PrismaClientKnownRequestError) {
if (error.code === 'P2002') throw new BadRequestException(`Invalid data: user not found`);
if (error.code === 'P2025') throw new NotFoundException(`Event not found`);
throw new NotFoundException(`Event not found`);
}
if (error instanceof PrismaClientValidationError) {
throw new BadRequestException(`Invalid data`);
Expand Down
7 changes: 0 additions & 7 deletions apps/backend/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import cors from 'cors';

import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
app.use(
cors({
origin: process.env.FRONTEND_HOST,
credentials: true,
})
);
await app.listen(3001);
}
bootstrap();
4 changes: 2 additions & 2 deletions apps/backend/src/users/dto/create-user.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OmitType } from '@nestjs/swagger';

import { UserEntity } from '../entities/user.entity';
import { User } from '../entities/user.entity';

export class CreateUserDto extends OmitType(UserEntity, ['isAdmin']) {}
export class CreateUserDto extends OmitType(User, ['isAdmin']) {}
4 changes: 0 additions & 4 deletions apps/backend/src/users/entities/PublicUser.ts

This file was deleted.

11 changes: 0 additions & 11 deletions apps/backend/src/users/entities/UserDetails.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/backend/src/users/entities/user.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IsBoolean, IsEmail, IsNotEmpty, IsString } from 'class-validator';

export class UserEntity {
export class User {
@IsString()
@IsNotEmpty()
authSchId: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/commo

import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { UserEntity } from './entities/user.entity';
import { User } from './entities/user.entity';
import { UsersService } from './users.service';

@Controller('users')
export class UsersController {
constructor(private readonly usersService: UsersService) {}

@Post()
create(@Body() data: CreateUserDto): Promise<UserEntity> {
create(@Body() data: CreateUserDto): Promise<User> {
return this.usersService.create(data);
}

Expand Down
18 changes: 7 additions & 11 deletions apps/backend/src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,41 @@ import { PrismaService } from 'nestjs-prisma';

import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { UserEntity } from './entities/user.entity';
import { User } from './entities/user.entity';

@Injectable()
export class UsersService {
constructor(private readonly prisma: PrismaService) {}

async create(data: CreateUserDto): Promise<UserEntity> {
async create(data: CreateUserDto): Promise<User> {
try {
return await this.prisma.user.create({ data });
} catch (error) {
if (error instanceof PrismaClientValidationError) {
throw new BadRequestException('Invalid User data');
}
if (error instanceof PrismaClientKnownRequestError) {
if (error.code === 'P2002') throw new BadRequestException(`Invalid User data: email already in use`);
}
throw error;
}
}

async findAll(): Promise<UserEntity[]> {
async findAll(): Promise<User[]> {
return this.prisma.user.findMany();
}

async findOne(id: string): Promise<UserEntity> {
async findOne(id: string): Promise<User> {
const user = await this.prisma.user.findUnique({ where: { authSchId: id } });
if (user === null) {
throw new NotFoundException('User not found');
}
return user;
}

async update(id: string, data: UpdateUserDto): Promise<UserEntity> {
async update(id: string, data: UpdateUserDto): Promise<User> {
try {
return await this.prisma.user.update({ where: { authSchId: id }, data });
} catch (error) {
if (error instanceof PrismaClientKnownRequestError) {
if (error.code === 'P2002') throw new BadRequestException(`Invalid data: email already in use`);
if (error.code === 'P2025') throw new NotFoundException(`User not found`);
throw new NotFoundException(`User not found`);
}
if (error instanceof PrismaClientValidationError) {
throw new BadRequestException(`Invalid data`);
Expand All @@ -51,7 +47,7 @@ export class UsersService {
}
}

async delete(id: string): Promise<UserEntity> {
async delete(id: string): Promise<User> {
try {
return await this.prisma.user.delete({ where: { authSchId: id } });
} catch {
Expand Down
10 changes: 2 additions & 8 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,22 @@
"lint": "next lint"
},
"dependencies": {
"@tanstack/react-query": "^5.51.15",
"@tanstack/react-query-devtools": "^5.51.23",
"axios": "^1.7.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.372.0",
"next": "14.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.52.2",
"react-icons": "^5.2.1",
"react-router-dom": "^6.25.1",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@types/node": "^20.12.7",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"eslint-plugin-react": "^7.34.1",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"eslint-plugin-react": "^7.34.1"
}
}
12 changes: 0 additions & 12 deletions apps/frontend/src/api/hooks/eventMutationHooks.ts

This file was deleted.

13 changes: 0 additions & 13 deletions apps/frontend/src/api/hooks/eventQueryHooks.ts

This file was deleted.

5 changes: 0 additions & 5 deletions apps/frontend/src/api/model/comment.model.ts

This file was deleted.

38 changes: 0 additions & 38 deletions apps/frontend/src/api/model/event.model.ts

This file was deleted.

3 changes: 0 additions & 3 deletions apps/frontend/src/api/model/organizer.model.ts

This file was deleted.

3 changes: 0 additions & 3 deletions apps/frontend/src/api/model/owner.model.ts

This file was deleted.

Loading