From c49735e67c7f7def0d8112a5560d4c91cd621bab Mon Sep 17 00:00:00 2001 From: "krisztian.maurer" Date: Thu, 24 Nov 2022 17:32:41 +0100 Subject: [PATCH] refactor: names --- example/app.ts | 3 ++- example/controllers/user.controller.ts | 11 ++++++++--- .../{specific-http.error.ts => bad-request.error.ts} | 2 +- lib/index.ts | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) rename lib/error/http/{specific-http.error.ts => bad-request.error.ts} (93%) diff --git a/example/app.ts b/example/app.ts index 811ac1b..3ee4853 100644 --- a/example/app.ts +++ b/example/app.ts @@ -4,9 +4,10 @@ import {ValidationPipe} from "../lib/services/pipe/validation.pipe"; import { LogMiddleware } from "./middlewares/log.middleware"; import express from 'express'; import * as path from "path"; +import { Env } from "../lib"; async function main() { - const port = process.env.PORT || 3001; + const port = Env.asNumber("PORT", 3000); const app = express() diff --git a/example/controllers/user.controller.ts b/example/controllers/user.controller.ts index 0284c7f..555ad99 100644 --- a/example/controllers/user.controller.ts +++ b/example/controllers/user.controller.ts @@ -9,10 +9,10 @@ import { Param } from '../../lib/decorators/param.decorator'; import { FooService } from '../services/foo.service'; import { UpperCasePipe } from '../services/upper.pipe'; import { Get } from '../../lib/decorators/method/get.decorator'; -import { Controller, Post } from "../../lib"; +import { Controller, HttpError, Post } from "../../lib"; import { OtherValidator, UserValidator } from "../user.validator"; import { ApiDocs } from "../../lib/decorators/openapi/result.decorator"; -import { NotImplementedError } from "../../lib/error/http/specific-http.error"; +import { NotImplementedError } from "../../lib/error/http/bad-request.error"; import { LogMiddleware2, LogMiddleware3 } from "../middlewares/log.middleware"; import { BeforeMiddleware } from "../../lib/decorators/middleware/before-middleware.decorator"; import { AfterMiddleware } from "../../lib/decorators/middleware/after-middleware.decorator"; @@ -30,7 +30,12 @@ export class UserController { return {test:"123"} } - @ApiDocs({resultType: UserValidator, summary: "custom summary", description: "this is my description", tags: ["ttttttttttttttt"]}) + @ApiDocs({ + resultType: UserValidator, + summary: "custom summary", + description: "this is my description", + tags: ["user"] + }) @Get('/test') async getUsers( @Req() req: Request, diff --git a/lib/error/http/specific-http.error.ts b/lib/error/http/bad-request.error.ts similarity index 93% rename from lib/error/http/specific-http.error.ts rename to lib/error/http/bad-request.error.ts index c2b9dea..453ce29 100644 --- a/lib/error/http/specific-http.error.ts +++ b/lib/error/http/bad-request.error.ts @@ -1,6 +1,6 @@ import { HttpError } from './http-error'; -export class SpecificHttpError extends HttpError { +export class BadRequestError extends HttpError { constructor(message: string, details?: any) { super(400, message, details); } diff --git a/lib/index.ts b/lib/index.ts index 6be9c10..1fc20fa 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -13,7 +13,7 @@ export * from './decorators/method/post.decorator'; export * from './decorators/controller.decorator'; export * from './env/env'; export * from './error/http/http-error'; -export * from './error/http/specific-http.error'; +export * from './error/http/bad-request.error'; export * from './error/http/status-map'; export * from 'type-chef-di'; export { Request, Response, Express, Application } from 'express';