-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Santiago Olayo
committed
Jun 23, 2024
1 parent
a3f9ea1
commit 5c19388
Showing
6 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
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
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,33 @@ | ||
import { | ||
Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
} from 'typeorm'; | ||
|
||
@Entity({ | ||
name: 'posts', | ||
}) | ||
export class Post { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
title: string; | ||
|
||
@Column({ | ||
type: 'text', | ||
name: 'image_url', | ||
}) | ||
imageUrl: string; | ||
|
||
@CreateDateColumn({ name: 'created_at' }) | ||
createdAt: string; | ||
|
||
@UpdateDateColumn({ name: 'updated_at' }) | ||
updatedAt: string; | ||
|
||
@Column({ default: true, name: 'is_active' }) | ||
isActive: boolean; | ||
} |
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,16 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { ApiOperation, ApiResponse } from '@nestjs/swagger'; | ||
import { PostsService } from './posts.service'; | ||
import { Post } from './post.entity'; | ||
|
||
@Controller('/v1/posts') | ||
export class PostsController { | ||
constructor(private readonly postService: PostsService) {} | ||
|
||
@Get('') | ||
@ApiOperation({ summary: 'List posts' }) | ||
@ApiResponse({ status: 200, description: 'Post found' }) | ||
async getPosts(): Promise<Post[]> { | ||
return this.postService.getPosts(); | ||
} | ||
} |
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 { PostsService } from './posts.service'; | ||
import { PostsController } from './posts.controller'; | ||
|
||
@Module({ | ||
providers: [PostsService], | ||
controllers: [PostsController] | ||
}) | ||
export class PostsModule {} |
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,10 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Post } from './post.entity'; | ||
|
||
@Injectable() | ||
export class PostsService { | ||
|
||
getPosts(): Promise<Post[]> { | ||
return Promise.resolve([]); | ||
} | ||
} |