Skip to content

Commit

Permalink
Create flow of creation/retrieval of user post-auth (#26)
Browse files Browse the repository at this point in the history
* wip: Adds minimal user creation in DB

* wip: Adds minimal user creation in DB

---------

Co-authored-by: Juliano <jchoi@42sp.org.br>
Co-authored-by: lenzo <lenzo@mail.com>
  • Loading branch information
3 people committed Jun 6, 2023
1 parent 65bc8c0 commit bfddc99
Show file tree
Hide file tree
Showing 20 changed files with 156 additions and 167 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ dist

# TernJS port file
.tern-port

# PostgreSQL directory
postgres/
67 changes: 66 additions & 1 deletion backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^9.0.0",
"@prisma/client": "^4.12.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0"
},
Expand Down
8 changes: 5 additions & 3 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Module } from '@nestjs/common';
import { UsersModule } from './modules/users/users.module';
import { UsersModule } from './users/users.module';
import { PrismaService } from './prisma/prisma.service';
import { PrismaModule } from './prisma/prisma.module';

@Module({
imports: [UsersModule],
imports: [UsersModule, PrismaModule],
controllers: [],
providers: [],
providers: [PrismaService],
})
export class AppModule {}

This file was deleted.

5 changes: 2 additions & 3 deletions backend/src/database/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ enum UserStatus {

model User {
id String @id @default(uuid())
username String @unique
password String
mfaEnabled Boolean
login String @unique
displayName String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
friendships Friendship[] @relation("FriendshipUser")
Expand Down
4 changes: 0 additions & 4 deletions backend/src/modules/users/dto/create-user.dto.ts

This file was deleted.

4 changes: 0 additions & 4 deletions backend/src/modules/users/dto/update-user.dto.ts

This file was deleted.

1 change: 0 additions & 1 deletion backend/src/modules/users/entities/user.entity.ts

This file was deleted.

20 changes: 0 additions & 20 deletions backend/src/modules/users/users.controller.spec.ts

This file was deleted.

42 changes: 0 additions & 42 deletions backend/src/modules/users/users.controller.ts

This file was deleted.

18 changes: 0 additions & 18 deletions backend/src/modules/users/users.service.spec.ts

This file was deleted.

40 changes: 0 additions & 40 deletions backend/src/modules/users/users.service.ts

This file was deleted.

15 changes: 0 additions & 15 deletions backend/src/prisma.service.ts

This file was deleted.

9 changes: 9 additions & 0 deletions backend/src/prisma/prisma.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Global, Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';

@Global()
@Module({
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}
9 changes: 9 additions & 0 deletions backend/src/prisma/prisma.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Injectable } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';

@Injectable()
export class PrismaService extends PrismaClient {
constructor() {
super();
}
}
8 changes: 8 additions & 0 deletions backend/src/users/dto/user.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IsString } from 'class-validator';
export class CreateUserDto {
@IsString()
login: string;

@IsString()
displayName: string;
}
12 changes: 12 additions & 0 deletions backend/src/users/users.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Controller, Get, Body } from '@nestjs/common';
import { UsersService } from './users.service';

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

@Get('me')
findMe(@Body() dto: any) {
return this.service.findMe(dto);
}
}
Loading

0 comments on commit bfddc99

Please sign in to comment.