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

Added support for AdonisJS v6 #838

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

atharahmed
Copy link

This PR adds an adapter for AdonisJS v6 and tries to solve #797

"@bull-board/api": "6.2.1",
"@bull-board/ui": "6.2.1",
"ejs": "^3.1.10",
"mime": "^4.0.4",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this dep, after the change of @adonisjs/static

packages/adonis/package.json Outdated Show resolved Hide resolved
});

if (this.statics) {
const statics = this.statics;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual handling of static files is not the proper way implement it.
Your current implementation opens a SECURITY issue.

Can we use the default @adonisjs/static addon somehow?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked into the @adonisjs/static and docs here: https://docs.adonisjs.com/guides/basics/static-file-server#static-files-server, but they haven't shared any way to use the static file server beyond the config. It seems to only load static build assets from the public folder, so I found an example of fs in packages > h3 > H3Adapter.ts and implemented that instead.

I also needed to use the mime package to find the right Content-Type header to return to render the file correctly.

I will continue to explore Adonis's codebase to see if I can find a way to use the static file server.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h3 package has several checks inorder to prevent path traversal Issue.
Maybe you can implement somthing similar.

}

public setErrorHandler(handler: (error: Error) => ControllerHandlerReturnType) {
this.errorHandler = handler;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see that there is any usage of this errorHandler from Adonis part... did you missed it?

@felixmosh
Copy link
Owner

Hi @atharahmed thank you for this awasom PR 🙏🏽

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

Successfully merging this pull request may close these issues.

2 participants