You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -74,6 +70,8 @@ This repository is a boilerplate for building Node.js applications using TypeScr
74
70
- Always use TypeScript for type safety and modern JavaScript features.
75
71
- Follow the project's coding conventions and architecture patterns.
76
72
- Use dependency injection for managing dependencies, avoiding direct instantiation of classes.
73
+
- All environment variables has to be extracted and validated using `dotenv` and `joi` packages. Store them in config files like `.env` or `.env.test` and process them in your application startup in `src/config/app.ts`.
74
+
- Never use `npm run plop` to generate code, use the provided boilerplate structure and manually create files as needed.
77
75
- Never run any commands with `docker-compose` command, use npm scripts instead (e.g., `npm run lint`, `npm run lint-fix`, `npm run forma`).
78
76
79
77
#### Naming Guidelines
@@ -100,13 +98,5 @@ This repository is a boilerplate for building Node.js applications using TypeScr
100
98
- Every utility function must have a corresponding unit test.
101
99
102
100
#### Security Guidelines
103
-
- Use `helmet` for security headers in Express.
104
-
- Use `celebrate` for input validation in REST endpoints.
105
-
- Use global error handling middleware for catching and formatting errors.
106
-
- Add logging for important events and errors using injected logger in handlers and actions.
107
101
- Never expose sensitive information in error messages or responses.
108
-
- Use environment variables for sensitive configuration (e.g., database credentials, API keys) and load them using `dotenv`.
109
102
- Use HTTPS for secure communication, especially in production environments.
110
-
- Implement proper authentication and authorization mechanisms for protected routes.
111
-
- Regularly update dependencies to patch security vulnerabilities.
112
-
- Use `cors` middleware to control cross-origin requests, allowing only trusted origins.
Copy file name to clipboardExpand all lines: .github/instructions/handlers.instructions.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,4 +40,12 @@ export class UserHandler {
40
40
}
41
41
```
42
42
- Never create tests for handlers.
43
-
- Don't use `@CacheQuery` decorator in any handlers unless explicitly stated otherwise.
43
+
- Don't use `@CacheQuery` decorator in any handlers unless explicitly stated otherwise.
44
+
- Erorrs should be thrown as exceptions, not returned as responses. They will be handled by the global error handler.
45
+
- There are built-in error classes in `src/shared/errors` that you can use to throw errors with appropriate HTTP status codes and messages.
46
+
- Use HttpError classes from `src/shared/errors` for throwing HTTP errors.
47
+
- The AppError shouldn't be used in handlers, as it is a generic error class for internal errors.
48
+
- The NotFoundError should be used for 404 errors.
49
+
- The Validation Errors are handled by `celebrate` in `src/middleware/error-handler.ts`, so you don't need to handle them in handlers.
50
+
- In case you need to handle specific errors, you can create custom error classes in `src/shared/errors` and throw them in handlers, but remember for them to extend the `AppError` class.
51
+
- Add logging for important events and errors using injected logger in handlers and actions.
0 commit comments