How to update 0.19.0 -> 1.1.0
Hi guys,
What is version 1.x doing? Can you provide a migration guide or similar? I was using 0.19.0 before and updated to 1.1.0, but send failed with a 404, so I switched back to 0.19.0. Cannot find any information.
send(event.node.req, filePath, {
cacheControl: true,
maxAge: '1 year',
immutable: true
})
.pipe(event.node.res)
Thanks!
There's a history file here: https://github.com/pillarjs/send/blob/master/HISTORY.md#100-beta1--2022-02-04
But I don't see anything that can help me debug the snippet you pasted. Do you have the filePath that is now a 404?
/Users/Name/Development/Company Name/website_company/.media-cache/images/w_2000/background_01-8cc5c16c-94b29dfe.jpg
I know there is a space in the path, but I tried to mask it with a backslash \ or encode it, nothing helped. Also it works in 0.19.0 so I am a bit confused.
Thanks for the quick reply, though!
This is really helpful, it looks like the package could use some updates to the README and release notes. In this case I think it's due to a change in dotfiles:
Remove hidden option -- use dotfiles option
In 0.x it only hid files when the began with a ., but now it hides anything that should be hidden (i.e. if the directory or file starts with a dot). I believe it's the ignore option in the README.
Do you need the ability to access files from hidden directories? Or just hidden files? You could tweak the dotfiles option or I can look at adding the old functionality back as an option.
Oh, i didn't guess that, because its a dot"folder". Yet, the moment i read the dotfiles entry in the docs i understand that this means files and directories the moment they are on the path.
I don't want to ever serve hidden files, the files i serve are located in a hidden directory.
Anyways i am happy to do dotfiles: 'allow'…
…But I saw you just added »The default value is similar to 'ignore', with the exception that this default will not ignore the files within a directory that begins with a dot, for backward-compatibility.«? – That's my best-case, thanks!
On another note: If send throws errors like this, maybe something like a cause could be a nice DX in the error log?
Like: Error, 404, due to dotfile rule.
But I saw you just added
Yeah, that's an outdated note in the README. The default behavior in 1.0 was changed to ignore, and that's why that file started to 404.
If send throws errors like this, maybe something like a cause could be a nice DX in the error log?
There's no error for this, but it was probably printed if you enable debugging: https://github.com/pillarjs/send/blob/dc6b5d4ec29355ffcf1ab122e52c27a98c392c15/index.js#L460
That's my best-case, thanks!
Does that mean you'd want an option like how it behaved in < 1.0? Something like dotfiles: 'allow file'? I'll think on the behavior more but don't see why it couldn't be supported as an official configuration.
dotfiles: 'allow directories'? I am slightly concerned to allow all dotfiles to be potentially served, now that I am thinking about it, yet i am also sure that's it's not a security issue in my setup at the moment, as i have preliminary checks that the file exists and is in the correct directory.
On the other side: Is it possible to set my root as
/Users/Name/Development/Company Name/website_company/.media-cache
and get my file from
/images/w_2000/background_01-8cc5c16c-94b29dfe.jpg
That should work in 1.x, right?
send(event.node.req, '/images/w_2000/background_01-8cc5c16c-94b29dfe.jpg', {
root: '/Users/Name/Development/Company Name/website_company/.media-cache',
cacheControl: true,
maxAge: '1 year',
immutable: true
})
.pipe(event.node.res)
Maybe that's a good solution because I knowingly opt in to serve from a dotdirectory and my path is controlled by dotfiles