All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 52s
195 lines
4.2 KiB
Plaintext
195 lines
4.2 KiB
Plaintext
syntax = "v1"
|
|
|
|
info (
|
|
title: "Blog API"
|
|
desc: "API for blog application"
|
|
author: "cialloo"
|
|
date: "2025-10-24"
|
|
version: "v1"
|
|
)
|
|
|
|
type (
|
|
PingReq {}
|
|
PingResp {
|
|
ok bool `json:"ok"`
|
|
}
|
|
)
|
|
|
|
type (
|
|
UploadPresignedURLReq {
|
|
file_name string `json:"file_name"` // Original file name
|
|
}
|
|
UploadPresignedURLResp {
|
|
url string `json:"url"` // Presigned URL for upload
|
|
file_key string `json:"file_key"` // Key to identify the uploaded file
|
|
expire_at int64 `json:"expire_at"` // Expiration timestamp
|
|
}
|
|
)
|
|
|
|
type (
|
|
DownloadPresignedURLReq {
|
|
file_key string `json:"file_key"` // Key to identify the file to download
|
|
}
|
|
DownloadPresignedURLResp {
|
|
url string `json:"url"` // Presigned URL for download
|
|
expire_at int64 `json:"expire_at"` // Expiration timestamp
|
|
}
|
|
)
|
|
|
|
type (
|
|
CreatePostReq {
|
|
title string `json:"title"`
|
|
content string `json:"content"`
|
|
cover_image_key string `json:"cover_image_key"`
|
|
}
|
|
CreatePostResp {
|
|
post_id string `json:"post_id"`
|
|
}
|
|
)
|
|
|
|
type (
|
|
EditPostReq {
|
|
post_id string `json:"post_id"`
|
|
title string `json:"title"`
|
|
content string `json:"content"`
|
|
cover_image_key string `json:"cover_image_key"`
|
|
}
|
|
EditPostResp {}
|
|
)
|
|
|
|
type (
|
|
DeletePostReq {
|
|
post_id string `json:"post_id"`
|
|
}
|
|
DeletePostResp {}
|
|
)
|
|
|
|
type (
|
|
GetPostReq {
|
|
post_id string `json:"post_id"`
|
|
}
|
|
GetPostResp {
|
|
post_id string `json:"post_id"`
|
|
title string `json:"title"`
|
|
content string `json:"content"`
|
|
cover_image_url string `json:"cover_image_url"`
|
|
created_at int64 `json:"created_at"`
|
|
updated_at int64 `json:"updated_at"`
|
|
}
|
|
)
|
|
|
|
type (
|
|
ListPostsReq {
|
|
page int `json:"page"`
|
|
page_size int `json:"page_size"`
|
|
}
|
|
ListPostsResp {
|
|
posts []ListPostsRespPosts `json:"posts"`
|
|
total_count int `json:"total_count"`
|
|
}
|
|
ListPostsRespPosts {
|
|
post_id string `json:"post_id"`
|
|
title string `json:"title"`
|
|
cover_image_url string `json:"cover_image_url"`
|
|
created_at int64 `json:"created_at"`
|
|
updated_at int64 `json:"updated_at"`
|
|
}
|
|
)
|
|
|
|
type (
|
|
ListTagsReq {}
|
|
ListTagsResp {
|
|
tags []ListTagsRespTags `json:"tags"`
|
|
}
|
|
ListTagsRespTags {
|
|
tag_id string `json:"tag_id"`
|
|
tag_name string `json:"tag_name"`
|
|
}
|
|
)
|
|
|
|
@server (
|
|
prefix: /api/blog
|
|
)
|
|
service Blog {
|
|
@doc (
|
|
summary: "Ping the server to check if it's alive"
|
|
description: "Ping the server to check if it's alive"
|
|
)
|
|
@handler pingHandler
|
|
get /ping (PingReq) returns (PingResp)
|
|
}
|
|
|
|
@server (
|
|
prefix: /api/blog/view
|
|
)
|
|
service Blog {
|
|
@doc (
|
|
summary: "Get a blog post by ID"
|
|
description: "Get a blog post by ID"
|
|
)
|
|
@handler GetPostHandler
|
|
post /post (GetPostReq) returns (GetPostResp)
|
|
|
|
@doc (
|
|
summary: "Get a list of blog posts"
|
|
description: "Get a list of blog posts with pagination"
|
|
)
|
|
@handler ListPostsHandler
|
|
post /posts (ListPostsReq) returns (ListPostsResp)
|
|
|
|
@doc (
|
|
summary: "Get a list of blog tags"
|
|
description: "Get a list of blog tags"
|
|
)
|
|
@handler ListTagsHandler
|
|
post /tags (ListTagsReq) returns (ListTagsResp)
|
|
}
|
|
|
|
@server (
|
|
middleware: SuperAdminAuthMiddleware
|
|
prefix: /api/blog/post
|
|
)
|
|
service Blog {
|
|
@doc (
|
|
summary: "Create a new blog post"
|
|
description: "Create a new blog post"
|
|
)
|
|
@handler CreatePostHandler
|
|
post /create (CreatePostReq) returns (CreatePostResp)
|
|
|
|
@doc (
|
|
summary: "Edit an existing blog post"
|
|
description: "Edit an existing blog post"
|
|
)
|
|
@handler EditPostHandler
|
|
post /edit (EditPostReq) returns (EditPostResp)
|
|
|
|
@doc (
|
|
summary: "Delete a blog post"
|
|
description: "Delete a blog post"
|
|
)
|
|
@handler DeletePostHandler
|
|
post /delete (DeletePostReq) returns (DeletePostResp)
|
|
}
|
|
|
|
@server (
|
|
middleware: SuperAdminAuthMiddleware
|
|
prefix: /api/blog/file
|
|
)
|
|
service Blog {
|
|
@doc (
|
|
summary: "Get presigned URL for file upload"
|
|
description: "Get presigned URL for file upload"
|
|
)
|
|
@handler UploadPresignedURLHandler
|
|
post /upload (UploadPresignedURLReq) returns (UploadPresignedURLResp)
|
|
|
|
@doc (
|
|
summary: "Get presigned URL for file download"
|
|
description: "Get presigned URL for file download"
|
|
)
|
|
@handler DownloadPresignedURLHandler
|
|
post /download (DownloadPresignedURLReq) returns (DownloadPresignedURLResp)
|
|
}
|
|
|