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
Copy file name to clipboardExpand all lines: README.md
+37-38Lines changed: 37 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,10 @@ By default, the server will log the request and response to console. This behavi
87
87
88
88
By default, the server will log the request body and headers. These behaviors can be disabled by setting the `app.disableLogRequestBody` or `app.disableLogRequestHeaders` to `true`.
89
89
90
+
> **Sensitive headers**
91
+
>
92
+
> If you want to redact sensitive headers from the logs, you can set the `fastify.logger.redact` option in the config.
93
+
90
94
### Send request id header
91
95
92
96
By default, the server will send a `Request-Id` header to the client. This behavior can be disabled by setting the `app.disableSendRequestIdHeader` to `true`.
@@ -132,40 +136,41 @@ By default, the server will log the API error(`throw new ApiError()`). This beha
132
136
### Install
133
137
134
138
```bash
135
-
npm install fastify-app js-yaml
139
+
npm install fastify-app
136
140
```
137
141
138
-
> The `js-yaml` can be omitted if you don't want to use a yaml config file.
139
-
140
142
### Create a config file
141
143
142
-
Create a `config.yaml` file in your project root with the following example:
143
-
144
-
```yaml
145
-
server:
146
-
host: 0.0.0.0
147
-
port: 53004
148
-
149
-
fastify:
150
-
disableRequestLogging: false
151
-
bodyLimit: 52428800#in bytes, 50Mb
152
-
logger:
153
-
redact:
154
-
- "req.headers.authorization"
155
-
156
-
app:
157
-
disableCors: false
158
-
disableLogRequestBody: false
159
-
disableLogRequestHeaders: false
160
-
disableLogApiError: false
161
-
disableSendRequestIdHeader: false
162
-
disableApiErrorHandler: false
163
-
internalServerErrorCode: 200
164
-
disableHealthCheckRoutes: false
165
-
healthCheckRoutesPrefix: "/health-check"
166
-
enableHealthCheckShowsGitRev: false
167
-
disableAddRequestState: false
168
-
disableReplyHelperFunctions: false
144
+
Create a `config.js` file in your project root with the following example:
145
+
146
+
```javascript
147
+
exportdefault {
148
+
server: {
149
+
host:'0.0.0.0',
150
+
port:63004,
151
+
},
152
+
fastify: {
153
+
disableRequestLogging:false,
154
+
bodyLimit:52428800, // 50Mb
155
+
logger: {
156
+
redact: ['req.headers.authorization'],
157
+
},
158
+
},
159
+
app: {
160
+
disableCors:false,
161
+
disableLogRequestBody:false,
162
+
disableLogRequestHeaders:false,
163
+
disableLogApiError:false,
164
+
disableSendRequestIdHeader:false,
165
+
disableApiErrorHandler:false,
166
+
internalServerErrorCode:200,
167
+
disableHealthCheckRoutes:false,
168
+
healthCheckRoutesPrefix:'/health-check',
169
+
enableHealthCheckShowsGitRev:false,
170
+
disableAddRequestState:false,
171
+
disableReplyHelperFunctions:false,
172
+
},
173
+
};
169
174
```
170
175
171
176
### Create your first API endpoint
@@ -212,11 +217,8 @@ Files with names starting with an underscore will not be registered to the fasti
0 commit comments