tsframework / ts-framework

A Web Framework for Nodejs
http://tsframework.github.io
MIT License
43 stars 6 forks source link

Refactoring #12

Closed jhonmike closed 8 years ago

jhonmike commented 8 years ago
atrakeur commented 8 years ago

I was also considering the lack of a good typescript framework so I dived a little into your code to see if I can help. For now I find it a little confusing. May I suggest to review the current naming and folder structure?

All framework respect some separation of concerns. In a web framework, there is at least 3 concerns: The Controller, The Model and The View.

The controller is the obvious part in Controller.ts, but it also take the Router with it. Let's call that part Http and put them in a directory named after that (because we are doing Http Controllers, not console Controllers after all!). Filters must go in that part too.

The model is quite obvious. It regroup the model class but also Model Validation, database base class and database drivers.

The view now regroup all sorts of view that can be produced. Here goes the template system, but also all views that can be returned (json, file download, error pages, whatever).

Now comes the glue between all that. Let's call it the Foundation. Here goes the Application class, Config class, Autoloader and all other base classes that are used as the base of the application.

This architecture is heavily inspired from other framework architecture (laravel, not to name it)

So to summarise here is my proposed directory structure:

- Foundation
    - Application.ts
    - Autoloader.ts
    - Configuration.ts
    - Reflection.ts
- Http
    - Controllers
    - Filters
    - Router.ts
- Models
    - Database
        - Drivers
   - Model.ts
- View
    - BaseView.ts
    - FileView.ts
    - JsonView.ts
    - Renderer

Of course It's just a draft. I can also implement it and submit it as a PR but I would like to have an open discution on that matter before hand.

jhonmike commented 8 years ago

The tips are excelent @atrakeur but we will review the organization of directories, it is that the moment the focus is complete controllers! but I'll take your feedback to the https://gitter.im/tsframework/ts-framework, will be good discuss there!