Skip to content

Commit

Permalink
refactor(http): append /v1 versioning prefix on each endpoint
Browse files Browse the repository at this point in the history
yoshinorin committed Feb 9, 2024
1 parent 2a8ab29 commit 51f9e4b
Showing 30 changed files with 357 additions and 350 deletions.
68 changes: 34 additions & 34 deletions docs/rest-api/openapi.yml
Original file line number Diff line number Diff line change
@@ -65,15 +65,15 @@ paths:
status:
type: string
example: operational
/system/health:
/v1/system/health:
get:
summary: Get API server health
tags:
- system
responses:
200:
description: API server is runnning
/system/metadata:
/v1/system/metadata:
get:
summary: Get system metadata
tags:
@@ -106,8 +106,8 @@ paths:
example: "Not Found"
instance:
type: string
example: "/system/metadata"
/token:
example: "/v1/system/metadata"
/v1/token:
post:
summary: Create an IDToken
tags:
@@ -149,10 +149,10 @@ paths:
example: "Bad Request"
instance:
type: string
example: "/token"
example: "/v1/token"
401:
description: Unauthorized
/archives:
/v1/archives:
get:
summary: Get all articles
tags:
@@ -166,7 +166,7 @@ paths:
type: array
items:
$ref: '#/components/schemas/simpleArticle'
/articles:
/v1/articles:
get:
summary: Get articles with count
tags:
@@ -198,7 +198,7 @@ paths:
type: array
items:
$ref: '#/components/schemas/article'
/authors:
/v1/authors:
get:
summary: Get all authors
tags:
@@ -212,7 +212,7 @@ paths:
type: array
items:
$ref: '#/components/schemas/author'
/authors/{authorName}:
/v1/authors/{authorName}:
get:
summary: Get an author
tags:
@@ -246,8 +246,8 @@ paths:
example: "Not Found"
instance:
type: string
example: "/author/{authorName}"
/contents:
example: "/v1/author/{authorName}"
/v1/contents:
post:
summary: Create or Update a content
tags:
@@ -289,7 +289,7 @@ paths:
example: "Bad Request"
instance:
type: string
example: "/contents/"
example: "/v1/contents/"
401:
description: Unauthorized
422:
@@ -316,8 +316,8 @@ paths:
example: "Unprocessable Entity"
instance:
type: string
example: "/contents"
/contents/{contentPath}:
example: "/v1/contents"
/v1/contents/{contentPath}:
get:
summary: Get a content
tags:
@@ -350,8 +350,8 @@ paths:
example: "Not Found"
instance:
type: string
example: "/contents/{contentPath}"
/contents/{contentId}:
example: "/v1/contents/{contentPath}"
/v1/contents/{contentId}:
delete:
summary: Delete a content
tags:
@@ -384,8 +384,8 @@ paths:
example: "Not Found"
instance:
type: string
example: "/contents/{contentId}"
/tags:
example: "/v1/contents/{contentId}"
/v1/tags:
get:
summary: Get a tags
tags:
@@ -398,7 +398,7 @@ paths:
schema:
items:
$ref: '#/components/schemas/tagWithCount'
/tags/{tagName}:
/v1/tags/{tagName}:
get:
summary: Get an articles by tagName
tags:
@@ -432,8 +432,8 @@ paths:
example: "Not Found"
instance:
type: string
example: "/tags/{tagName}"
/tags/{tagId}:
example: "/v1/tags/{tagName}"
/v1/tags/{tagId}:
delete:
summary: Delete a tag
tags:
@@ -466,8 +466,8 @@ paths:
example: "Not Found"
instance:
type: string
example: "/tags/{tagId}"
/content-types/{contentPath}:
example: "/v1/tags/{tagId}"
/v1/content-types/{contentPath}:
get:
summary: Get Content-Types
tags:
@@ -480,7 +480,7 @@ paths:
schema:
items:
$ref: '#/components/schemas/contentType'
/content-types/{contentTypeName}:
/v1/content-types/{contentTypeName}:
get:
summary: Get a Content-Type
tags:
@@ -513,8 +513,8 @@ paths:
example: "Not Found"
instance:
type: string
example: "/content-types/{contentTypeName}"
/sitemaps:
example: "/v1/content-types/{contentTypeName}"
/v1/sitemaps:
get:
summary: Get an articles url & updated date for sitemaps.xml
tags:
@@ -528,7 +528,7 @@ paths:
type: array
items:
$ref: '#/components/schemas/sitemaps'
/feeds/{feedName}:
/v1/feeds/{feedName}:
get:
summary: Get a feeds
tags:
@@ -542,7 +542,7 @@ paths:
type: array
items:
$ref: '#/components/schemas/feed'
/caches/:
/v1/caches/:
delete:
summary: Invalidate all caches
tags:
@@ -554,7 +554,7 @@ paths:
description: Caches are invalidated
401:
description: Unauthorized
/search:
/v1/search:
get:
summary: Search contents
tags:
@@ -602,8 +602,8 @@ paths:
example: "Unprocessable Entity"
instance:
type: string
example: "/search"
/series:
example: "/v1/search"
/v1/series:
get:
summary: Get all series
tags:
@@ -658,10 +658,10 @@ paths:
example: "Bad Request"
instance:
type: string
example: "/series/"
example: "/v1/series/"
401:
description: Unauthorized
/series/{seriesName}:
/v1/series/{seriesName}:
get:
summary: Get a series
tags:
@@ -696,7 +696,7 @@ paths:
example: "Not Found"
instance:
type: string
example: "/series/{seriesName}"
example: "/v1/series/{seriesName}"
components:
securitySchemes:
basicAuth:
82 changes: 41 additions & 41 deletions src/main/scala/net/yoshinorin/qualtet/BootStrap.scala
Original file line number Diff line number Diff line change
@@ -12,21 +12,21 @@ import org.typelevel.log4cats.{LoggerFactory => Log4CatsLoggerFactory}
import org.typelevel.log4cats.slf4j.{Slf4jFactory => Log4CatsSlf4jFactory}
import org.typelevel.log4cats.slf4j.{Slf4jLogger => Log4CatsSlf4jLogger}
import net.yoshinorin.qualtet.http.{AuthProvider, CorsProvider}
import net.yoshinorin.qualtet.http.routes.{
ArchiveRoute,
ArticleRoute,
AuthRoute,
AuthorRoute,
CacheRoute,
ContentRoute,
ContentTypeRoute,
FeedRoute,
HomeRoute,
SearchRoute,
SeriesRoute,
SitemapRoute,
SystemRoute,
TagRoute
import net.yoshinorin.qualtet.http.routes.HomeRoute
import net.yoshinorin.qualtet.http.routes.v1.{
ArchiveRoute => ArchiveRouteV1,
ArticleRoute => ArticleRouteV1,
AuthRoute => AuthRouteV1,
AuthorRoute => AuthorRouteV1,
CacheRoute => CacheRouteV1,
ContentRoute => ContentRouteV1,
ContentTypeRoute => ContentTypeRouteV1,
FeedRoute => FeedRouteV1,
SearchRoute => SearchRouteV1,
SeriesRoute => SeriesRouteV1,
SitemapRoute => SitemapRouteV1,
SystemRoute => SystemRouteV1,
TagRoute => TagRouteV1
}

import scala.concurrent.duration._
@@ -42,37 +42,37 @@ object BootStrap extends IOApp {
val authProvider = new AuthProvider(Modules.authService)
val corsProvider = new CorsProvider(Modules.config.cors)

val archiveRoute = new ArchiveRoute(Modules.archiveService)
val articleRoute = new ArticleRoute(Modules.articleService)
val authorRoute = new AuthorRoute(Modules.authorService)
val authRoute = new AuthRoute(Modules.authService)
val cacheRoute = new CacheRoute(authProvider, Modules.cacheService)
val contentTypeRoute = new ContentTypeRoute(Modules.contentTypeService)
val contentRoute = new ContentRoute(authProvider, Modules.contentService)
val feedRoute = new FeedRoute(Modules.feedService)
val archiveRouteV1 = new ArchiveRouteV1(Modules.archiveService)
val articleRouteV1 = new ArticleRouteV1(Modules.articleService)
val authorRouteV1 = new AuthorRouteV1(Modules.authorService)
val authRouteV1 = new AuthRouteV1(Modules.authService)
val cacheRouteV1 = new CacheRouteV1(authProvider, Modules.cacheService)
val contentTypeRouteV1 = new ContentTypeRouteV1(Modules.contentTypeService)
val contentRouteV1 = new ContentRouteV1(authProvider, Modules.contentService)
val feedRouteV1 = new FeedRouteV1(Modules.feedService)
val homeRoute: HomeRoute = new HomeRoute()
val searchRoute = new SearchRoute(Modules.searchService)
val seriesRoute = new SeriesRoute(authProvider, Modules.seriesService)
val sitemapRoute = new SitemapRoute(Modules.sitemapService)
val systemRoute = new SystemRoute(Modules.config.http.endpoints.system)
val tagRoute = new TagRoute(authProvider, Modules.tagService, Modules.articleService)
val searchRouteV1 = new SearchRouteV1(Modules.searchService)
val seriesRouteV1 = new SeriesRouteV1(authProvider, Modules.seriesService)
val sitemapRouteV1 = new SitemapRouteV1(Modules.sitemapService)
val systemRouteV1 = new SystemRouteV1(Modules.config.http.endpoints.system)
val tagRouteV1 = new TagRouteV1(authProvider, Modules.tagService, Modules.articleService)

val router = new net.yoshinorin.qualtet.http.Router(
corsProvider,
archiveRoute,
articleRoute,
authorRoute,
authRoute,
cacheRoute,
contentRoute,
contentTypeRoute,
feedRoute,
archiveRouteV1,
articleRouteV1,
authorRouteV1,
authRouteV1,
cacheRouteV1,
contentRouteV1,
contentTypeRouteV1,
feedRouteV1,
homeRoute,
searchRoute,
seriesRoute,
sitemapRoute,
systemRoute,
tagRoute
searchRouteV1,
seriesRouteV1,
sitemapRouteV1,
systemRouteV1,
tagRouteV1
)

private[this] def server(host: Ipv4Address, port: Port, httpApp: HttpApp[IO]): Resource[IO, Server] = {
Loading

0 comments on commit 51f9e4b

Please sign in to comment.