{"id":15068214,"url":"https://github.com/dmarzzucco/hanlderstatuscodeshttpsforexpress","last_synced_at":"2026-01-02T14:51:14.602Z","repository":{"id":256088941,"uuid":"854297247","full_name":"DMarzzucco/HanlderStatusCodesHTTPSforExpress","owner":"DMarzzucco","description":"Class module to handle HTTP responses for Express, using standard status codes. The ResponseStatusHTTPS class makes it easy to create consistent and structured responses for different situations in a web application.","archived":false,"fork":false,"pushed_at":"2024-10-10T13:22:23.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T18:51:29.379Z","etag":null,"topics":["api","backend","express-js","nodejs","nosql","solid-principles","sql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DMarzzucco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-08T22:24:20.000Z","updated_at":"2024-10-10T13:22:27.000Z","dependencies_parsed_at":"2024-09-08T23:32:14.491Z","dependency_job_id":"be9084c8-f5cc-4d54-90a3-7f63238dc8f9","html_url":"https://github.com/DMarzzucco/HanlderStatusCodesHTTPSforExpress","commit_stats":null,"previous_names":["dmarzzucco/hanlderstatuscodeshttpsforexpress"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DMarzzucco%2FHanlderStatusCodesHTTPSforExpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DMarzzucco%2FHanlderStatusCodesHTTPSforExpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DMarzzucco%2FHanlderStatusCodesHTTPSforExpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DMarzzucco%2FHanlderStatusCodesHTTPSforExpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DMarzzucco","download_url":"https://codeload.github.com/DMarzzucco/HanlderStatusCodesHTTPSforExpress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243833330,"owners_count":20355249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","backend","express-js","nodejs","nosql","solid-principles","sql","typescript"],"created_at":"2024-09-25T01:32:28.003Z","updated_at":"2026-01-02T14:51:14.572Z","avatar_url":"https://github.com/DMarzzucco.png","language":"TypeScript","readme":"\n\n# Hanlder Status Codes HTTPS for Express\n\nThis module provides a class to handle HTTP responses for Express, using standard status codes. The ResponseStatusHTTPS class makes it easy to create consistent and structured responses for different situations in a web application.\n\n## Objective\n\nThe main goal of this module is to provide a standardized and consistent way to manage HTTP responses in an application. The implementation of this class is guided by SOLID principles and design parameters to:\n\n- **Keep code clean:** Providing clear and specific methods for each type of response, avoiding code duplication and promoting reuse.\n\n- **Ensure scalability:** Allowing easy addition of new types of responses or modification of existing ones without affecting other parts of the system.\n\n- **Ensure high quality:** Applying design principles that improve the readability and maintainability of the code.\n\n## Examples in Service \n\n### First Option\n\n```TS\n \n async getByid(id: number): Promise\u003cServiceResponse\u003cusers\u003e\u003e {\n        try {\n            const user = await prisma.users.findUnique({ where: { id: id } })\n            if (!user) {\n                return ResponseStatudsHTTPS.notFound(`User not found`)\n            }\n            return ResponseStatudsHTTPS.succes(user)\n        } catch (error: any) {\n            return ResponseStatudsHTTPS.errorServer(error.message)\n        }\n    }\n\n ```\n ### Second Option\n\n  ```TS\n \n async getByid(id: number): Promise\u003cServiceResponse\u003cusers\u003e\u003e {\n        try {\n            const user = await prisma.users.findUnique({ where: { id: id } })\n            if (!user) {\n                return ResponseStatudsHTTPS.createResponse({status:Code.NOT_FOUND, message:\"User not found\"})\n            }\n            return ResponseStatudsHTTPS.createResponse({status:Code.OK, data:user})\n        } catch (error: any) {\n            return ResponseStatudsHTTPS.createResponse({status:Code.INTERNAL_SERVER_ERROR, message: error.message})\n        }\n    }\n\n ```\n\n ## Examples in Controllers \n\n```TS\n  public async getByid(req: Request, res: Response) {\n        const { id } = req.params\n        const result = await this.service.getByid(Number(id))\n        return res.status(result.statusCode).json(result.body)\n    }\n ```\n\n ## Interface \n\n```TS\n\ninterface ServiceResponse\u003cT\u003e {\n    statusCode: httpsStatusCode; //Export Enums\n    body: {\n        message?: string;\n        data?: T;\n    }\n}\n\n```\n\n## Handler Error for NestJs\n\n ```TS\n public async getByid(id: number): Promise\u003cUser\u003e {\n        try {\n            const user = await prisma.users.findUnique({ where: { id: id } })\n            if (!user) {\n                throw new ErrorManager({ type: \"NOT_FOUND\", message: \"User not found\" })\n            }\n            return user\n        } catch (error: any) {\n            throw new ErrorManager.createSignatureError(error.message)\n        }\n    }\n ```\n\n## Author\n\nMade by Dario Marzzucco (@darmarzz)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmarzzucco%2Fhanlderstatuscodeshttpsforexpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmarzzucco%2Fhanlderstatuscodeshttpsforexpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmarzzucco%2Fhanlderstatuscodeshttpsforexpress/lists"}