A MVC boilerplate for ExpressJS backed by CaminteJS and Bootstrap.
This application help to create a Webapp MVC style
in few minutes. TrinteJS tuned for ExpressJS 3.x, jQuery 2.x and Twitter Bootstrap 3.x.
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
- Get started!
- Usage overview
- Created application
- Recommend extensions
- Credits
- Peoject Author
- Copyright & License
- Resources
$ trinte [command(s)] [argument(s)]
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.
g, script help *<name> : This help script, optional script name for additional help.
g, script <name> *args : Run a script with <name>, with params
Available scripts (generators):
controller, create-controller args : Creates a controller
model, create-model args : Creates a model
test, create-test args : Creates a test
view, create-view args : Creates a view
crud, generate-all args : Creates a scaffold
help : Show help
$ 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 server # running server (default in cluster mode)
- Browse your application to http://localhost:3000
Available 7 themes default
, black
, blue
, green
, orange
, pink
, violet
. Default theme violet
.
$ trinte init AppName theme
// Shows help
$ trinte help
$ trinte script help generate-all
// Creates all (model, views, controller, tests)
$ trinte script generate-all User
or the same
$ trinte g crud 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.
// format: trinte script create-model [model name] [field(s)]
// Create Post model without fields
$ trinte script create-model Post
or the same
$ trinte g 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.
// Creates a controller
$ trinte script create-controller Post
or the same
$ trinte g controller Post
// Creates views
$ trinte script create-view Post
or the same
$ trinte g view Post
// Creates tests
$ trinte script create-test HelloWorld
// Creates all (model, views, controller, tests)
// all scripts will be generated in the folder 'namespase' name
// as example app/admin/*
$ trinte script generate-all admin#User
or the same
$ trinte g crud admin#User
// create User model and etc. with fields: name, email, password, active
$ trinte script generate-all admin#User name email password active:boolean
- See all valid field types here.
$ 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
Following are all valid field types.
String
Number
Date
Boolean
Text
Learn more on CaminteJS.
/config/configuration.js
module.exports = {
port : 3000,
session: {
maxAge : 8640000,
key : "trinte",
secret : "Web-based Application"
},
parser : {
encoding : "utf-8",
keepExtensions : true
} ...
/config/database.js
module.exports = {
db: {
driver : "mongoose",
host : "localhost",
port : "27017",
username : "",
password : "",
database : "trinte-dev"
} ...
On initialization directories tree generated, like that:
.
|-- config
| |-- configuration.js
| |-- database.js
| |-- development.js
| |-- production.js
| `-- test.js
|-- tools
| `-- inflection.js
|-- app
| |-- models
| | |-- Category.js
| | |-- Post.js
| | `-- User.js
| |-- controllers
| | |-- AppController.js
| | `-- PostsController.js
| |-- heplers
| | |-- ApplicationHelper.js
| | `-- ModelsHelper.js
| |-- lib
| | `-- pager.js
| `-- views
| |-- app
| | `-- index.ejs
| `-- posts
| | |-- edit.ejs
| | |-- index.ejs
| | `-- new.ejs
| |-- errors
| | |-- 404.ejs
| } `-- 500.ejs
| |-- default_layout.ejs
| |-- error_layout.ejs
| `-- messages.ejs
|-- public
| |-- css
| | `-- ...
| |-- js
| | `-- ...
| `-- img
| | `-- ...
|-- package.json
|-- app.js
`-- app-cluster.js
/config/routes.js
- resourceful routes
- generic routes
- url helpers
- namespaces
- custom helper names / paths for resources
- named parameters in url helpers
Example:
map.get('/test/:param1/:param2', 'controller#action');
map.pathTo.test({param1: 'foo', param2: 'bar'}); // '/test/foo/bar'
Example:
map.resource('post');
Will generate the following routes:
method route controller#action helper method
--------------------------------------------------------------------------
GET /posts posts#index pathTo.posts()
GET /post/:id posts#show pathTo.show_post(id)
POST /post posts#create pathTo.create_posts()
GET /post/new posts#new pathTo.new_post()
GET /post/edit/:id posts#edit pathTo.edit_post(id)
DELETE /post/:id posts#destroy pathTo.destroy_post(id)
PUT /post/:id posts#update pathTo.update_post(id)
DELETE /posts posts#destroyall pathTo.destroy_posts()
Singleton resources can also have nested resources. For example:
map.resource('users', function(users) {
users.resources('posts');
});
Will generate the following routes:
method route controller#action helper method
--------------------------------------------------------------------------
GET /users/:user_id/posts posts#index pathTo.users_posts(user_id)
GET /users/:user_id/post/:id posts#show pathTo.show_users_post(user_id, id)
POST /users/:user_id/post posts#create pathTo.create_users_posts(user_id)
GET /users/:user_id/post/new posts#new pathTo.new_users_post(user_id)
GET /users/:user_id/post/edit/:id posts#edit pathTo.edit_users_post(user_id, id)
DELETE /users/:user_id/post/:id posts#destroy pathTo.destroy_users_post(user_id, id)
PUT /users/:user_id/post/:id posts#update pathTo.update_users_post(user_id, id)
DELETE /users/:user_id/posts posts#destroyall pathTo.destroy_users_posts(user_id)
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+$/);
- express-useragent NodeJS user-agent middleware.
- express-mongodb MongoDB Session Storage for ExpressJS.
- csrf CSRF protection middleware.
- CaminteJS - Cross-db ORM for NodeJS
- 2CO - is the module that will provide nodejs adapters for 2checkout API payment gateway.
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.
- Node.js: Amazing javascript asynchronous IO library, install manually.
- NPM: Node package manager, used to install:
- Express.Js: Application Framework for Node.js
- Caminte.Js: Node.JS ORM for Any DB.
- 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.
Aleksej Gordejev ([email protected]).
(The MIT License)
Copyright (c) 2012 Aleksej Gordejev [email protected]
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.
- Visit the author website.
- Follow @biggora on Twitter for updates.
- Report issues on the github issues page.