The what and how
@Entity()
Class Presentor {
@Column()
name: "Wout";
@Column()
age: 23;
@Column()
profession: "Fullstack developer @ Riaktr";
@Column("string", { array: true })
hobbies: ["Coding", "Gaming", "Trains"];
}
.
└── src/
├── app.module.ts
├── app.controller.ts
├── app.service.ts
└── main.ts
.
└── src/
├── community/
│ ├── community.module.ts
│ ├── community.controller.ts
│ └── community.service.ts
├── app.module.ts
├── app.controller.ts
├── app.service.ts
└── main.ts
@Controller('community')
export class CommunityController {
constructor(
private readonly communityService: CommunityService
) {}
@Get('/best')
getBestCommunity(): string {
return this.communityService.getBestCommunity();
}
@Post(':id')
create(@Body() createCommunity: { name: string }) {
return this.communityService.create(createCommunity);
}
}
@Injectable()
export class CommunityService {
getBestCommunity(): string {
return 'BeJS';
}
create(createCommunityDto: CreateCommunityDto) {
return 'This action adds a new community';
}
}
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
@Module({
imports: [CommunityModule],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
.
└── src/
├── community/
│ └── ...
├── ...
└── main.ts
.
└── src/
├── community/
├── meetup/
│ ├── dto/
│ │ ├── create-meetup.dto.ts
│ │ └── update-meetup.dto.ts
│ ├── entities/
│ │ └── meetup.entity.ts
│ ├── meetup.module.ts
│ ├── meetup.controller.ts
│ └── meetup.service.ts
├── ...
└── main.ts
@Entity()
export class Meetup {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
description: string;
@Column()
date: Date;
}
export class CreateMeetupDto {
@IsString()
@IsNotEmpty()
name: string;
@IsString()
@IsNotEmpty()
description: string;
@IsDate()
@IsNotEmpty()
date: Date;
}