Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Chief

Blackbeard v0.1.0-beta - Opinionated MVC Framework

Recommended Posts

ScreenShot2015-12-21at9.07.14AM.png

 

For a quickstart quide, better examples, and API documentation, visit: http://ndugger.github.io/blackbeard/

 

Blackbeard is an opinionated MVC framework built on top of Node.js, using the most current and future versions of the ES language spec. What does this mean? Well, it means that you can take advantage of some of the upcoming and recent arrivals in the JavaScript language:

 


  • Classes


  • Annotations


  • Lambda expressions


  • Async/Await


  • Modules

 

So, using all of these great new language features, what then does it mean for the framework to be "opinionated"? Well, it means that we make it really easy to correctly implement an MVC pattern by giving you an API that does most of the work for you. The framework does also assume a few things (and throws appropriate errors if those assumptions fail). No worries, though, setup is really convenient and takes care of some of the boilerplating for you.

 

Well, enough with the long-winded boring stuff; let's get to the fun!

 

Here's an example of a very simple controller:

 



import { Controller, View, Router } from 'blackbeard';
const { MapRoute, GET } = Router;
 
@Controller
class MainController {
    
    @MapRoute('/', GET)
    async index () {
        return new View('index');
    }
 
}


 

If you're familiar with .NET MVC or Spring, you can see that Blackbeard will already be familiar to you. It was built to be simple and familiar, yet fast and powerful.

 

Here's another example of a more complex controller:

 



import Forum from '../models/forum';
import { Cache, Controller, DataString, Requirements, Router, Session, View } from 'blackbeard';
const { MapRoute, GET, POST } = Router;
const { isAuthenticated } = Session;
 
@Controller
@MapRoute('/forums')
class ForumController {
 
    @Cache(60)
    @MapRoute('/', GET)
    async index () {
        const forums = await Forum.findAll();
        return new View('index', forums);
    }
 
    @MapRoute('/{id}', GET)
    async forum (id) {
        const forum = await Forum.findById(Number(id));
        if (forum) {
            return new View('forum', forum);
        } else {
            return new Error(404);
        }
    }
 
    @MapRoute('/{id}/delete', POST)
    @Requirements(isAuthenticated)
    async delete (id, request) {
        const data = JSON.parse(request.body.toString());
        // do stuff with posted data
        await Forum.destroy({ where: { id: Number(id) } });
        return new DataString('application/json', JSON.stringify({ success: true });
    }
 
}


 

As you can see, due to the nature of the API, the annotations make it very simple to define your controllers and routes.

 

My questions for you all are, what sort of features would you love for an MVC framework to have?

Do you have any concerns about the API?

Would you use this?

 

Thanks!

Edited by Chief

Share this post


Link to post
Share on other sites

wu wuuu whaaaaattt???????

Im completely confused what this even is lol. But im sure marked know what it is. To me this just looks like an alien just posted stuff that i cant read XD.

Share this post


Link to post
Share on other sites

It's just a server framework for making websites; I use all sorts of fancy keywords, but it's really quite simple in the end.

Share this post


Link to post
Share on other sites

All of this site's custom stuff written by me was written in what is essentially a PHP version of what this does. It's a framework for coding. I guess you could say it provides guidelines for how to separate the three components of code: Model (engine room code), view (the interface, like HTML) and controller (routing slash telling the system what code to run).

 

http://webdevrefinery.com/forums/topic/600-an-introduction-to-mvc-architecture/

Share this post


Link to post
Share on other sites

Version 0.1.2-beta has been released; It features a faster async/await environment, and some minor bug fixes. 0.1.1-beta featured additions to the setup script that allows you to configure your Redis connection.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...