alado 2.2.8 → 2.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -823,6 +823,28 @@ setAvatar(req) {
|
|
|
823
823
|
}
|
|
824
824
|
```
|
|
825
825
|
|
|
826
|
+
3. Respond with Stream:
|
|
827
|
+
|
|
828
|
+
```ts
|
|
829
|
+
@get('/user/:id/avatar', { tags: ['User'] })
|
|
830
|
+
@withAuth(bearerAuth)
|
|
831
|
+
@defineResponse({
|
|
832
|
+
statusCode: 200,
|
|
833
|
+
title: 'OK',
|
|
834
|
+
headers: { 'Content-Type': 'image/png' },
|
|
835
|
+
body: {},
|
|
836
|
+
})
|
|
837
|
+
@defineRequest({ path: Id })
|
|
838
|
+
public getAvatar(req: Request) {
|
|
839
|
+
const readStream = createReadStream(`./uploads/user-${req.path.id}.png`);
|
|
840
|
+
return {
|
|
841
|
+
statusCode: 200,
|
|
842
|
+
headers: { 'Content-Type': 'image/png' },
|
|
843
|
+
body: readStream,
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
```
|
|
847
|
+
|
|
826
848
|
---
|
|
827
849
|
|
|
828
850
|
## OpenAPI / Swagger
|