Skip to content
TrinteJS - Javascrpt MVC Framework for Node.JS
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin
conf
controllers
lib
models
public
scripts
tests
utils
views
.gitignore
.npmignore
README.md
app-cluster.js
app.js
app.json
config.js
package.json
trinte

README.md

TrinteJS Javascript MVC Framework for NodeJS

A MVC boilerplate for ExpressJS backed by MongooseJS and Bootstrap, based on Express MVC Bootstrap.

Description

This application help to create a Webapp MVC style in few minutes.

Installation

Installation is done using the NodeJS Package Manager (npm). If you don't have npm installed on your system you can download it from npmjs.org To install trinte:

$ sudo npm install trinte -g

Table of contents

Usage overview:

  $ trinte [command(s)] [argument(s)]

Command format:

  cluster *port=3000                : Run the application using the cluster module.
  server *port=3000                 : Run the application as a server.
  test                              : Run all tests.
  test unit|integration|functional  : Run a particular type of test.
  script help *<name>               : This help script, optional script name for additional help.
  script <name> *args               : Run a script with <name>, with params

  Available scripts:

  create-controller  args           : Creates a controller
  create-model  args                : Creates a model
  create-test  args                 : Creates a test
  create-view  args                 : Creates a view
  generate-all  args                : Creates a scaffold
  help                              : Show help

Create and initialize app

  $ trinte create-app HelloWorld    # Create application
  $ cd HelloWorld && npm -l install # intall dependencies

  # generate scaffold
  $ trinte script generate-all User name email password active
  $ trinte                          # running server (default in cluster mode)

Shows help:

  // Shows help
  $ trinte help
  $ trinte script help generate-all

Create a scaffold:

  // Creates all (model, views, controller, tests)
  $ trinte script generate-all User

  // create User model and etc. with fields: name, email, password, active
  $ trinte script generate-all User name email password active:boolean
  • See all valid field types here.

Create a model:

  // format: trinte script create-model [model name] [field(s)]

  // Create Post model without fields
  $ trinte script create-model Post

  // create User model with fields name, email, password, active: Boolean
  $ trinte script create-model User name email password active:boolean
  • See all valid field types here.

Create a controller:

  // Creates a controller
  $ trinte script create-controller Post

Create a views:

  // Creates views
  $ trinte script create-view Post

Create a test:

  // Creates tests
  $ trinte script create-test HelloWorld

Runs server:

  $ trinte                         // Runs server in cluster mode
  $ trinte server                  // Runs server in simple mode
  $ trinte cluster                 // Runs server in cluster mode

  # Runs server in simple mode on different port
  $ trinte server port=3000

Field types:

Following are all valid field types.

  String
  Number
  Date
  Buffer
  Boolean
  Mixed
  ObjectId
  Array

Learn more on MongooseJS.

Created application

Directory structure

On initialization directories tree generated, like that:

.
|-- conf
|   |-- configuration.js
|   |-- development.js
|   |-- production.js
|   `-- test.js
|-- controllers
|   |-- AppController.js
|   `-- PostsController.js
|-- lib
|   `-- inflection.js
|-- models
|   |-- Category.js
|   |-- Post.js
|   `-- User.js
|-- public
|   |-- css
|   |   `-- ...
|   |-- js
|   |   `-- ...
|   `-- img
|   |   `-- ...
|-- views
|   |-- app
|   |   `-- index.html
|   `-- posts
|   |   |-- edit.html
|   |   |-- index.html
|   |   `-- new.html
|   |-- layout.html
|   |-- 404.html
|   `-- 500.html
|-- utils
|   |-- helper.js
|   `-- pager.js
|-- package.json
|-- app.js
`-- app-cluster.js

Routing

// Plural
app.get("/:controller?", router);                           // Index
app.get("/:controller.:format?", router);                   // Index
app.get("/:controller/:from-:to.:format?", router);         // Index

// Plural Create & Delete
app.post("/:controller", router);                           // Create
app.del("/:controller", router);                            // Delete all

// Singular - different variable to clarify routing
app.get("/:controller/:action", router);                    // Add (New) and custom actions
app.get("/:controller/:id.:format?", router);               // To support controller/index
app.get("/:controller/:id/:action", router);                // Show edit
app.put("/:controller/:id", router);                        // Update
app.del("/:controller/:id", router);                        // Delete

Params

app.param('id', /^[A-Za-z0-9]+$/);
app.param('controller', /^[a-zA-Z]+$/);
app.param('action', /^[a-zA-Z]+$/);
app.param('format', /^[a-zA-Z]+$/);
app.param('from', /^\d+$/);
app.param('to', /^\d+$/);

Used Middleware

In the Wild

The following projects use TrinteJS.

If you are using TrinteJS in a project, app, or module, get on the list below by getting in touch or submitting a pull request with changes to the README.

Startups & Apps

Credits

  • Node.js: Amazing javascript asynchronous IO library, install manually.
  • MongoDB: NoSQL Database, install manually.
  • NPM: Node package manager, used to install:
  • Express.Js: Application Framework for Node.js
  • Mongoose.Js: Node.JS ORM for MongoDB.
  • EJS: Embedded Javascript Templating Library.
  • jQuery: Best Javascript Library.
  • Bootstrap: Powerful front-end CSS/JS framework
  • Glyphicons: Fantastic library of precisely prepared monochromatic icons and symbols.

Author

Aleksej Gordejev (aleksej@gordejev.lv).

Copyright & License

(The MIT License)

Copyright (c) 2012 Aleksej Gordejev aleksej@gordejev.lv

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Resources

Something went wrong with that request. Please try again.