Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Blackbeard - Opinionated MVC Framework [Pre-release thoughts]

Recommended Posts

So, this thread is just to gather people's thoughts and criticism for my MVC framework; I'll create a new thread with a release announcement when the time comes.


**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;

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;

class ForumController {

    @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)
    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 upon the beta release?

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...