Files
main.tsmain
What you'll learn
- Return a file as a StreamableFile from a read stream or a buffer, and explain why not to pipe to the response yourself
- Set Content-Type and Content-Disposition with @Header, res.set() and the StreamableFile options
- Refuse a missing file with a 404 before streaming starts
Press Run tests to start the app. Its log appears here.Graded endpoints
records/cats.csv streamed from disk, typed and named by @Header
The same file through the generic route, with no declared type
existsSync said no, so the route threw a 404 before creating a stream
A row for the export
A second row
A CSV built in memory, returned as a StreamableFile over a Buffer, with the headers set through res.set()