Releases: mjackson/remix-the-web
file-storage v0.6.1
- Fix regression when using
LocalFileStorage
together withform-data-parser
(see #53)
tar-parser v0.2.2
- Add
Promise<void>
toTarEntryHandler
return type
multipart-parser v0.8.2
- Add
Promise<void>
toMultipartPartHandler
return type
file-storage v0.6.0
- BREAKING CHANGE:
LocalFileStorage
now uses 2 characters for shard directory names instead of 8. - Buffer contents of files stored in
MemoryFileStorage
. - Add
storage.list(options)
for listing files in storage.
The following options
are available:
cursor
: An opaque string that allows you to paginate over the keys in storageincludeMetadata
: Iftrue
, include file metadata in the resultlimit
: The maximum number of files to returnprefix
: Only return keys that start with this string
For example, to list all files under keys that start with user123/
:
let result = await storage.list({ prefix: 'user123/' });
console.log(result.files);
// [
// { key: "user123/..." },
// { key: "user123/..." },
// ...
// ]
result.files
will be an array of { key: string }
objects. To include metadata about each file, use includeMetadata: true
.
let result = await storage.list({ prefix: 'user123/', includeMetadata: true });
console.log(result.files);
// [
// {
// key: "user123/...",
// lastModified: 1737955705270,
// name: "hello.txt",
// size: 16,
// type: "text/plain"
// },
// ...
// ]
Pagination is done via an opaque cursor
property in the list result object. If it is not undefined
, there are more files to list. You can list them by passing the cursor
back in the options
object on the next call. For example, to list all items in storage, you could do something like this:
let result = await storage.list();
console.log(result.files);
while (result.cursor !== undefined) {
result = await storage.list({ cursor: result.cursor });
console.log(result.files);
}
Use the limit
option to limit how many results you get back in the files
array.
multipart-parser v0.8.1
- Fix bad publish that left a
workspace:^
version identifier in package.json
headers v0.10.0
This release contains several improvements to Cookie
that bring it more in line with other headers like Accept
, AcceptEncoding
, and AcceptLanguage
.
- BREAKING CHANGE:
cookie.names()
andcookie.values()
are now getters that returnstring[]
instead of methods that returnIterableIterator<string>
- BREAKING CHANGE:
cookie.forEach()
calls its callback with(name, value, cookie)
instead of(value, name, map)
- BREAKING CHANGE:
cookie.delete(name)
returnsvoid
instead ofboolean
// before
let cookieNames = Array.from(headers.cookie.names());
// after
let cookieNames = headers.cookie.names;
Additionally, this release adds support for the If-None-Match
header. This is useful for conditional GET requests where you want to return a response with content only if the ETag has changed.
import { SuperHeaders } from '@mjackson/headers';
function requestHandler(request: Request): Promise<Response> {
let response = await callDownstreamService(request);
if (request.method === 'GET' && response.headers.has('ETag')) {
let headers = new SuperHeaders(request.headers);
if (headers.ifNoneMatch.matches(response.headers.get('ETag'))) {
return new Response(null, { status: 304 });
}
}
return response;
}
node-fetch-server v0.5.1
- Iterate manually over response bodies in
sendResponse
instead of usingfor await...of
. This seems to avoid an issue where the iterator tries to read from a stream after the lock has been released.
lazy-file v3.3.1
- Handle stream errors in
lazy-file/fs
'writeFile
. When there is an error in the stream, callwriteStream.end()
on the underlying file stream before rejecting the promise.
form-data-parser v0.7.0
- BREAKING CHANGE: Override
parseFormData
signature so the upload handler is always last in the argument list.parserOptions
are now an optional 2nd arg.
import { parseFormData } from '@mjackson/form-data-parser';
// before
await parseFormData(
request,
(fileUpload) => {
// ...
},
{ maxFileSize },
);
// after
await parseFormData(request, { maxFileSize }, (fileUpload) => {
// ...
});
- Upgrade
multipart-parser
to v0.8 to fix an issue where errors would crash the process whenmaxFileSize
was exceeded (see #28) - Add an example of how to use
form-data-parser
together withfile-storage
to handle multipart uploads on Node.js - Expand
FileUploadHandler
interface to support returningBlob
from the upload handler, which is the superclass ofFile
file-storage v0.5.0
- Add
fileStorage.put(key, file)
method as a convenience aroundfileStorage.set(key, file)
+fileStorage.get(key)
, which is a very common pattern when you need immediate access to the file you just put in storage
// before
await fileStorage.set(key, file);
let newFile = await fileStorage.get(key)!;
// after
let newFile = await fileStorage.put(key, file);