Skip to content

Commit

Permalink
fix(splatter): Fix splatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodarru committed Oct 26, 2024
1 parent 0b30b2f commit c26ca9d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const server = fastify({

server.register(bootstrap, {
directory: resolve(__dirname, "rest"),
mask: /\.rest\./,
prefix: "/api"
});

Expand Down
File renamed without changes.
60 changes: 60 additions & 0 deletions src/rest/example.rest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Controller, GET } from "fastify-decorators";

@Controller({ route: "/" })
export default class ControllerTest {
@GET({
url: "/hello",
options: {
schema: {
response: {
200: {
type: "string"
}
}
}
}
})
async helloHandler(req, res) {
if (req.query.name) {
return `Hello, ${req.query.name}!`;
}

return "Hello world!";
}

@GET({
url: "/goodbye",
options: {
schema: {
response: {
200: {
type: "string"
}
}
}
}
})
async goodbyeHandler(req, res) {
if (req.query.name) {
return `Goodbye, ${req.query.name}!`;
}

return "Bye-bye!";
}

@GET({
url: "/hello/:name",
options: {
schema: {
response: {
200: {
type: "string"
}
}
}
}
})
async nameHandler(req, res) {
return `Hello, ${req.params.name}!`;
}
}

0 comments on commit c26ca9d

Please sign in to comment.