All Projects → bougarfaoui → back

bougarfaoui / back

Licence: other
Back.js : MVC Framework for Node.js written in Typescript and built on top of Express.js

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to back

SmartMvc
深入解析SpringMVC核心原理:从手写简易版MVC框架开始(SmartMvc)
Stars: ✭ 66 (+29.41%)
Mutual labels:  mvc-framework
CoolFrame
iOS搭建高可用APP框架,实现快速开发 。
Stars: ✭ 38 (-25.49%)
Mutual labels:  mvc-framework
shivneri
Component based MVC web framework based on fort architecture targeting good code structures, modularity & performance.
Stars: ✭ 21 (-58.82%)
Mutual labels:  mvc-framework
Fuga-Framework
Web Framework for Java
Stars: ✭ 15 (-70.59%)
Mutual labels:  mvc-framework
openresty-project-v0.01
🌹 基于OpenResty编写一个MVC模式的WEB项目 V0.01
Stars: ✭ 40 (-21.57%)
Mutual labels:  mvc-framework
puremvc-swift-multicore-framework
PureMVC MultiCore Framework for Swift
Stars: ✭ 17 (-66.67%)
Mutual labels:  mvc-framework
ZenTS
ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.
Stars: ✭ 36 (-29.41%)
Mutual labels:  mvc-framework
W
Framework pédagogique de la WebForce3
Stars: ✭ 10 (-80.39%)
Mutual labels:  mvc-framework
auction-website
🏷️ An e-commerce marketplace template. An online auction and shopping website for buying and selling a wide variety of goods and services worldwide.
Stars: ✭ 44 (-13.73%)
Mutual labels:  mvc-framework
flask-mvc
Flask Simple Model-View-Controller(MVC)
Stars: ✭ 21 (-58.82%)
Mutual labels:  mvc-framework
node-mysql
Node with mysql boilerplate
Stars: ✭ 72 (+41.18%)
Mutual labels:  mvc-framework
puremvc-delphi-standard-framework
A Delphi implementation of PureMVC (http://puremvc.org/)
Stars: ✭ 44 (-13.73%)
Mutual labels:  mvc-framework
databind-js
A powerful and flexible MVC data binding library
Stars: ✭ 16 (-68.63%)
Mutual labels:  mvc-framework
blog
用Node.js+Express和MongoDB搭建一个属于自己的博客
Stars: ✭ 46 (-9.8%)
Mutual labels:  mvc-framework
Geisha
Tiny Java Web Framework.
Stars: ✭ 120 (+135.29%)
Mutual labels:  mvc-framework
Sane
"Spring Boot for Classic ASP." A powerful and full-featured VBScript MVC framework that brings sanity to Classic ASP development. Use domain & view models, automap model -> view, easily enumerate and introspect, write db migrations, and more. No, seriously.
Stars: ✭ 26 (-49.02%)
Mutual labels:  mvc-framework
full-stack-tdc-poa
Projeto full stack Delphi MVC Framework e DevExtreme React.js
Stars: ✭ 16 (-68.63%)
Mutual labels:  mvc-framework
leafMVC
MVC "Framework" created from Leaf PHP Framework
Stars: ✭ 25 (-50.98%)
Mutual labels:  mvc-framework
stencil-realworld-app
An example SPA written with Stencil
Stars: ✭ 56 (+9.8%)
Mutual labels:  mvc-framework
aquiver
🚀 The aquifer is a java web framework based on Java8 and netty
Stars: ✭ 38 (-25.49%)
Mutual labels:  mvc-framework

NOTE: This project is deprecated and no longer being actively developed or maintained

Back.js: MVC Framework for Node.js written in Typescript and built on top of Express.js

Build Status

back.js is a new MVC framework for node written totally in Typescript and inspired from the popular spring MVC in java, it has a system of dependency injection and it's easy to use. Back.js is very new, it's not ready for production yet and needs some contributions.

🌟 There are a lot of javascript frameworks for node.js out there. This one is different :

  • Provides great TypeScript developer experience
  • Simple and flexible API
  • MVC Architecture

Quick start

$ npm install -g back-starter

Create the app

$ back

Install dependencies

$ npm install

Start your app at http://localhost:3000/

$ npm start

Quick Tutorial

Example 1 (simple GET request):

import {Controller ,Get ,Route } from "back-js";

@Controller
@Route("/")
class HomeController{

    constructor(){}

    @Get("/")
    greet() {
        console.log("hello World");
    }
    
    @Get("/greet")
    anotherGreet() {
        console.log("another hello World");
    }
} 
  • @Controller : class Decorator used to mark the class as request handler.
  • @Route : class Decorator used to specify the route handled by the controller.
  • @Get : method Decorator, when used on a method ,this method will handle all the GET requests corresponding to its route.

in this example we created a controller HomeController that handles all requests coming from / route, inside the controller we have two methods greet and anotherGreet, these methods point to / and /greet respectively. We used @Get(route) to indicate that the method will handle any web request GET coming from the route specified in the Decorator.

Example 2 (Request ,Reponse and Route parameter):

import {Controller ,Get ,Post,Route ,Request ,Response } from "back-js";


@Controller
@Route("/product")
class ProductController{

    constructor(){}

    @Get("/:id")
    getProduct(req : Request ,res : Response, id : number) {
        console.log(id);
        // do something
        res.send("not found");
    }
    
    @Post("/")
    addProduct(res : Response,id : number, name : string, price : number){
        res.end("done");
    }

}

Here we have acontroller ProductController that points to /product route and has two methods getProduct and addProduct :

the first method getProduct has @Get("/:id") decorator on it, this means that it points to the /product/anything route .The route parameter in this case id can be accessed as a parameter of getProduct method. The req and res objects are the same as those in Express.js .

the second method addProduct points to the /product/ route and handles requests of type POST. it has four parameters the last three ones are id, name and price ,each parameter holds the value of the property that has the same name in the request body , fro example if the client send the object below :

{"id":12,"name":"nutella","price":20}

the result :

    @Post("/")
    addProduct(res : Response, id : number, name : string, price : number, other : string){
        console.log(id); // 12
        console.log(name); // nutella
        console.log(price); // 20
        console.log(other); // undefined
    }

Example 3 (@RequestBody, @ResponseBody, @Service):

   import {Controller,Service ,Get ,Post,Route ,Request ,Response, RequestBody, ResponseBody } from "back-js";
   
   class Product{
       constructor(
           private id : number,
           private label : string,
           private price : number,
       ){}
   }
   
   @Service
   class ProductService{
   
       constructor(){}

       getProduct() : Promise<Product>{
           return new Promise((resolve)=>{
               resolve(new Product(1,"Bimo",45));
           });
       }

   }
  
   @Controller
   @Route("/product")
   class ProductController{
   
       constructor(
           private productService : ProductService
       ){}

       @Get("/")
       @ResponseBody
       getProduct(req : Request ,res : Response ) : Promise<Product> {
           return this.productService.getProduct();
       }   

       @Post("/")
       @ResponseBody
       addProduct(@RequestBody product) : string{
           console.log(product);
           return "done";
       }
   } 
  • @Service : class Decorator used to indicates that the class is injectable
  • @ResponseBody : method Decorator , indicates that the method return value should be bound to the web response body (if the return value is a promise the data holded by this promise will be sent).
  • @RequestBody : parameter Decorator , indicates that the method parameter should be bound to the web request body

in this example we have a controllerProductController with one dependency productService that will be injected automatically by the framework,this controller has also two methods :

the first one getProduct it has @ResponseBody decorator on it and returns a promise this means that the value holded in the promise will be sent in the web response body.

the second one addProduct has @ResponseBody decorator on its parameter product this means that web request body will be bound to the product parameter.

Contribution

1- Fork

2- Do your magic

3- Pull request 😄

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].