Closed thetutlage closed 5 years ago
Typescript or flow types support
Hey @thetutlage poking in here to discuss jsonapi.org serializer support.
Especially with the introduction of operations, the structure of Lucid serializers is not a fit for compliant serialization.
Some things that would be needed for compliance is to properly be aware of include
and fields
from the request object. While I'm not saying the serializer should be responsible for fetching/lazy loading this data it is important for coverage that included relations are ONLY included when include
is present in the URL and fields should only include the fields in the specified type when fields
is present in the URL query params.
From experience implementing, teaching, and working on OSS that uses jsonapi.org spec, my recommendation is to have a serializer with a serialize
function that takes in two arguments (shown with pseudo typescript): serialize(req: Request, collection: LucidCollection)
.
Some good implementations are:
My preference is somewhere between JA Serializer and JSON API DotNET Core.
Some other things to really think about and work with, a built in integration layer for jsonapi should also help with error serialization and should be aware of links
for resources and relationships (which then requires some integration to the router potentially for best use).
The good thing is that this work could also be applied for other specs like JSON Schema and even GraphQL
It will be nice to have some kind of release plan for new versions of AdonisJs. That way we know when to expect new versions.
Add support for task scheduling.
Please add support for MongoDB
Please make MongoDB as built-in support
As @ammezie said. I think a build in way to do task scheduling would be worth having. Due to the way the server process runs, Nodejs is perfect for this and it would make the setup of the schedule runner much simpler than in analog frameworks.
Perhaps you can simply include modules that already exists (or very similar code) to the core. For example: https://codelike.pro/schedule-jobs-crontab-like-in-an-adonisjs-app/
Queue jobs 👍
@Zizaco @ammezie Sure I will look into the Scheduled tasks as well. Adding it to the list.
Regarding MongoDB and GraphQL I personally don't use both. What that means, I am not expert in these technologies to build modules or solutions around them. I know @RomainLanz is passionate about GraphQL, and if he publishes something great, I will be adding to it to the list of 1st party modules.
Regarding MongoDB @wxs77577, you already maintain a module for same. I am happy to share any insights you looking for. But adding that to the core and maintaining it is not possible, since I have almost zero experience with MongoDB.
RBAC Module Plugin
hello;
Great features. Is it possible to have a release plan; each 6 months so we can make commitments on our products as well :)
thanks for the fantastic job on adonisjs.
Some basis for authorization (much like laravel's one) would be cool
You can already do that with @slynova/fence
or even using the alpha version of adonis-guard
. Happy to help you in the Discord Server.
Concerning V5, I want also to... (not in order)
Router
to be able to add with ease regex for defining parameters.edge
)adonis-bundler
an official package.adonis-graphql
For queues, it should be something AMQP-compatible. Or even more ideally, the protocol should be pluggable (kind of like database is now).
One reason I prefer RabbitMQ over Redis, is that RMQ has support for dead letter queue (SQS supports that too). That makes it easier to write fault-tolerant apps. I can simply throw
in the task handler code and the task is automatically re-queued according to the queue system logic.
With Redis though, the task needs to be manually re-inserted (error prone).
@Zizaco in addition to what @RomainLanz suggested, you should check out enniel/adonis-acl
Support for better logging swapping. E.g. I prefer to use Bunyan.
Hi guys, add sftp filesystem for remote storage.
I know that this request will break everything but hey, its a new major version 5, so people will expect it to break anyway, so it's good to start new projects:
Standard es5/6 import modules, instead of "use"
@taviroquai depending on the release date plan for 5, this would conflict with latest Node LTS and adoption across companies relying on LTS. I think after Node LTS supports import/export statements then it could be more feasible.
The other way around this would be to require a precompile step which is doable (and can actually lead to some pretty interesting performance improvements) but would be a pretty large departure from what's currently available. I think if precompile did become an option, then I think that there would need to be a full major version cycle where you could do both.
It would be great to have an native (and optional) assets compiler, lixe Laravel Mix.
Also route groups inside another groups would be realy nice in some situations, example:
Route.group(() => {
Route.group(() => {
Route.get('/login', 'SessionController.login')
Route.post('/login', 'SessionController.submitLogin')
Route.get('/register', 'SessionController.register')
Route.post('/register', 'SessionController.submitRegister')
}).middleware('redirect-if-authenticated')
Route.get('/logout', 'SessionController.logout')
.middleware('auth')
}).prefix('/session')
I think i would be great to have ability to configure folder structure, like for views, exceptions folder etc. It would make possible use more modular structure and divide app by logical modules.
Mixing the ideas of @lffg and @PazzaVlad, Engines support could be nice so that you can build sub projects and mount the entire project to the router and have a sharing mechanism to map things within sub DIs.
So in an Engine you might have a User
model that you require to be mapped but there would be a way to inject a different Lucid model (for example a Guest
model) into the Engine.
This is heavily inspired by rails and Ember engines
Would be great if the request
and response
objects were compatible with the objects used by Express, and if middleware in Adonis supported the same interface as Express middlewares.
With no compatibility between Express middleware (mainly due to differences in the request
and response
objects), it is very costly to migrate an existing Express application to Adonis if your Express application makes heavy use of middlewares.
I wonder if validator messages will looking for translation (if available) by default. For example, if we have unique
, required
or any validations error it will looking for available translation first, otherwise use default message.
The translation file would be located in resources/locales/<locale>/validations.json
& should contains the following
// resources/locales/<locale>/validations.json
{
"unique": "The {field} should be unique",
"required": "The {field} is required",
"range": "The {field} should between {0} and {1}"
}
I've done this by creating simple helper that dump all validation keys from indicative
like this:
Helpers.validationMessages = () => {
const formats = {}
const rules = require('indicative/builds/validations')
for (let rule of Object.keys(rules)) {
rule = rule.split(/(?=[A-Z])/).join('_').toLowerCase()
formats[rule] = (field, type, args) => {
const params = { field, ...args }
try {
return Antl.formatMessage(`validations.${type}`, params)
} catch (err) {
Logger.debug('Validation translation not found', { err })
}
}
}
return formats
}
That way I could simply use validate(data, rules, Helpers.validationMessages)
, so I don't have to translate each form manually.
I thought it would be great if adonis could handle this kind of functionality by default.
P.s. Hope you guys get the idea even tho my english was so poor 😁
Would be great if the request and response objects were compatible with the objects used by Express, and if middleware in Adonis supported the same interface as Express middlewares.
Totally agree with that. I don't see why we even need these special wrapper objects, when an original object can be extended with all of the same features.
Implement front-matter for email templates.
I think it'd be better if we could define the subject line, and even to
and from
inside the email template itself. A front matter could be a good solution for this. I don't like that we have to hard-code the subject inside the code itself.
@moltar
Implement front-matter for email templates.
I don't think that was good (for me personaly). What I'm currently implement is add from
and repyTo
inside app.js
config and use Translation for subject
instead, That way I could simply dispatch
a job (using adonis-kue for now)
job.dispatch('mailer', { type: 'user-activation', recipient: userInstance, data )}
Inside the Jobs/Mailer.js
async handle ({ type, recipient, data }) {
data.recipient = recipient
const view = `emails.${type}`
const subject = Antl.formatMessage(view, { extraValueIfAny })
await Mail.send(view, data, (mail) => {
mail.to(recipient.email, recipient.username)
.from(app.mailer.address, app.mailer.name)
.subject(subject)
})
}
And here the view/emails/user-activation.edge
@layout('layouts.emails')
@section('content')
<tr>
<td align="left" valign="top">
<p>Hello {{ recipient.username }},</p>
<p>Welcome bla bla bla:</p>
</td>
</tr>
<tr>
<td align="center" height="10" style="font-size:10px; line-height:10px;">
@!component('components.emails-button', ....)
</td>
</tr>
@endsection
Because .
I don't like that we have to hard-code the subject inside the code itself.
And also I don't like that I have to add another dependency just for sending a simple email.
Just personal preference
@moltar How come you can define the to
field inside the email template itself. A single email template is used to send emails to multiple people.
@feryardiant I don't think adding a dependency is really a big deal. That what Node eco-system is all about.
@moltar @viglucci The goal of Adonis is not to be compatible with express and infact they are both different frameworks. If anyone of you feel fancy to write a wrapper, then please do
@feryardiant I have created a separate issue for translating validation messages. However, I have some questions, hope you or if anyone else can help with it https://github.com/adonisjs/adonis-validation-provider/issues/51
@thetutlage
I don't think adding a dependency is really a big deal. That what Node eco-system is all about.
Like i said, it's my personal opinion. I don't like to add another dependency to do simple stuff, unless I really have to.
I would love to see Adonisjs as an all inclusive web framework-
@shimjudavid That's too much for a framework buddy. You'll need a CMS not a Framework for that.
I I have 2 things that I would love to see added or improved upon in Adonis 5.
Better third party node modules support. I would love to see an even thinner layer to integrate third party modules with an easier syntax. This would make it even easier to use the current NPM packages in the ecosystem. The Namespacey deal as it is right now is hard to get into.
Clustering built in to easily create worker instances and alike to utilize cores and threads on a system even better with Adonis.
@thetutlage
How come you can define the to field inside the email template itself. A single email template is used to send emails to multiple people.
Right, but using the template it is possible to interpolate the variables.
---
to: "{{ user.firstName }} {{ user.lastName }}" <{{ user.to }}>
subject: {{ antl.formatMessage('Subject line goes here') }}
X-Some-Other-Header: foo
---
Hi {{ user.firstName }},
...
@Nefiron can you expand on "The Namespacey deal as it is right now is hard to get into". Are you referring to the IOC container and the service providers? If so, I think the dependency management in Adonis is one of its major strengths in the node ecosystem. There aren't many other frameworks that offer this type of feature without having to "roll your own" solution along side them.
Having the ability to split routes into different files would be nice to see. For example, routes/api.js + routes/web.js + routes/custom.js. This, IMO, will make the routes feel less daunting and cluttered.
@antwaanvh interesting, I just trying to split my routes.js
become this
and everything seems to works just fine.
P.s: routes.old.js
is my old one,
@moltar
It’s weird that you are happy passing data to the template, but cannot write message.to()
, though both needs to be done at the same place.
Also I am confused with the usage of antl
, which language will it format the message to?
@antwaanvh @feryardiant I think you can already do this as long as you require all the other route files in route.js, and redefine Route
at the top of each of them.
I agree that an autoload patter for routes that includes a folder would be good though
Also I am confused with the usage of
antl
, which language will it format the message to?
Depends on your default locale app.locales.locale
or by request, isn't it?
@feryardiant
Depends on your default locale app.locales.locale or by request, isn't it?
Ideally no, since most of the times, emails are not sent during the HTTP request. You may fire an event or add it to a queue.
@thetutlage
It’s weird that you are happy passing data to the template, but cannot write message.to(), though both needs to be done at the same place.
Nah, I can do that too. I was just answering the question how a to
field is handled. I think it's fair to add to
on the JS side. My main concern is hard-coding the subject lines on the JS side. Which is, as you know, just another header. So if we are handling one header, might as well handle any header. But still leave the choice to the user to use a to
method on the JS side, or subject
method, if they want a quick-hack script. But also support front-matter, for those who need more controls.
Also I am confused with the usage of antl, which language will it format the message to?
That was kind of pseudo-code. Of course, language should be determined somehow. Maybe part of user
object, or passed in somehow.
@viglucci
Would be great if the request and response objects were compatible with the objects used by Express, and if middleware in Adonis supported the same interface as Express middlewares.
I second this. HTTP Request/Response should be the most compatible as possible with other third-party modules.
Something like Cashier/OmniPay that would be awesome the Provider/Addon could be called "PayDay" 💰 :P cant find any package which handles this stuff like Chasier or OmniPay ok sure this could be done in a extra Package
//e after i read my own message i think thats just fit addons :O
Add @for
and @while
loops in Edge.JS
Add @for and @while loops in Edge.JS
why would you use it instead of @each?
@PazzaVlad there are still reasons to use other structures other than @each
loops even when not often used for templates.
PLease add support for mysql 8, since the mysql 8 security alghoritm driver has changed
Currently the only driver that it works for mysql 8 in nodejs is mysqlx
https://insidemysql.com/introducing-connector-node-js-for-mysql-8-0/ https://dev.mysql.com/doc/dev/connector-nodejs/8.0/
So if right now you try to put togheter mysql 8 and adonis framework gives a error result like:
Client does not support authentication protocol requested by server; consider upgrading MySQL client
If fact the current mysql drivers mysql and mysql2 show the same error
This discussion is open for the public to share their ideas on features they want to see in AdonisJs with version 5.
Please note:
thumbs up
and please do not comment with+1
.Big features
Enhancements
unique
rule to be more versatile, by applying runtime database constraints.eslint
overstandard
.vow-browser
to the latest version of the puppeteer. Puppeteer has evolved a lot in last few months, so there will be the bunch of breaking changes. We just need to fix them and keep the API compatible.Good to have
docblocks
in the code and also make use of YuiDoc or similar tools to generate API docs for all the official repos.Mail
,Session
,Drive
.import
syntax overuse
method to resolve dependencies from IoC container. This highly depends upon the progress done in the core of Node.js. Also, since ES6 modules in Node.js supports.mjs
extensions, will have to think about that too.Breaking changes
Performance Wins
Arrays
withSets
, were are later use_.unique
to pull unique items. This results in some serious performance gains.