Skip to content

Commit

Permalink
fix: describe Joi schemas in another file (refactoring)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemattosv committed May 27, 2024
1 parent 5693069 commit 1bcfd1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/controllers/base/HelloNameController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ import { APIGatewayProxyHandler } from "aws-lambda";
import { Handler } from "src/errors/Handler";
import { HelloService } from "src/services/base/HelloService";
import { ok, badRequest } from "src/utils/returns";
import * as Joi from "joi";
import { paramsSchema } from "src/schemas/BaseSchemas";

const HelloNameController: APIGatewayProxyHandler = async (event) => {

if (!event.queryStringParameters) {
return badRequest("Missing query string parameters");
}

const paramsSchema = Joi.object({
name: Joi.string().required(),
});

type Params = { name: string };
let params: Params;

Expand Down
5 changes: 5 additions & 0 deletions src/schemas/BaseSchemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as Joi from 'joi';

export const paramsSchema = Joi.object({
name: Joi.string().required(),
});

0 comments on commit 1bcfd1a

Please sign in to comment.