Skip to content

Commit

Permalink
Fixed code smell (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
petruki authored Oct 8, 2023
1 parent 3f43559 commit 8262ff9
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/routes/searchdocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ import { SearchDocsQueryParams } from '../dto/request.ts';
const router = new Router();
let service: SearchDocsService;

const { ignoreCase, previewLength, query, regex, skipCache, trimContent, url } = SearchDocsQueryParams;
const { checkParam, required, hasLenght, isUrl, isBoolean, isNumeric } = Validator;

router.get(
'/',
checkParam([
{ key: SearchDocsQueryParams.query, validators: [required(), hasLenght({ max: 100 })] },
{ key: SearchDocsQueryParams.url, validators: [isUrl()] },
{ key: SearchDocsQueryParams.previewLength, validators: [isNumeric()] },
{ key: SearchDocsQueryParams.ignoreCase, validators: [isBoolean()] },
{ key: SearchDocsQueryParams.trimContent, validators: [isBoolean()] },
{ key: SearchDocsQueryParams.regex, validators: [isBoolean()] },
{ key: SearchDocsQueryParams.skipCache, validators: [isBoolean()] },
{ key: query, validators: [required(), hasLenght({ max: 100 })] },
{ key: url, validators: [isUrl()] },
{ key: previewLength, validators: [isNumeric()] },
{ key: ignoreCase, validators: [isBoolean()] },
{ key: trimContent, validators: [isBoolean()] },
{ key: regex, validators: [isBoolean()] },
{ key: skipCache, validators: [isBoolean()] },
]),
async (context: Context) => {
try {
Expand Down

0 comments on commit 8262ff9

Please sign in to comment.