Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update 0.19.0 -> 1.1.0 #242

Open
fabianwohlfart opened this issue Oct 15, 2024 · 7 comments
Open

How to update 0.19.0 -> 1.1.0 #242

fabianwohlfart opened this issue Oct 15, 2024 · 7 comments

Comments

@fabianwohlfart
Copy link

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!

@blakeembrey
Copy link
Member

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?

@fabianwohlfart
Copy link
Author

/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!

@blakeembrey
Copy link
Member

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.

@fabianwohlfart
Copy link
Author

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.

@blakeembrey
Copy link
Member

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:

send/index.js

Line 460 in dc6b5d4

debug('%s dotfile "%s"', this._dotfiles, path)

@blakeembrey
Copy link
Member

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.

@fabianwohlfart
Copy link
Author

fabianwohlfart commented Oct 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants