adonisjs / discussion

Discussing about new features and sharing random thoughts: ⚠️ Not every request will be accepted
51 stars 5 forks source link

Planning version 5 #62

Closed thetutlage closed 5 years ago

thetutlage commented 6 years ago

This discussion is open for the public to share their ideas on features they want to see in AdonisJs with version 5.

Please note:

  1. All requests cannot be accepted, but we can always discuss the reasons like adults.
  2. All accepted requests will be added to this comment.
  3. The work on version 5 has not yet started. I will update this thread when I will start working on it.
  4. The focus is to reduce the number of breaking changes.
  5. If you like some idea, then use the reactions to thumbs up and please do not comment with +1.
  6. If you are interested in working on a feature, please lemme know and we can discuss it in depth.

Big features

Enhancements

Good to have

Breaking changes

Performance Wins

moltar commented 6 years ago
  1. Add a validator that uses JSON Schema. This makes it easier to re-use work across backend/frontend and nicely integrates with many form libraries.
  2. Maybe outside the scope of this, but maybe there is some work that needs to happen to make this work, but it'd be nice to be able to use Adonis websockets with GraphQL subscription transport.
  3. Request I made via PR elsewhere: https://github.com/adonisjs/adonis-auth/issues/103
fractalzombie commented 6 years ago

Typescript or flow types support

rtablada commented 6 years ago

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

ammezie commented 6 years ago

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.

ammezie commented 6 years ago

Add support for task scheduling.

ghost commented 6 years ago

Please add support for MongoDB

wxs77577 commented 6 years ago

Please make MongoDB as built-in support

Zizaco commented 6 years ago

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/

Zizaco commented 6 years ago

Queue jobs 👍

thetutlage commented 6 years ago

@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.

wxs77577 commented 6 years ago

RBAC Module Plugin

ghost commented 6 years ago

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.

Zizaco commented 6 years ago

Some basis for authorization (much like laravel's one) would be cool

RomainLanz commented 6 years ago

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)

  1. Rewrite the Router to be able to add with ease regex for defining parameters.
  2. Implement the new design for the website
  3. Rewrite the doc completly
  4. Add polymorphic support to Lucid
  5. Add soft delete support to Lucid (https://github.com/adonisjs/adonis-lucid/pull/315)
  6. Extract the view layer to its own module (so people will be able to use something else than edge)
  7. Make adonis-bundler an official package.
  8. Finish adonis-graphql
moltar commented 6 years ago

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).

hadihallak commented 6 years ago

@Zizaco in addition to what @RomainLanz suggested, you should check out enniel/adonis-acl

moltar commented 6 years ago

Support for better logging swapping. E.g. I prefer to use Bunyan.

pdipax commented 6 years ago

Hi guys, add sftp filesystem for remote storage.

taviroquai commented 6 years ago

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"

rtablada commented 6 years ago

@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.

lffg commented 6 years ago

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')
PazzaVlad commented 6 years ago

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.

rtablada commented 6 years ago

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

viglucci commented 6 years ago

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.

feryardiant commented 6 years ago

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 😁

moltar commented 6 years ago

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.

moltar commented 6 years ago

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.

feryardiant commented 6 years ago

@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

thetutlage commented 6 years ago

@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.

thetutlage commented 6 years ago

@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

thetutlage commented 6 years ago

@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

feryardiant commented 6 years ago

@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.

shimjudavid commented 6 years ago

I would love to see Adonisjs as an all inclusive web framework-

  1. Dynamic and interactive HTML5 charts and graphs
  2. Create powerful documents, charts, and reports. Interfaces to work with PDF, and extends the integration support to OpenOffice and MS Office formats such as Excel, PowerPoint, and SharePoint.
  3. Image manipulation - to create and manipulate images, retrieve and store images in a database, retrieve image information for indexes and searches, convert images from one format to another, and write images to the hard drive.
feryardiant commented 6 years ago

@shimjudavid That's too much for a framework buddy. You'll need a CMS not a Framework for that.

Nefiron commented 6 years ago

I I have 2 things that I would love to see added or improved upon in Adonis 5.

moltar commented 6 years ago

@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 }},

...
viglucci commented 6 years ago

@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.

antwaanh commented 6 years ago

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.

feryardiant commented 6 years ago

@antwaanvh interesting, I just trying to split my routes.js become this

gambar

and everything seems to works just fine.

P.s: routes.old.js is my old one,

thetutlage commented 6 years ago

@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?

webdevian commented 6 years ago

@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

feryardiant commented 6 years ago

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?

thetutlage commented 6 years ago

@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.

moltar commented 6 years ago

@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.

taviroquai commented 6 years ago

@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.

cannap commented 6 years ago

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

lffg commented 6 years ago

Add @for and @while loops in Edge.JS

PazzaVlad commented 6 years ago

Add @for and @while loops in Edge.JS

why would you use it instead of @each?

rtablada commented 6 years ago

@PazzaVlad there are still reasons to use other structures other than @each loops even when not often used for templates.

ghost commented 6 years ago

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