Skip to content

Commit

Permalink
refactor: add prefix to /api to all routes
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn committed Sep 24, 2023
1 parent 16b8866 commit 051637f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ void server.register(swaggerUI, {
});

// Health check
server.get("/", async (_request, _reply) => ({ ok: true }));
server.get("/api", async (_request, _reply) => ({ ok: true }));

// Declare a route
server.get<{
Querystring: { name: string };
}>("/hello", async (request) => {
}>("/api/hello", async (request) => {
const { name } = request.query;
return { hello: name ?? "world" };
});
Expand All @@ -71,7 +71,7 @@ const opts: RouteShorthandOptions = {
};

server.get(
"/ping",
"/api/ping",
opts,
async (_request: FastifyRequest, _reply: FastifyReply) => ({
pong: "it worked!",
Expand Down
6 changes: 3 additions & 3 deletions specs/generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ tests:
name: Default
steps:
- http:
url: /
url: /api
method: GET
schema:
type: object
properties:
ok: bool
- http:
url: /hello
url: /api/hello
method: GET
check:
status: 200
schema:
type: object
description: Successful response with a JSON object
- http:
url: /ping
url: /api/ping
method: GET
check:
status: 200
Expand Down
6 changes: 3 additions & 3 deletions specs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ externalDocs:
servers:
- url: http://localhost:3000
paths:
/:
/api:
get:
responses:
200:
description: Default Response
content: {}
/hello:
/api/hello:
get:
responses:
200:
Expand All @@ -25,7 +25,7 @@ paths:
schema:
type: string
description: Successful response with a JSON object
/ping:
/api/ping:
get:
responses:
200:
Expand Down
6 changes: 3 additions & 3 deletions specs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"definitions": {},
"paths": {
"/": {
"/api": {
"get": {
"responses": {
"200": {
Expand All @@ -16,7 +16,7 @@
}
}
},
"/hello": {
"/api/hello": {
"get": {
"responses": {
"200": {
Expand All @@ -25,7 +25,7 @@
}
}
},
"/ping": {
"/api/ping": {
"get": {
"responses": {
"200": {
Expand Down
2 changes: 1 addition & 1 deletion workflow.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "1.1"
name: Api Check
env:
host: localhost:3000
host: localhost:3000/api
tests:
ping:
steps:
Expand Down

0 comments on commit 051637f

Please sign in to comment.