This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
generated from IgrowkerTraining/template-express-ts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from igrowker/Pau_Branch
feat /crear modulo users con nest, creat entity en modulo users #31
- Loading branch information
Showing
10 changed files
with
186 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class CreateUserDto {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { CreateUserDto } from './create-user.dto'; | ||
|
||
export class UpdateUserDto extends PartialType(CreateUserDto) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; | ||
|
||
@Entity({ | ||
name: "users" | ||
}) | ||
export default class User { | ||
|
||
@PrimaryGeneratedColumn('uuid') //depende de como se origine la id se usa PrimaryColumn | ||
id: string | ||
|
||
// @PrimaryColumn() | ||
// id: string | ||
|
||
@Column() | ||
name: string | ||
|
||
@Column() | ||
age: number | ||
|
||
@Column() | ||
gender: string | ||
|
||
@Column({ | ||
type: "enum", | ||
enum: ["searching", "offering"], | ||
default: "offering" | ||
}) | ||
role: string | ||
|
||
@Column({ | ||
type: 'text', | ||
array: true, | ||
nullable: true | ||
}) | ||
preferences: string[] //puede ser un enum con strings acordadas (cambiar decorador) | ||
|
||
@Column({ | ||
type: 'text', | ||
array: true, | ||
nullable: true | ||
}) | ||
travelHistory: string[] | ||
|
||
@Column({ | ||
type: 'text', | ||
array: true, | ||
nullable: true | ||
}) | ||
favorites: string[] //array de festivales cuando este creado (cambiar decorador) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { UsersController } from './users.controller'; | ||
import { UsersService } from './users.service'; | ||
|
||
describe('UsersController', () => { | ||
let controller: UsersController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [UsersController], | ||
providers: [UsersService], | ||
}).compile(); | ||
|
||
controller = module.get<UsersController>(UsersController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; | ||
import { UsersService } from './users.service'; | ||
import { CreateUserDto } from './dto/create-user.dto'; | ||
import { UpdateUserDto } from './dto/update-user.dto'; | ||
|
||
@Controller('users') | ||
export class UsersController { | ||
constructor(private readonly usersService: UsersService) {} | ||
|
||
@Post() | ||
create(@Body() createUserDto: CreateUserDto) { | ||
return this.usersService.create(createUserDto); | ||
} | ||
|
||
@Get() | ||
findAll() { | ||
return this.usersService.findAll(); | ||
} | ||
|
||
@Get(':id') | ||
findOne(@Param('id') id: string) { | ||
return this.usersService.findOne(+id); | ||
} | ||
|
||
@Patch(':id') | ||
update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) { | ||
return this.usersService.update(+id, updateUserDto); | ||
} | ||
|
||
@Delete(':id') | ||
remove(@Param('id') id: string) { | ||
return this.usersService.remove(+id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { UsersService } from './users.service'; | ||
import { UsersController } from './users.controller'; | ||
|
||
@Module({ | ||
controllers: [UsersController], | ||
providers: [UsersService], | ||
}) | ||
export class UsersModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { UsersService } from './users.service'; | ||
|
||
describe('UsersService', () => { | ||
let service: UsersService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [UsersService], | ||
}).compile(); | ||
|
||
service = module.get<UsersService>(UsersService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CreateUserDto } from './dto/create-user.dto'; | ||
import { UpdateUserDto } from './dto/update-user.dto'; | ||
|
||
@Injectable() | ||
export class UsersService { | ||
create(createUserDto: CreateUserDto) { | ||
return 'This action adds a new user'; | ||
} | ||
|
||
findAll() { | ||
return `This action returns all users`; | ||
} | ||
|
||
findOne(id: number) { | ||
return `This action returns a #${id} user`; | ||
} | ||
|
||
update(id: number, updateUserDto: UpdateUserDto) { | ||
return `This action updates a #${id} user`; | ||
} | ||
|
||
remove(id: number) { | ||
return `This action removes a #${id} user`; | ||
} | ||
} |