Xiara Application Framework Update

in #utopian-io7 years ago (edited)

In the past weeks i've been busy with the developement of the Xiara Application Framework.

About the project?

Xiara is a framework for building efficient, scalable Node.js server-side applications. It uses modern JavaScript, is built with TypeScript (preserves compatibility with pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).

Under the hood, Xiara makes use of Express, allowing for easy use of the myriad third-party plugins which are available.
Xiara also features mongodb support out of the box

The framework is split up between multiple repositories:
https://github.com/azarus/xiara-core
https://github.com/azarus/xiara-web
https://github.com/azarus/xiara-mongo

And a boilerplate quickstart project:
https://github.com/azarus/xiara-boilerplate

Bug Fixes

  • Added missing remove documents to @xiara/mongo
  • Added missing removeOne to @xiara/mongo
  • Fixed a validation error when Date objects are used

New Features

  • Added remove documents to @xiara/mongo
  • Added removeOne to @xiara/mongo
  • Added pragmatic support for aggregations (collection.match().where().group() and so on)
  • Module Management and Component / Service loading
  • Basic Web Application backend

A xiara web application with express & mongo is built up with the following components:

Modules: Are the root of the application
Submodules: Are the same as modules can import and export components

  • Components (Base App component, Controlers, Policies and Responses inherit the behavior of a component)
  • Controller (MVC Controllers)
  • Policy (Authenticaiton rules)
  • Middlewares (Express Middlewards)
  • Models (Database definitions)
  • Responses (HTTP Response definitions & Exceptions)
  • Service (Services)
  • Views (ejs or other template engine views)

web-app

A simple Controllers Example

@Controller("/route")
class TestAPIController
{
    @GET("/getData")
    getData(req, res)
    {
      res.json({
        success: true
      })
    }
}

The above route defines the following HTTP end point
GET /route/getData

Policy

@Policy("Auth")
class AuthPolicy
{
    resolve(req, res, next)
    {
      // If logged in continue
      if(req.user)
      {
          return next();
      }
      res.forbidden("Login required");
    }
}

Responses

@Response("forbidden")
class ForbiddenResponse
{
    constructor(public message: string)
    {
    }
    
    send(req, res, next)
    {
      return res.json({
        success: false,
        message: this.message
      })
    }
}

Related Commits:

Xiara-Core
https://github.com/azarus/xiara-core/commit/f4f2feaf39c9f24bc2c3e3cee7f8c3f77ac54208
https://github.com/azarus/xiara-core/commit/32e321bc30d5931e493910fc70c912cbc7f05e65

Xiara-Mongo
https://github.com/azarus/xiara-mongo/commit/7b289c9c1e3420e5b7eff6924efa7d220907a20b#diff-2f8bbac3d76bf8fc13dca6e4ee6c4863

Xiara-Web
https://github.com/azarus/xiara-web/commit/2612670b19bc836058b8ac5d949321d5693e20c0

License

Mit

Got a question? Problem? Bug?

Please open an issue on github:
https://github.com/azarus/xiara-core



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @azarus I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]