DEV Community

ringeringeraja
ringeringeraja

Posted on

We finally have a fullstack framework for MongoDB

The two most popular alternatives for working with MongoDB in JavaScript (Prisma and Mongoose) are both flawed.

Mongoose adds a lot of polyfills and hooks to the MongoDB driver, stealing all of MongoDB's intended simplicity, requires external plugins to autopopulate references and does it badly (using hooks and multiple transactions instead of doing it in a single transaction leveraging the Aggregation Framework). It also has limited TypeScript support.

Prisma, on the other hand, emulates relational behavior when used with Mongo and misses denormalization, which is a very powerful feature intrinsic to Document-oriented databases.

I thought the JavaScript community deserved better, so I put together some good people and started working on a web framework written on top of MongoDB.

First, we have a compiler written in PureScript that parses .aeria files and emits JavaScript and TypeScript code.
The compiler runs in watch mode when the development server is active, so there's no need of running something like "aeria migrate" every time. Types are automatically updated on each compilation without need for IDE hacks also.

Role-Based Access Control

The framework let's you bring up RESTful endpoints automatically. Once exposed with the @expose attribute alone, any authenticated user can reach the endpoint. To control which set of users can have access to a specific endpoint, we can extend the builtin aeria.user collection with the roles property and then pass the desired roles as parameter to the @expose attribute.

Access Control remains strongely typed across the application. This could be used to be used to verify the access to critical functions in development/compile time.

Error handling

Since the begining, we know we didn't want try/catch error handling in our framework, so our first option was FP-style Eithers. That worked fine, but the user would have to adapt to idiomatic code like isLeft() and unwrapEither(), what didn't sound right. Later we finally came across our actual error handling approach, which is returning a Result.Either<E, R> object that the user can destructure and narrow as needed.

Extensible dashboard

All the backend metadata (information about collections and routes) is made available in the runtime as parseable JSON-schemas, so making a adaptative dashboard for Aeria was just around the corner. Aeria UI is a frontend counterpart for Aeria that allows bringing a CRUD-based application up in minutes. It is currently extensible with Vue only, but we plan on making it available to other UI frameworks as well.


That's it for now!
Also I am an ESL person, so forgive me if the text was sloppy at times.

Star us on GitHub!

We dream of getting traction someday and turning Aeria into a self-sustainable Open Source project.
If you liked the project and want it to thrive, please consider starring us on GitHub:

Top comments (0)