├── .gitignore
├── LICENSE
├── README.md
├── app-mode
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── global.js
│ │ │ └── middleware.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── hook.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ ├── session.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── development.js
│ ├── production.js
│ └── testing.js
├── crontab
├── .gitignore
├── .thinkjsrc
├── README.md
├── app
│ ├── bootstrap
│ │ ├── global.js
│ │ └── middleware.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── error.js
│ │ ├── hook.js
│ │ ├── locale
│ │ │ └── en.js
│ │ ├── session.js
│ │ └── view.js
│ ├── controller
│ │ ├── base.js
│ │ ├── error.js
│ │ └── index.js
│ ├── logic
│ │ └── index.js
│ └── model
│ │ └── index.js
├── nginx.conf
├── package.json
├── pm2.json
├── view
│ ├── error_400.html
│ ├── error_403.html
│ ├── error_404.html
│ ├── error_500.html
│ ├── error_503.html
│ └── index_index.html
└── www
│ ├── README.md
│ ├── development.js
│ ├── production.js
│ └── testing.js
├── file-download
├── .gitignore
├── .thinkjsrc
├── README.md
├── app
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── hook.js
│ │ │ └── start.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── nginx.conf
├── package.json
├── pm2.json
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── file-session
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── global.js
│ │ │ └── middleware.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── hook.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ ├── session.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ ├── index.js
│ │ └── session.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── file-upload
├── .gitignore
├── .thinkjsrc
├── README.md
├── app
│ ├── bootstrap
│ │ ├── hook.js
│ │ └── start.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── locale
│ │ │ └── en.js
│ │ └── view.js
│ ├── controller
│ │ ├── base.js
│ │ ├── error.js
│ │ └── index.js
│ ├── logic
│ │ └── index.js
│ └── model
│ │ └── index.js
├── nginx.conf
├── package.json
├── pm2.json
├── view
│ ├── error_400.html
│ ├── error_403.html
│ ├── error_404.html
│ ├── error_500.html
│ ├── error_503.html
│ ├── index_index.html
│ └── index_upload.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ ├── testing.js
│ └── upload
│ └── _AQM3QSz3nfWJdAndt1oS_xb.js
├── logic-rules
├── .thinkjsrc
├── README.md
├── app
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── global.js
│ │ │ └── middleware.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── error.js
│ │ │ ├── hook.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ ├── session.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── nginx.conf
├── package.json
├── pm2.json
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── development.js
│ ├── production.js
│ └── testing.js
├── middleware-ip-filter
├── .thinkjsrc
├── README.md
├── app
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── hook.js
│ │ │ └── start.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── hook.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── nginx.conf
├── package.json
├── pm2.json
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── mini-project
├── .gitignore
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── bootstrap
│ │ ├── hook.js
│ │ └── start.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── locale
│ │ │ └── en.js
│ │ └── view.js
│ ├── controller
│ │ ├── base.js
│ │ ├── error.js
│ │ └── index.js
│ ├── logic
│ │ └── index.js
│ └── model
│ │ └── index.js
├── view
│ ├── error_400.html
│ ├── error_403.html
│ ├── error_404.html
│ ├── error_500.html
│ ├── error_503.html
│ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── model-mongo
├── .gitignore
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── hook.js
│ │ │ └── start.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── user.js
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── model-mongo2.1
├── .gitignore
├── .thinkjsrc
├── README.md
├── app
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── global.js
│ │ │ └── middleware.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── error.js
│ │ │ ├── hook.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ ├── session.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── nginx.conf
├── package.json
├── pm2.json
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── development.js
│ ├── production.js
│ └── testing.js
├── model-mysql
├── .gitignore
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── hook.js
│ │ │ └── start.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── user.js
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── model-relation
├── .gitignore
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── hook.js
│ │ │ └── start.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ └── view.js
│ │ ├── controller
│ │ │ └── error.js
│ │ └── model
│ │ │ ├── info.js
│ │ │ ├── post.js
│ │ │ └── user.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── mongo-rest
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── bootstrap
│ │ ├── hook.js
│ │ └── start.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── locale
│ │ │ └── en.js
│ │ └── view.js
│ ├── controller
│ │ ├── base.js
│ │ ├── error.js
│ │ ├── index.js
│ │ └── user.js
│ ├── logic
│ │ ├── index.js
│ │ └── uesr.js
│ └── model
│ │ └── index.js
├── view
│ ├── error_400.html
│ ├── error_403.html
│ ├── error_404.html
│ ├── error_500.html
│ ├── error_503.html
│ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── normal-app
├── .gitignore
├── .thinkjsrc
├── README.md
├── app
│ ├── bootstrap
│ │ ├── hook.js
│ │ └── start.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── locale
│ │ │ └── en.js
│ │ └── view.js
│ ├── controller
│ │ └── home
│ │ │ ├── base.js
│ │ │ ├── error.js
│ │ │ └── index.js
│ ├── logic
│ │ └── home
│ │ │ └── index.js
│ └── model
│ │ └── index.js
├── nginx.conf
├── package.json
├── pm2.json
├── view
│ └── home
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ ├── error_503.html
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── nunjucks-locale
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── bootstrap
│ │ ├── global.js
│ │ └── middleware.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── error.js
│ │ ├── hook.js
│ │ ├── locale
│ │ │ ├── en.js
│ │ │ └── zh-CN.js
│ │ ├── session.js
│ │ └── view.js
│ ├── controller
│ │ ├── base.js
│ │ ├── error.js
│ │ └── index.js
│ ├── logic
│ │ └── index.js
│ └── model
│ │ └── index.js
├── view
│ ├── error_400.html
│ ├── error_403.html
│ ├── error_404.html
│ ├── error_500.html
│ ├── error_503.html
│ └── index_index.html
└── www
│ ├── README.md
│ ├── development.js
│ ├── production.js
│ └── testing.js
├── sqlite-rest
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── common
│ │ ├── adapter
│ │ │ └── session
│ │ │ │ └── xxx.js
│ │ ├── bootstrap
│ │ │ ├── hook.js
│ │ │ └── start.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ └── view.js
│ │ ├── controller
│ │ │ ├── error.js
│ │ │ └── user.js
│ │ └── logic
│ │ │ └── user.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ ├── index.js
│ │ └── user.js
│ │ ├── logic
│ │ ├── index.js
│ │ └── user.js
│ │ └── model
│ │ └── index.js
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── template-handlebars
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── bootstrap
│ │ ├── global.js
│ │ └── middleware.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── hook.js
│ │ ├── locale
│ │ │ └── en.js
│ │ ├── session.js
│ │ └── view.js
│ ├── controller
│ │ ├── base.js
│ │ ├── error.js
│ │ └── index.js
│ ├── logic
│ │ └── index.js
│ └── model
│ │ └── index.js
├── view
│ ├── error_400.html
│ ├── error_403.html
│ ├── error_404.html
│ ├── error_500.html
│ ├── error_503.html
│ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── template-nunjucks
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── bootstrap
│ │ ├── hook.js
│ │ └── start.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── hook.js
│ │ ├── locale
│ │ │ └── en.js
│ │ └── view.js
│ ├── controller
│ │ ├── base.js
│ │ ├── error.js
│ │ └── index.js
│ ├── logic
│ │ └── index.js
│ └── model
│ │ └── index.js
├── view
│ ├── error_400.html
│ ├── error_403.html
│ ├── error_404.html
│ ├── error_500.html
│ ├── error_503.html
│ ├── index_index.html
│ ├── parent.html
│ └── test.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
├── template-nunjucks2.1
├── .gitignore
├── .thinkjsrc
├── README.md
├── app
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── global.js
│ │ │ └── middleware.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── error.js
│ │ │ ├── hook.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ ├── session.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── nginx.conf
├── package.json
├── pm2.json
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ ├── index_index.html
│ │ └── parent.html
└── www
│ ├── README.md
│ ├── development.js
│ ├── production.js
│ └── testing.js
├── v1-rest
├── .gitignore
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── api
│ │ ├── config
│ │ │ └── config.js
│ │ ├── controller
│ │ │ ├── base.js
│ │ │ ├── index.js
│ │ │ └── v1
│ │ │ │ └── gdasapi.js
│ │ ├── logic
│ │ │ └── index.js
│ │ └── model
│ │ │ └── index.js
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── global.js
│ │ │ └── middleware.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── error.js
│ │ │ ├── hook.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ ├── route.js
│ │ │ ├── session.js
│ │ │ └── view.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── view
│ ├── api
│ │ └── index_index.html
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── development.js
│ ├── production.js
│ └── testing.js
├── websocket-socket.io
├── .gitignore
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
│ ├── common
│ │ ├── bootstrap
│ │ │ ├── hook.js
│ │ │ └── start.js
│ │ ├── config
│ │ │ ├── config.js
│ │ │ ├── db.js
│ │ │ ├── env
│ │ │ │ ├── development.js
│ │ │ │ ├── production.js
│ │ │ │ └── testing.js
│ │ │ ├── locale
│ │ │ │ └── en.js
│ │ │ ├── view.js
│ │ │ └── websocket.js
│ │ └── controller
│ │ │ └── error.js
│ └── home
│ │ ├── config
│ │ └── config.js
│ │ ├── controller
│ │ ├── base.js
│ │ └── index.js
│ │ ├── logic
│ │ └── index.js
│ │ └── model
│ │ └── index.js
├── view
│ ├── common
│ │ ├── error_400.html
│ │ ├── error_403.html
│ │ ├── error_404.html
│ │ ├── error_500.html
│ │ └── error_503.html
│ └── home
│ │ └── index_index.html
└── www
│ ├── README.md
│ ├── index.js
│ ├── production.js
│ └── testing.js
└── websocket-sockjs
├── .gitignore
├── .thinkjsrc
├── README.md
├── nginx.conf
├── package.json
├── pm2.json
├── src
├── common
│ ├── bootstrap
│ │ ├── hook.js
│ │ └── start.js
│ ├── config
│ │ ├── config.js
│ │ ├── db.js
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── testing.js
│ │ ├── locale
│ │ │ └── en.js
│ │ ├── view.js
│ │ └── websocket.js
│ └── controller
│ │ └── error.js
└── home
│ ├── config
│ └── config.js
│ ├── controller
│ ├── base.js
│ └── index.js
│ ├── logic
│ └── index.js
│ └── model
│ └── index.js
├── view
├── common
│ ├── error_400.html
│ ├── error_403.html
│ ├── error_404.html
│ ├── error_500.html
│ └── error_503.html
└── home
│ └── index_index.html
└── www
├── README.md
├── index.js
├── production.js
└── testing.js
/README.md:
--------------------------------------------------------------------------------
1 | # thinkjs2-demos
2 | ThinkJS 2.0 demos
3 |
--------------------------------------------------------------------------------
/app-mode/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-11-14 07:37:41",
3 | "mode": "module",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/app-mode/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/app-mode/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/development.js"
7 | },
8 | "dependencies": {
9 | "thinkjs": "2.0.x"
10 | }
11 | }
--------------------------------------------------------------------------------
/app-mode/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "app-mode",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/app-mode",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/app-mode/src/common/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/app-mode/src/common/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
--------------------------------------------------------------------------------
/app-mode/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/app-mode/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/app-mode/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/app-mode/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/app-mode/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/app-mode/src/common/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 | export default {
8 |
9 | }
--------------------------------------------------------------------------------
/app-mode/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/app-mode/src/common/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * session configs
5 | */
6 | export default {
7 | name: 'thinkjs',
8 | type: 'file',
9 | secret: 'IQ#*Z$(1',
10 | timeout: 24 * 3600,
11 | cookie: { // cookie options
12 | length: 32,
13 | httponly: true
14 | },
15 | adapter: {
16 | file: {
17 | path: think.getPath('common', 'runtime') + '/session',
18 | }
19 | }
20 | };
--------------------------------------------------------------------------------
/app-mode/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | type: 'ejs',
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | adapter: {
12 | ejs: {}
13 | }
14 | };
--------------------------------------------------------------------------------
/app-mode/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/app-mode/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/app-mode/src/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | //auto render template file index_index.html
12 | return this.display();
13 | }
14 | }
--------------------------------------------------------------------------------
/app-mode/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/app-mode/src/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/app-mode/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/app-mode/www/development.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.compile(true);
14 |
15 | instance.run();
--------------------------------------------------------------------------------
/app-mode/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/app-mode/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/crontab/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
32 |
--------------------------------------------------------------------------------
/crontab/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2016-01-12 09:57:18",
3 | "mode": "normal"
4 | }
--------------------------------------------------------------------------------
/crontab/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/crontab/app/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
13 |
14 | var crontab = require('node-crontab');
15 |
16 | console.log('bootstrap/global')
17 | // 1 分钟执行一次
18 | var jobId = crontab.scheduleJob("*/1 * * * *", function(){
19 | var d = new Date();
20 | console.log('conrtab callback', d.getMinutes(), Date.now());
21 | return think.http('/index/test', true);
22 | });
23 |
--------------------------------------------------------------------------------
/crontab/app/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
15 |
--------------------------------------------------------------------------------
/crontab/app/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/crontab/app/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'mysql',
8 | log_sql: true,
9 | log_connect: true,
10 | adapter: {
11 | mysql: {
12 | host: '127.0.0.1',
13 | port: '',
14 | database: '',
15 | user: '',
16 | password: '',
17 | prefix: 'think_',
18 | encoding: 'utf8'
19 | },
20 | mongo: {
21 |
22 | }
23 | }
24 | };
--------------------------------------------------------------------------------
/crontab/app/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/crontab/app/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/crontab/app/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/crontab/app/config/error.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * err config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | key: "errno", //error number
9 | msg: "errmsg" //error message
10 | };
--------------------------------------------------------------------------------
/crontab/app/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 |
8 | module.exports = {
9 |
10 | }
--------------------------------------------------------------------------------
/crontab/app/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/crontab/app/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | name: 'thinkjs',
5 | type: 'file',
6 | secret: '%V93CHBK',
7 | timeout: 24 * 3600,
8 | cookie: { // cookie options
9 | length: 32,
10 | httponly: true
11 | },
12 | adapter: {
13 | file: {
14 | path: think.getPath('common', 'runtime') + '/session',
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/crontab/app/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'ejs',
8 | content_type: 'text/html',
9 | file_ext: '.html',
10 | file_depr: '_',
11 | root_path: think.ROOT_PATH + '/view',
12 | adapter: {
13 | ejs: {}
14 | }
15 | };
--------------------------------------------------------------------------------
/crontab/app/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = think.controller({
4 | /**
5 | * some base method in here
6 | */
7 | });
--------------------------------------------------------------------------------
/crontab/app/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Base = require('./base.js');
4 |
5 | module.exports = think.controller(Base, {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction: function(self){
11 | //auto render template file index_index.html
12 | return self.display();
13 | },
14 | testAction: function(self){
15 | console.log('test');
16 | return self.success();
17 | }
18 | });
--------------------------------------------------------------------------------
/crontab/app/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | module.exports = think.logic({
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction: function(){
13 |
14 | }
15 | });
--------------------------------------------------------------------------------
/crontab/app/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | * @type {Class}
5 | */
6 | module.exports = think.model({
7 |
8 | });
--------------------------------------------------------------------------------
/crontab/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/development.js"
7 | },
8 | "dependencies": {
9 | "node-crontab": "0.0.8",
10 | "thinkjs": "2.1.x"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/crontab/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "crontab",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos//Users/welefen/Develop/git/thinkjs2-demos/crontab",
6 | "exec_mode": "cluster",
7 | "instances": 0,
8 | "max_memory_restart": "1G",
9 | "autorestart": true,
10 | "node_args": [],
11 | "args": [],
12 | "env": {
13 |
14 | }
15 | }]
16 | }
--------------------------------------------------------------------------------
/crontab/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | ### how to link resource
36 |
37 | *in template file*
38 |
39 | ```html
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | ```
48 |
49 | *link image in css*
50 |
51 | ```css
52 | .a{
53 | background: url(../img/a.png) no-repeat;
54 | }
55 | ```
--------------------------------------------------------------------------------
/crontab/www/development.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/crontab/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/crontab/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-download/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/file-download/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-29 10:09:31",
3 | "mode": "module",
4 | "es6": false
5 | }
--------------------------------------------------------------------------------
/file-download/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 |
11 | ## start server
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## deploy with pm2
18 |
19 | use pm2 to deploy app on production envrioment.
20 |
21 | ```
22 | pm2 startOrReload pm2.json
23 | ```
--------------------------------------------------------------------------------
/file-download/app/common/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/file-download/app/common/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/file-download/app/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/file-download/app/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/file-download/app/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/file-download/app/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/file-download/app/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/file-download/app/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/file-download/app/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | type: 'ejs',
12 | options: {}
13 | };
--------------------------------------------------------------------------------
/file-download/app/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/file-download/app/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = think.controller({
4 | /**
5 | * some base method in here
6 | */
7 | });
--------------------------------------------------------------------------------
/file-download/app/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Base = require('./base.js');
4 |
5 | module.exports = think.controller(Base, {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction: function(self){
11 | //auto render template file index_index.html
12 | return self.display();
13 | },
14 | downloadAction: function(){
15 | var file = __filename;
16 | this.download(file);
17 | }
18 | });
--------------------------------------------------------------------------------
/file-download/app/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | module.exports = think.logic({
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction: function(){
13 |
14 | }
15 | });
--------------------------------------------------------------------------------
/file-download/app/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | * @type {Class}
5 | */
6 | module.exports = think.model({
7 |
8 | });
--------------------------------------------------------------------------------
/file-download/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-project",
3 | "description": "project created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "thinkjs": "2.0.x"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/file-download/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "file-download",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/file-download",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/file-download/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/file-download/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-download/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-download/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-session/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-11-08 19:49:13",
3 | "mode": "module",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/file-session/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/file-session/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/ --retain-lines",
8 | "watch-compile": "node -e \"console.log(' no longer need, use command direct.');console.log();\"",
9 | "watch": "npm run watch-compile"
10 | },
11 | "dependencies": {
12 | "thinkjs": "2.0.x",
13 | "babel": "5.8.21",
14 | "babel-runtime": "5.6.17"
15 | }
16 | }
--------------------------------------------------------------------------------
/file-session/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "file-session",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/file-session",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/file-session/src/common/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/file-session/src/common/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
--------------------------------------------------------------------------------
/file-session/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/file-session/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/file-session/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/file-session/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/file-session/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/file-session/src/common/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 | export default {
8 |
9 | }
--------------------------------------------------------------------------------
/file-session/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/file-session/src/common/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * session configs
5 | */
6 | export default {
7 | name: 'thinkjs',
8 | type: 'file',
9 | secret: 'A$S51T3)',
10 | timeout: 24 * 3600,
11 | cookie: { // cookie options
12 | length: 32,
13 | httponly: true
14 | },
15 | adapter: {
16 | file: {
17 | path: think.getPath('common', 'runtime') + '/session',
18 | }
19 | }
20 | };
--------------------------------------------------------------------------------
/file-session/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | type: 'ejs',
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/file-session/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/file-session/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/file-session/src/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | //auto render template file index_index.html
12 | return this.display();
13 | }
14 | }
--------------------------------------------------------------------------------
/file-session/src/home/controller/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | async getAction(){
11 | let data = await this.session('userInfo');
12 | this.success(data);
13 | }
14 | async setAction(){
15 | let data = {
16 | name: this.get('name') || 'wwww'
17 | }
18 | await this.session('userInfo', data);
19 | return this.redirect('/session/get');
20 | }
21 | async deleteAction(){
22 | await this.session();
23 | return this.redirect('/session/get');
24 | }
25 | }
--------------------------------------------------------------------------------
/file-session/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/file-session/src/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/file-session/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/file-session/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | //watch compile code
13 | instance.compile(true);
14 |
15 | instance.run();
--------------------------------------------------------------------------------
/file-session/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-session/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-upload/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/file-upload/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-28 11:18:28",
3 | "mode": "mini",
4 | "es6": false
5 | }
--------------------------------------------------------------------------------
/file-upload/README.md:
--------------------------------------------------------------------------------
1 | ## README
2 |
3 | application created by [ThinkJS](http://www.thinkjs.org)
4 |
5 | ## install dependencies
6 |
7 | ```
8 | npm install
9 | ```
10 |
11 | ## start server
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## deploy with pm2
18 |
19 | ```
20 | pm2 startOrReload pm2.json
21 | ```
--------------------------------------------------------------------------------
/file-upload/app/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/file-upload/app/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/file-upload/app/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/file-upload/app/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/file-upload/app/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/file-upload/app/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/file-upload/app/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/file-upload/app/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/file-upload/app/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | type: 'ejs',
12 | options: {}
13 | };
--------------------------------------------------------------------------------
/file-upload/app/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = think.controller({
4 | /**
5 | * some base method in here
6 | */
7 | });
--------------------------------------------------------------------------------
/file-upload/app/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | module.exports = think.logic({
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction: function(){
13 |
14 | }
15 | });
--------------------------------------------------------------------------------
/file-upload/app/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | * @type {Class}
5 | */
6 | module.exports = think.model({
7 |
8 | });
--------------------------------------------------------------------------------
/file-upload/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-project",
3 | "description": "project created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "thinkjs": "2.0.x"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/file-upload/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "file-upload",
4 | "script": "production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/file-upload/www",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/file-upload/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/file-upload/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-upload/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-upload/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/file-upload/www/upload/_AQM3QSz3nfWJdAndt1oS_xb.js:
--------------------------------------------------------------------------------
1 | //循环体内有function
2 |
3 | var Benchmark = require('benchmark');
4 |
5 | var suite = new Benchmark.Suite();
6 |
7 |
8 | var fn1 = function(name){
9 | if (name === undefined) {
10 |
11 | };
12 | }
13 |
14 | var fn2 = function(name){
15 | if (arguments.length === 0) {
16 |
17 | };
18 | }
19 | suite.add('undefined', function (defer) {
20 | fn1();
21 | fn1("welefen");
22 | defer.resolve();
23 | }, {
24 | defer: true
25 | }).add('arguments', function (defer) {
26 | fn2();
27 | fn2("welefen");
28 | defer.resolve();
29 | }, {
30 | defer: true
31 | }).on('complete', function () {
32 | console.log('Fastest is ' + this.filter('fastest').pluck('name'));
33 | })
34 | .run({ async: true });
--------------------------------------------------------------------------------
/logic-rules/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-12-30 10:55:20",
3 | "mode": "module",
4 | "es6": false
5 | }
--------------------------------------------------------------------------------
/logic-rules/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/logic-rules/app/common/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/logic-rules/app/common/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
--------------------------------------------------------------------------------
/logic-rules/app/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/logic-rules/app/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | },
23 | adapter: {
24 | mysql: {},
25 | mongo: {}
26 | }
27 | };
--------------------------------------------------------------------------------
/logic-rules/app/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/logic-rules/app/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/logic-rules/app/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/logic-rules/app/common/config/error.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * err config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | key: "errno", //error number
9 | msg: "errmsg" //error message
10 | };
--------------------------------------------------------------------------------
/logic-rules/app/common/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 |
8 | module.exports = {
9 |
10 | }
--------------------------------------------------------------------------------
/logic-rules/app/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/logic-rules/app/common/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | name: 'thinkjs',
5 | type: 'file',
6 | secret: '*~23BTW7',
7 | timeout: 24 * 3600,
8 | cookie: { // cookie options
9 | length: 32,
10 | httponly: true
11 | },
12 | adapter: {
13 | file: {
14 | path: think.getPath('common', 'runtime') + '/session',
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/logic-rules/app/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'ejs',
8 | content_type: 'text/html',
9 | file_ext: '.html',
10 | file_depr: '_',
11 | root_path: think.ROOT_PATH + '/view',
12 | adapter: {
13 | ejs: {}
14 | }
15 | };
--------------------------------------------------------------------------------
/logic-rules/app/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/logic-rules/app/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = think.controller({
4 | /**
5 | * some base method in here
6 | */
7 | });
--------------------------------------------------------------------------------
/logic-rules/app/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Base = require('./base.js');
4 |
5 | module.exports = think.controller(Base, {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction: function(self){
11 | //auto render template file index_index.html
12 | return self.display();
13 | }
14 | });
--------------------------------------------------------------------------------
/logic-rules/app/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | module.exports = think.logic({
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction: function(){
13 | this.rules = {
14 | id: 'required|int'
15 | }
16 | }
17 | });
--------------------------------------------------------------------------------
/logic-rules/app/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | * @type {Class}
5 | */
6 | module.exports = think.model({
7 |
8 | });
--------------------------------------------------------------------------------
/logic-rules/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/development.js"
7 | },
8 | "dependencies": {
9 | "thinkjs": "2.0.x"
10 | }
11 | }
--------------------------------------------------------------------------------
/logic-rules/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "logic-rules",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/logic-rules",
6 | "exec_mode": "cluster",
7 | "instances": 0,
8 | "max_memory_restart": "1G",
9 | "autorestart": true,
10 | "node_args": [],
11 | "args": [],
12 | "env": {
13 |
14 | }
15 | }]
16 | }
--------------------------------------------------------------------------------
/logic-rules/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/logic-rules/www/development.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 |
14 |
15 | instance.run();
--------------------------------------------------------------------------------
/logic-rules/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/logic-rules/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/middleware-ip-filter/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-11-01 13:08:12",
3 | "mode": "module",
4 | "es6": false
5 | }
--------------------------------------------------------------------------------
/middleware-ip-filter/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
6 | var ipFilter = require('think-ip-filter');
7 | think.middleware('ip_filter', ipFilter);
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | ip_filter: function(){
8 | return Promise.resolve(['10.*'])
9 | }
10 | //key: value
11 | };
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/config/hook.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | request_begin: ['prepend', 'ip_filter']
3 | }
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/middleware-ip-filter/app/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | type: 'ejs',
12 | options: {}
13 | };
--------------------------------------------------------------------------------
/middleware-ip-filter/app/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/middleware-ip-filter/app/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = think.controller({
4 | /**
5 | * some base method in here
6 | */
7 | });
--------------------------------------------------------------------------------
/middleware-ip-filter/app/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Base = require('./base.js');
4 |
5 | module.exports = think.controller(Base, {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction: function(self){
11 | //auto render template file index_index.html
12 | return self.display();
13 | }
14 | });
--------------------------------------------------------------------------------
/middleware-ip-filter/app/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | module.exports = think.logic({
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction: function(){
13 |
14 | }
15 | });
--------------------------------------------------------------------------------
/middleware-ip-filter/app/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | * @type {Class}
5 | */
6 | module.exports = think.model({
7 |
8 | });
--------------------------------------------------------------------------------
/middleware-ip-filter/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "think-ip-filter": "^1.0.0",
14 | "thinkjs": "2.0.x"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/middleware-ip-filter/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "middleware-ip-filter",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/middleware-ip-filter",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/middleware-ip-filter/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/middleware-ip-filter/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/middleware-ip-filter/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/mini-project/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/mini-project/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-27 12:49:59",
3 | "mode": "mini",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/mini-project/README.md:
--------------------------------------------------------------------------------
1 | ## README
2 |
3 | application created by [ThinkJS](http://www.thinkjs.org)
4 |
5 | ## install dependencies
6 |
7 | ```
8 | npm install
9 | ```
10 |
11 |
12 | ## start server
13 |
14 | ```
15 | npm start
16 | ```
17 |
18 | ## deploy with pm2
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/mini-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-project",
3 | "description": "project created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "thinkjs": "2.0.x"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/mini-project/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "mini-project",
4 | "script": "production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/mini-project/www",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/mini-project/src/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/mini-project/src/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/mini-project/src/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/mini-project/src/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/mini-project/src/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/mini-project/src/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/mini-project/src/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/mini-project/src/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/mini-project/src/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | content_type: 'text/html',
7 | file_ext: '.html',
8 | file_depr: '_',
9 | root_path: think.ROOT_PATH + '/view',
10 | type: 'ejs',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/mini-project/src/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/mini-project/src/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | //auto render template file index_index.html
12 | return this.display();
13 | }
14 | }
--------------------------------------------------------------------------------
/mini-project/src/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/mini-project/src/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/mini-project/view/index_index.html:
--------------------------------------------------------------------------------
1 | hello thinkjs!
--------------------------------------------------------------------------------
/mini-project/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/mini-project/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | instance.compile(true);
13 | instance.run();
--------------------------------------------------------------------------------
/mini-project/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/mini-project/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-mongo/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/model-mongo/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-23 12:52:51",
3 | "mode": "module",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/model-mongo/README.md:
--------------------------------------------------------------------------------
1 | ## README
2 |
3 | application created by [ThinkJS](http://www.thinkjs.org)
4 |
5 | ## install dependencies
6 |
7 | ```
8 | npm install
9 | ```
10 |
11 |
12 | ## start server
13 |
14 | ```
15 | npm start
16 | ```
17 |
18 | ## deploy with pm2
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/model-mongo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-project",
3 | "description": "project created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "thinkjs": "2.0.x"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/model-mongo/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "model-mongo",
4 | "script": "production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/model-mongo/www",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/model-mongo/src/common/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/model-mongo/src/common/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/model-mongo/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/model-mongo/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | prefix: 'think_',
8 | encoding: 'utf8',
9 | nums_per_page: 10,
10 | log_sql: true,
11 | log_connect: true,
12 | cache: {
13 | on: true,
14 | type: '',
15 | timeout: 3600
16 | },
17 | options: {
18 | authSource: 'admin'
19 | }
20 | };
21 |
--------------------------------------------------------------------------------
/model-mongo/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mongo/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mongo/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mongo/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mongo/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | content_type: 'text/html',
7 | file_ext: '.html',
8 | file_depr: '_',
9 | root_path: think.ROOT_PATH + '/view',
10 | type: 'ejs',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/model-mongo/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/model-mongo/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/model-mongo/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/model-mongo/src/home/model/user.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 |
6 | export default class extends think.model.mongo {
7 | init(...args){
8 | super.init(...args);
9 | this.indexes = {
10 | name1: 1,
11 | test1: {
12 | name2: 1,
13 | title2: 1
14 | }
15 | }
16 | }
17 | addUser(){
18 | return this.add({
19 | name: 'welefen' + Math.random(),
20 | title: 'haha'
21 | })
22 | }
23 | }
--------------------------------------------------------------------------------
/model-mongo/view/home/index_index.html:
--------------------------------------------------------------------------------
1 | hello thinkjs!
--------------------------------------------------------------------------------
/model-mongo/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/model-mongo/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | instance.compile(true);
13 | instance.run();
--------------------------------------------------------------------------------
/model-mongo/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-mongo/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-mongo2.1/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
32 |
--------------------------------------------------------------------------------
/model-mongo2.1/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2016-01-09 13:14:49",
3 | "mode": "module"
4 | }
--------------------------------------------------------------------------------
/model-mongo2.1/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'mongo',
8 | log_sql: true,
9 | log_connect: true,
10 | adapter: {
11 | mongo: {
12 | host: '127.0.0.1',
13 | port: '',
14 | database: 'test',
15 | user: '',
16 | password: '',
17 | prefix: 'think_',
18 | encoding: 'utf8'
19 | }
20 | }
21 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/error.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * err config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | key: "errno", //error number
9 | msg: "errmsg" //error message
10 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 |
8 | module.exports = {
9 |
10 | }
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | name: 'thinkjs',
5 | type: 'file',
6 | secret: '$O~`S&U*',
7 | timeout: 24 * 3600,
8 | cookie: { // cookie options
9 | length: 32,
10 | httponly: true
11 | },
12 | adapter: {
13 | file: {
14 | path: think.getPath('common', 'runtime') + '/session',
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/model-mongo2.1/app/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'ejs',
8 | content_type: 'text/html',
9 | file_ext: '.html',
10 | file_depr: '_',
11 | root_path: think.ROOT_PATH + '/view',
12 | adapter: {
13 | ejs: {}
14 | }
15 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/model-mongo2.1/app/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = think.controller({
4 | /**
5 | * some base method in here
6 | */
7 | });
--------------------------------------------------------------------------------
/model-mongo2.1/app/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | module.exports = think.logic({
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction: function(){
13 |
14 | }
15 | });
--------------------------------------------------------------------------------
/model-mongo2.1/app/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | * @type {Class}
5 | */
6 | module.exports = think.model({
7 |
8 | });
--------------------------------------------------------------------------------
/model-mongo2.1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/development.js"
7 | },
8 | "dependencies": {
9 | "mongodb": "^2.0.48",
10 | "thinkjs": "2.x.x"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/model-mongo2.1/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "model-mongo2.1",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos//Users/welefen/Develop/git/thinkjs2-demos/model-mongo2.1",
6 | "exec_mode": "cluster",
7 | "instances": 0,
8 | "max_memory_restart": "1G",
9 | "autorestart": true,
10 | "node_args": [],
11 | "args": [],
12 | "env": {
13 |
14 | }
15 | }]
16 | }
--------------------------------------------------------------------------------
/model-mongo2.1/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/model-mongo2.1/www/development.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-mongo2.1/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-mongo2.1/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-mysql/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/model-mysql/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-22 10:54:49",
3 | "mode": "module",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/model-mysql/README.md:
--------------------------------------------------------------------------------
1 | ## README
2 |
3 | application created by [ThinkJS](http://www.thinkjs.org)
4 |
5 | ## install dependencies
6 |
7 | ```
8 | npm install
9 | ```
10 |
11 | ## start server
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## deploy with pm2
18 |
19 | ```
20 | pm2 startOrReload pm2.json
21 | ```
--------------------------------------------------------------------------------
/model-mysql/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-project",
3 | "description": "project created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "thinkjs": "2.0.x"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/model-mysql/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "model-mysql",
4 | "script": "production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/model-mysql/www",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/model-mysql/src/common/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/model-mysql/src/common/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/model-mysql/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/model-mysql/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | database: 'think_demo',
11 | user: 'root',
12 | pwd: 'root',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | //connectionLimit: 10,
19 | cache: {
20 | on: true,
21 | type: '',
22 | timeout: 3600
23 | }
24 | };
--------------------------------------------------------------------------------
/model-mysql/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mysql/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mysql/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mysql/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-mysql/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | content_type: 'text/html',
7 | file_ext: '.html',
8 | file_depr: '_',
9 | root_path: think.ROOT_PATH + '/view',
10 | type: 'ejs',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/model-mysql/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/model-mysql/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/model-mysql/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/model-mysql/view/home/index_index.html:
--------------------------------------------------------------------------------
1 | hello thinkjs!
--------------------------------------------------------------------------------
/model-mysql/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/model-mysql/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | instance.compile(true);
13 | instance.run();
--------------------------------------------------------------------------------
/model-mysql/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-mysql/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-relation/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/model-relation/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-25 19:22:13",
3 | "mode": "module",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/model-relation/README.md:
--------------------------------------------------------------------------------
1 | ## README
2 |
3 | application created by [ThinkJS](http://www.thinkjs.org)
4 |
5 | ## install dependencies
6 |
7 | ```
8 | npm install
9 | ```
10 |
11 |
12 | ## start server
13 |
14 | ```
15 | npm start
16 | ```
17 |
18 | ## deploy with pm2
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/model-relation/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-project",
3 | "description": "project created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "thinkjs": "2.0.x"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/model-relation/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "model-relation",
4 | "script": "production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/model-relation/www",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/model-relation/src/common/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/model-relation/src/common/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/model-relation/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/model-relation/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: 'think_demo',
11 | user: 'root',
12 | pwd: 'root',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/model-relation/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-relation/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-relation/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-relation/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/model-relation/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | content_type: 'text/html',
7 | file_ext: '.html',
8 | file_depr: '_',
9 | root_path: think.ROOT_PATH + '/view',
10 | type: 'ejs',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/model-relation/src/common/model/info.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * relation model
4 | */
5 | export default class extends think.model.relation {
6 | /**
7 | * init
8 | * @param {} args []
9 | * @return {} []
10 | */
11 | init(...args){
12 | super.init(...args);
13 |
14 | this.relation = {
15 | user: {
16 | type: think.model.BELONG_TO,
17 | relation: 'info'
18 | }
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/model-relation/src/common/model/post.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * relation model
4 | */
5 | export default class extends think.model.relation {
6 | relation = {
7 | cate: {
8 | type: think.model.MANY_TO_MANY,
9 | rModel: 'post_cate',
10 | //rfKey: 'cate_id'
11 | }
12 | }
13 | /**
14 | * init
15 | * @param {} args []
16 | * @return {} []
17 | */
18 | init(...args){
19 | super.init(...args);
20 |
21 | // this.relation = {
22 | // // comment: {
23 | // // type: think.model.HAS_MANY
24 | // // },
25 | // cate: {
26 | // type: think.model.MANY_TO_MANY,
27 | // rModel: 'post_cate',
28 | // //rfKey: 'cate_id'
29 | // }
30 | // }
31 | }
32 | }
--------------------------------------------------------------------------------
/model-relation/src/common/model/user.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * relation model
4 | */
5 | export default class extends think.model.relation {
6 | /**
7 | * init
8 | * @param {} args []
9 | * @return {} []
10 | */
11 | init(...args){
12 | super.init(...args);
13 |
14 | this.relation = {
15 | info: {
16 | type: think.model.HAS_ONE
17 | }
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/model-relation/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/model-relation/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/model-relation/src/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | async indexAction(){
11 | let model = this.model('post');
12 | let data = await model.select();
13 |
14 | this.success(data);
15 | //auto render template file index_index.html
16 | //return this.display();
17 | }
18 | }
--------------------------------------------------------------------------------
/model-relation/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/model-relation/src/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/model-relation/view/home/index_index.html:
--------------------------------------------------------------------------------
1 | hello thinkjs!
--------------------------------------------------------------------------------
/model-relation/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/model-relation/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | instance.compile(true);
13 | instance.run();
--------------------------------------------------------------------------------
/model-relation/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/model-relation/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/mongo-rest/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-30 19:33:23",
3 | "mode": "mini",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/mongo-rest/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/mongo-rest/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "thinkjs": "2.0.x",
12 | "babel": "5.8.21",
13 | "babel-runtime": "5.6.17"
14 | }
15 | }
--------------------------------------------------------------------------------
/mongo-rest/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "mongo-rest",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/mongo-rest",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/mongo-rest/src/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/mongo-rest/src/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/mongo-rest/src/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/mongo-rest/src/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mongo',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: 'demoee',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/mongo-rest/src/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/mongo-rest/src/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/mongo-rest/src/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/mongo-rest/src/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/mongo-rest/src/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | content_type: 'text/html',
7 | file_ext: '.html',
8 | file_depr: '_',
9 | root_path: think.ROOT_PATH + '/view',
10 | type: 'ejs',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/mongo-rest/src/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/mongo-rest/src/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | //auto render template file index_index.html
12 | return this.display();
13 | }
14 | }
--------------------------------------------------------------------------------
/mongo-rest/src/controller/user.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * rest controller
4 | * @type {Class}
5 | */
6 | export default class extends think.controller.rest {
7 | /**
8 | * init
9 | * @param {Object} http []
10 | * @return {} []
11 | */
12 | init(http){
13 | super.init(http);
14 | }
15 | /**
16 | * before magic method
17 | * @return {Promise} []
18 | */
19 | __before(){
20 |
21 | }
22 | }
--------------------------------------------------------------------------------
/mongo-rest/src/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/mongo-rest/src/logic/uesr.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/mongo-rest/src/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/mongo-rest/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/mongo-rest/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | instance.compile(true);
13 | instance.run();
--------------------------------------------------------------------------------
/mongo-rest/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/mongo-rest/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/normal-app/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/normal-app/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-29 10:23:40",
3 | "mode": "normal",
4 | "es6": false
5 | }
--------------------------------------------------------------------------------
/normal-app/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/normal-app/app/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/normal-app/app/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/normal-app/app/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/normal-app/app/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/normal-app/app/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/normal-app/app/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/normal-app/app/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/normal-app/app/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/normal-app/app/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | type: 'ejs',
12 | options: {}
13 | };
--------------------------------------------------------------------------------
/normal-app/app/controller/home/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = think.controller({
4 | /**
5 | * some base method in here
6 | */
7 | });
--------------------------------------------------------------------------------
/normal-app/app/controller/home/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Base = require('./base.js');
4 |
5 | module.exports = think.controller(Base, {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction: function(self){
11 | //auto render template file index_index.html
12 | return self.display();
13 | }
14 | });
--------------------------------------------------------------------------------
/normal-app/app/logic/home/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | module.exports = think.logic({
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction: function(){
13 | // this.rules = {
14 | // name: 'required'
15 | // }
16 | }
17 | });
--------------------------------------------------------------------------------
/normal-app/app/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | * @type {Class}
5 | */
6 | module.exports = think.model({
7 |
8 | });
--------------------------------------------------------------------------------
/normal-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "thinkjs": "2.0.x",
12 | "babel": "5.8.21",
13 | "babel-runtime": "5.6.17"
14 | }
15 | }
--------------------------------------------------------------------------------
/normal-app/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "normal-app",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/normal-app",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/normal-app/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/normal-app/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/normal-app/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/normal-app/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/nunjucks-locale/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-12-04 18:05:05",
3 | "mode": "mini",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/nunjucks-locale/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/nunjucks-locale/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/development.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/ --retain-lines",
8 | "watch-compile": "node -e \"console.log(' no longer need, use command direct.');console.log();\"",
9 | "watch": "npm run watch-compile"
10 | },
11 | "dependencies": {
12 | "babel": "5.8.21",
13 | "babel-runtime": "5.6.17",
14 | "nunjucks": "^2.1.0",
15 | "thinkjs": "2.0.x"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/nunjucks-locale/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "nunjucks-locale",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/nunjucks-locale",
6 | "exec_mode": "cluster",
7 | "instances": 0,
8 | "max_memory_restart": "1G",
9 | "autorestart": true,
10 | "node_args": [],
11 | "args": [],
12 | "env": {
13 |
14 | }
15 | }]
16 | }
--------------------------------------------------------------------------------
/nunjucks-locale/src/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/nunjucks-locale/src/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | },
23 | adapter: {
24 | mysql: {},
25 | mongo: {}
26 | }
27 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/error.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * err config
4 | */
5 | export default {
6 | //key: value
7 | key: "errno", //error number
8 | msg: "errmsg" //error message
9 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 | export default {
8 |
9 | }
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 | title: 'english'
5 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/locale/zh-CN.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 | title: '中文'
5 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * session configs
5 | */
6 | export default {
7 | name: 'thinkjs',
8 | type: 'file',
9 | secret: 'F~XDWIZ0',
10 | timeout: 24 * 3600,
11 | cookie: { // cookie options
12 | length: 32,
13 | httponly: true
14 | },
15 | adapter: {
16 | file: {
17 | path: think.getPath('common', 'runtime') + '/session',
18 | }
19 | }
20 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | type: 'nunjucks',
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | adapter: {
12 | ejs: {}
13 | }
14 | };
--------------------------------------------------------------------------------
/nunjucks-locale/src/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/nunjucks-locale/src/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | //auto render template file index_index.html
12 | return this.display();
13 | }
14 | }
--------------------------------------------------------------------------------
/nunjucks-locale/src/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/nunjucks-locale/src/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/nunjucks-locale/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/nunjucks-locale/www/development.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.compile({retainLines: true, log: true});
14 |
15 | instance.run();
--------------------------------------------------------------------------------
/nunjucks-locale/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/nunjucks-locale/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/sqlite-rest/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-31 18:13:21",
3 | "mode": "module",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/sqlite-rest/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/sqlite-rest/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "thinkjs": "2.0.x",
12 | "babel": "5.8.21",
13 | "babel-runtime": "5.6.17"
14 | }
15 | }
--------------------------------------------------------------------------------
/sqlite-rest/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "sqlite-rest",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/sqlite-rest",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/common/adapter/session/xxx.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * session adapter
4 | */
5 | export default class extends think.adapter.session {
6 | /**
7 | * init
8 | * @return {[]} []
9 | */
10 | init(...args){
11 | super.init(...args);
12 | }
13 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/common/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/sqlite-rest/src/common/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/sqlite-rest/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/sqlite-rest/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'sqlite',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/sqlite-rest/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/sqlite-rest/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/sqlite-rest/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/sqlite-rest/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/sqlite-rest/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | content_type: 'text/html',
7 | file_ext: '.html',
8 | file_depr: '_',
9 | root_path: think.ROOT_PATH + '/view',
10 | type: 'ejs',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/sqlite-rest/src/common/controller/user.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * rest controller
4 | * @type {Class}
5 | */
6 | export default class extends think.controller.rest {
7 | /**
8 | * init
9 | * @param {Object} http []
10 | * @return {} []
11 | */
12 | init(http){
13 | super.init(http);
14 | }
15 | /**
16 | * before magic method
17 | * @return {Promise} []
18 | */
19 | __before(){
20 |
21 | }
22 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/common/logic/user.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/sqlite-rest/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | //auto render template file index_index.html
12 | return this.display();
13 | }
14 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/home/controller/user.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * rest controller
4 | * @type {Class}
5 | */
6 | export default class extends think.controller.rest {
7 | /**
8 | * init
9 | * @param {Object} http []
10 | * @return {} []
11 | */
12 | init(http){
13 | super.init(http);
14 | }
15 | /**
16 | * before magic method
17 | * @return {Promise} []
18 | */
19 | __before(){
20 |
21 | }
22 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/home/logic/user.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/sqlite-rest/src/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/sqlite-rest/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | watch file change:
36 |
37 | ```
38 | npm run wacth-compile
39 | ```
40 |
41 | ### how to link resource
42 |
43 | *in template file*
44 |
45 | ```html
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | *link image in css*
56 |
57 | ```css
58 | .a{
59 | background: url(../img/a.png) no-repeat;
60 | }
61 | ```
--------------------------------------------------------------------------------
/sqlite-rest/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | instance.compile(true);
13 | instance.run();
--------------------------------------------------------------------------------
/sqlite-rest/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/sqlite-rest/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/template-handlebars/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-11-08 15:19:03",
3 | "mode": "mini",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/template-handlebars/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/template-handlebars/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/ --retain-lines",
8 | "watch-compile": "node -e \"console.log(' no longer need, use command direct.');console.log();\"",
9 | "watch": "npm run watch-compile"
10 | },
11 | "dependencies": {
12 | "babel": "5.8.21",
13 | "babel-runtime": "5.6.17",
14 | "think-template-handlebars": "^1.0.2",
15 | "thinkjs": "2.0.x"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/template-handlebars/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "template-handlebars",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/template-handlebars",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/template-handlebars/src/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
13 |
14 | import HandlebarseAdapter from 'think-template-handlebars';
15 | think.adapter('template', 'handlebars', HandlebarseAdapter);
16 |
17 |
18 | // console.log(thinkCache(thinkCache.ALIAS_EXPORT))
--------------------------------------------------------------------------------
/template-handlebars/src/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
--------------------------------------------------------------------------------
/template-handlebars/src/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/template-handlebars/src/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/template-handlebars/src/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/template-handlebars/src/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/template-handlebars/src/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/template-handlebars/src/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 | export default {
8 |
9 | }
--------------------------------------------------------------------------------
/template-handlebars/src/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/template-handlebars/src/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * session configs
5 | */
6 | export default {
7 | name: 'thinkjs',
8 | type: 'file',
9 | secret: 'Z^3M1GI&',
10 | timeout: 24 * 3600,
11 | cookie: { // cookie options
12 | length: 32,
13 | httponly: true
14 | },
15 | adapter: {
16 | file: {
17 | path: think.getPath('common', 'runtime') + '/session',
18 | }
19 | }
20 | };
--------------------------------------------------------------------------------
/template-handlebars/src/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | type: 'handlebars',
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/template-handlebars/src/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/template-handlebars/src/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | this.assign('name', 'thinkjs')
12 | //auto render template file index_index.html
13 | return this.display();
14 | }
15 | }
--------------------------------------------------------------------------------
/template-handlebars/src/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/template-handlebars/src/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/template-handlebars/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | //watch compile code
13 | instance.compile();
14 |
15 | instance.run();
--------------------------------------------------------------------------------
/template-handlebars/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/template-handlebars/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/template-nunjucks/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-31 19:57:55",
3 | "mode": "mini",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/template-nunjucks/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/template-nunjucks/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "nunjucks": "^2.1.0",
14 | "think-debug-toolbar": "^1.0.5",
15 | "thinkjs": "2.0.x"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/template-nunjucks/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "template-nunjucks",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/template-nunjucks",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/template-nunjucks/src/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 | 'use strict';
6 |
7 | import debugToolbar from 'think-debug-toolbar';
8 |
9 | let conf = {
10 | panels: ['request', 'session', 'view', 'template', 'response', 'config', 'info'],
11 | depth: 4,
12 | extra_attrs: '',
13 | disabled: false,
14 | sort: false
15 | };
16 |
17 | think.middleware('debug_toolbar', debugToolbar(conf));
--------------------------------------------------------------------------------
/template-nunjucks/src/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
13 |
14 | // let nunjucks = think.npm('nunjucks');
15 |
16 | // let env = nunjucks.configure();
17 | // env.addFilter('thinkjs2', () => {
18 | // return 111;
19 | // });
--------------------------------------------------------------------------------
/template-nunjucks/src/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/template-nunjucks/src/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/template-nunjucks/src/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/template-nunjucks/src/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/template-nunjucks/src/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/template-nunjucks/src/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 | view_filter : ['append', 'debug_toolbar'],
5 | }
--------------------------------------------------------------------------------
/template-nunjucks/src/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/template-nunjucks/src/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | type: 'nunjucks',
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | prerender: (nunjucks, env) => {
12 | console.log('prerender outside');
13 | },
14 | adapter: {
15 | nunjucks: {
16 | prerender: (nunjucks, env) => {
17 | console.log('prerender inside');
18 | env.addFilter('thinkjs', function(){
19 | return 1111;
20 | })
21 | }
22 | }
23 | }
24 | };
--------------------------------------------------------------------------------
/template-nunjucks/src/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/template-nunjucks/src/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | * indexAction(){
11 | this.assign('name', 'welefen')
12 | //auto render template file index_index.html
13 | return this.display();
14 | }
15 | }
--------------------------------------------------------------------------------
/template-nunjucks/src/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/template-nunjucks/src/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/template-nunjucks/view/index_index.html:
--------------------------------------------------------------------------------
1 | {%include './test.html'%}
--------------------------------------------------------------------------------
/template-nunjucks/view/parent.html:
--------------------------------------------------------------------------------
1 | <%include './test.html'%>
--------------------------------------------------------------------------------
/template-nunjucks/view/test.html:
--------------------------------------------------------------------------------
1 | www
--------------------------------------------------------------------------------
/template-nunjucks/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.compile(true);
14 |
15 | console.log('compile end')
16 | instance.run();
--------------------------------------------------------------------------------
/template-nunjucks/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/template-nunjucks/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/template-nunjucks2.1/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
32 |
--------------------------------------------------------------------------------
/template-nunjucks2.1/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2016-01-08 15:23:21",
3 | "mode": "module"
4 | }
--------------------------------------------------------------------------------
/template-nunjucks2.1/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'mysql',
8 | log_sql: true,
9 | log_connect: true,
10 | adapter: {
11 | mysql: {
12 | host: '127.0.0.1',
13 | port: '',
14 | database: '',
15 | user: '',
16 | password: '',
17 | prefix: 'think_',
18 | encoding: 'utf8'
19 | },
20 | mongo: {
21 |
22 | }
23 | }
24 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/error.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * err config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | key: "errno", //error number
9 | msg: "errmsg" //error message
10 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 |
8 | module.exports = {
9 |
10 | }
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 |
5 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | name: 'thinkjs',
5 | type: 'file',
6 | secret: '(7GWFZ$)',
7 | timeout: 24 * 3600,
8 | cookie: { // cookie options
9 | length: 32,
10 | httponly: true
11 | },
12 | adapter: {
13 | file: {
14 | path: think.getPath('common', 'runtime') + '/session',
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | type: 'nunjucks',
8 | content_type: 'text/html',
9 | file_ext: '.html',
10 | file_depr: '_',
11 | root_path: think.ROOT_PATH + '/view',
12 | adapter: {
13 | ejs: {}
14 | }
15 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | * @type {Object}
5 | */
6 | module.exports = {
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = think.controller({
4 | /**
5 | * some base method in here
6 | */
7 | });
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Base = require('./base.js');
4 |
5 | module.exports = think.controller(Base, {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction: function(self){
11 | //auto render template file index_index.html
12 | return self.display();
13 | }
14 | });
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | module.exports = think.logic({
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction: function(){
13 |
14 | }
15 | });
--------------------------------------------------------------------------------
/template-nunjucks2.1/app/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | * @type {Class}
5 | */
6 | module.exports = think.model({
7 |
8 | });
--------------------------------------------------------------------------------
/template-nunjucks2.1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/development.js"
7 | },
8 | "dependencies": {
9 | "thinkjs": "2.1.x"
10 | }
11 | }
--------------------------------------------------------------------------------
/template-nunjucks2.1/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "template-nunjucks2.1",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos//Users/welefen/Develop/git/thinkjs2-demos/template-nunjucks2.1",
6 | "exec_mode": "cluster",
7 | "instances": 0,
8 | "max_memory_restart": "1G",
9 | "autorestart": true,
10 | "node_args": [],
11 | "args": [],
12 | "env": {
13 |
14 | }
15 | }]
16 | }
--------------------------------------------------------------------------------
/template-nunjucks2.1/view/home/index_index.html:
--------------------------------------------------------------------------------
1 | {% extends "./parent.html" %}
--------------------------------------------------------------------------------
/template-nunjucks2.1/www/development.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/template-nunjucks2.1/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/template-nunjucks2.1/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/v1-rest/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
32 |
33 | app/
--------------------------------------------------------------------------------
/v1-rest/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2016-01-21 09:57:11",
3 | "mode": "module",
4 | "es": true
5 | }
--------------------------------------------------------------------------------
/v1-rest/README.md:
--------------------------------------------------------------------------------
1 |
2 | application created by [ThinkJS](http://www.thinkjs.org)
3 |
4 | ## install dependencies
5 |
6 | ```
7 | npm install
8 | ```
9 |
10 | ## start server
11 |
12 | ```
13 | npm start
14 | ```
15 |
16 | ## deploy with pm2
17 |
18 | use pm2 to deploy app on production envrioment.
19 |
20 | ```
21 | pm2 startOrReload pm2.json
22 | ```
--------------------------------------------------------------------------------
/v1-rest/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-application",
3 | "description": "application created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/development.js",
7 | "compile": "babel --presets es2015-loose,stage-1 --plugins transform-runtime src/ --out-dir app/ --retain-lines",
8 | "watch-compile": "node -e \"console.log(' no longer need, use command direct.');console.log();\"",
9 | "watch": "npm run watch-compile"
10 | },
11 | "dependencies": {
12 | "thinkjs": "2.1.x",
13 | "babel-runtime": "6.x.x"
14 | },
15 | "devDependencies": {
16 | "babel-cli": "6.x.x",
17 | "babel-preset-es2015-loose": "6.x.x",
18 | "babel-preset-stage-1": "6.x.x",
19 | "babel-plugin-transform-runtime": "6.x.x",
20 | "babel-core": "6.x.x"
21 | }
22 | }
--------------------------------------------------------------------------------
/v1-rest/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "v1-rest",
4 | "script": "www/production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos//Users/welefen/Develop/git/thinkjs2-demos/v1-rest",
6 | "exec_mode": "cluster",
7 | "instances": 0,
8 | "max_memory_restart": "1G",
9 | "autorestart": true,
10 | "node_args": [],
11 | "args": [],
12 | "env": {
13 |
14 | }
15 | }]
16 | }
--------------------------------------------------------------------------------
/v1-rest/src/api/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/v1-rest/src/api/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/v1-rest/src/api/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | //auto render template file index_index.html
12 | return this.display();
13 | }
14 | }
--------------------------------------------------------------------------------
/v1-rest/src/api/controller/v1/gdasapi.js:
--------------------------------------------------------------------------------
1 |
2 | export default class extends think.controller.rest {
3 | getAction(){
4 | return this.success('test');
5 | }
6 | }
--------------------------------------------------------------------------------
/v1-rest/src/api/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/v1-rest/src/api/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/v1-rest/src/common/bootstrap/global.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/v1-rest/src/common/bootstrap/middleware.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register middleware
4 | * https://thinkjs.org/doc/middleware.html
5 | */
6 |
7 | /**
8 | *
9 | * think.middleware('xxx', http => {
10 | *
11 | * })
12 | *
13 | */
14 |
--------------------------------------------------------------------------------
/v1-rest/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/v1-rest/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | log_sql: true,
9 | log_connect: true,
10 | adapter: {
11 | mysql: {
12 | host: '127.0.0.1',
13 | port: '',
14 | database: '',
15 | user: '',
16 | password: '',
17 | prefix: 'think_',
18 | encoding: 'utf8'
19 | },
20 | mongo: {
21 |
22 | }
23 | }
24 | };
--------------------------------------------------------------------------------
/v1-rest/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/v1-rest/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/v1-rest/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/v1-rest/src/common/config/error.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * err config
4 | */
5 | export default {
6 | //key: value
7 | key: "errno", //error number
8 | msg: "errmsg" //error message
9 | };
--------------------------------------------------------------------------------
/v1-rest/src/common/config/hook.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * hook config
5 | * https://thinkjs.org/doc/middleware.html#toc-df6
6 | */
7 | export default {
8 |
9 | }
--------------------------------------------------------------------------------
/v1-rest/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/v1-rest/src/common/config/route.js:
--------------------------------------------------------------------------------
1 | export default [
2 | [/^api\/gdasapi(.*)$/, 'api/v1/gdasapi:1']
3 | ]
--------------------------------------------------------------------------------
/v1-rest/src/common/config/session.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * session configs
5 | */
6 | export default {
7 | name: 'thinkjs',
8 | type: 'file',
9 | secret: '*B45HRJC',
10 | timeout: 24 * 3600,
11 | cookie: { // cookie options
12 | length: 32,
13 | httponly: true
14 | },
15 | adapter: {
16 | file: {
17 | path: think.getPath('common', 'runtime') + '/session',
18 | }
19 | }
20 | };
--------------------------------------------------------------------------------
/v1-rest/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | type: 'ejs',
7 | content_type: 'text/html',
8 | file_ext: '.html',
9 | file_depr: '_',
10 | root_path: think.ROOT_PATH + '/view',
11 | adapter: {
12 | ejs: {}
13 | }
14 | };
--------------------------------------------------------------------------------
/v1-rest/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/v1-rest/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/v1-rest/src/home/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Base from './base.js';
4 |
5 | export default class extends Base {
6 | /**
7 | * index action
8 | * @return {Promise} []
9 | */
10 | indexAction(){
11 | //auto render template file index_index.html
12 | return this.display();
13 | }
14 | }
--------------------------------------------------------------------------------
/v1-rest/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/v1-rest/src/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/v1-rest/www/README.md:
--------------------------------------------------------------------------------
1 | ## application
2 |
3 | ### start server
4 |
5 | *development*
6 |
7 | ```js
8 | node www/index.js
9 | ```
10 |
11 | *testing*
12 |
13 | ```js
14 | node www/testing.js
15 | ```
16 |
17 | *production*
18 |
19 | ```js
20 | node www/production.js
21 | ```
22 |
23 | or use pm2 to manage node:
24 |
25 | ```
26 | pm2 start www/production.js
27 | ```
28 |
29 | ### compile es6 code
30 |
31 | ```
32 | npm run compile
33 | ```
34 |
35 | ### how to link resource
36 |
37 | *in template file*
38 |
39 | ```html
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | ```
48 |
49 | *link image in css*
50 |
51 | ```css
52 | .a{
53 | background: url(../img/a.png) no-repeat;
54 | }
55 | ```
--------------------------------------------------------------------------------
/v1-rest/www/development.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | RUNTIME_PATH: rootPath + path.sep + 'runtime',
9 | ROOT_PATH: rootPath,
10 | RESOURCE_PATH: __dirname,
11 | env: 'development'
12 | });
13 |
14 | //compile src/ to app/
15 | instance.compile({
16 | retainLines: true,
17 | log: true
18 | });
19 |
20 | instance.run();
--------------------------------------------------------------------------------
/v1-rest/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | RUNTIME_PATH: rootPath + path.sep + 'runtime',
9 | ROOT_PATH: rootPath,
10 | RESOURCE_PATH: __dirname,
11 | env: 'production'
12 | });
13 |
14 | instance.run();
--------------------------------------------------------------------------------
/v1-rest/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + path.sep + 'app',
8 | RUNTIME_PATH: rootPath + path.sep + 'runtime',
9 | ROOT_PATH: rootPath,
10 | RESOURCE_PATH: __dirname,
11 | env: 'testing'
12 | });
13 |
14 | instance.run();
--------------------------------------------------------------------------------
/websocket-socket.io/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/websocket-socket.io/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-21 11:48:41",
3 | "mode": "module",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/websocket-socket.io/README.md:
--------------------------------------------------------------------------------
1 | ## README
2 |
3 | application created by [ThinkJS](http://www.thinkjs.org)
4 |
5 | ## install dependencies
6 |
7 | ```
8 | npm install
9 | ```
10 |
11 | ## start server
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## deploy with pm2
18 |
19 | ```
20 | pm2 startOrReload pm2.json
21 | ```
--------------------------------------------------------------------------------
/websocket-socket.io/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-project",
3 | "description": "project created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "thinkjs": "2.0.x"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/websocket-socket.io/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "websocket-socket.io",
4 | "script": "production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/websocket-socket.io/www",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //cluster_on: true //socket.io not support cluster mode
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | content_type: 'text/html',
7 | file_ext: '.html',
8 | file_depr: '_',
9 | root_path: think.ROOT_PATH + '/view',
10 | type: 'ejs',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/common/config/websocket.js:
--------------------------------------------------------------------------------
1 | export default {
2 | on: true, //是否开启 WebSocket
3 | type: "socket.io",
4 | allow_origin: "",
5 | sub_protocal: "",
6 | adapter: undefined,
7 | path: "", //url path for websocket
8 | messages: {
9 | open: 'home/index/open',
10 | close: 'home/index/close',
11 | chat: 'home/index/chat',
12 | typing: 'home/index/typing',
13 | stoptyping: 'home/index/stoptyping',
14 | adduser: 'home/index/adduser'
15 | }
16 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/websocket-socket.io/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/websocket-socket.io/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/websocket-socket.io/src/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/websocket-socket.io/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | instance.compile(true);
13 | instance.run();
--------------------------------------------------------------------------------
/websocket-socket.io/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/websocket-socket.io/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/websocket-sockjs/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage/
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Dependency directory
23 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
24 | node_modules/
25 |
26 | # IDE config
27 | .idea
28 |
29 | # output
30 | output/
31 | output.tar.gz
--------------------------------------------------------------------------------
/websocket-sockjs/.thinkjsrc:
--------------------------------------------------------------------------------
1 | {
2 | "createAt": "2015-10-21 11:48:47",
3 | "mode": "module",
4 | "es6": true
5 | }
--------------------------------------------------------------------------------
/websocket-sockjs/README.md:
--------------------------------------------------------------------------------
1 | ## README
2 |
3 | application created by [ThinkJS](http://www.thinkjs.org)
4 |
5 | ## install dependencies
6 |
7 | ```
8 | npm install
9 | ```
10 |
11 | ## start server
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## deploy with pm2
18 |
19 | ```
20 | pm2 startOrReload pm2.json
21 | ```
--------------------------------------------------------------------------------
/websocket-sockjs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "thinkjs-project",
3 | "description": "project created by thinkjs",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "start": "node www/index.js",
7 | "compile": "babel --loose all --optional runtime --stage 0 --modules common src/ --out-dir app/",
8 | "watch-compile": "npm run compile -- --watch"
9 | },
10 | "dependencies": {
11 | "babel": "5.8.21",
12 | "babel-runtime": "5.6.17",
13 | "thinkjs": "2.0.x"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/websocket-sockjs/pm2.json:
--------------------------------------------------------------------------------
1 | {
2 | "apps": [{
3 | "name": "websocket-sockjs",
4 | "script": "production.js",
5 | "cwd": "/Users/welefen/Develop/git/thinkjs2-demos/websocket-sockjs/www",
6 | "max_memory_restart": "1G",
7 | "autorestart": true,
8 | "node_args": [],
9 | "args": [],
10 | "env": {
11 |
12 | }
13 | }]
14 | }
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/bootstrap/hook.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can register app hook
4 | */
5 |
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/bootstrap/start.js:
--------------------------------------------------------------------------------
1 | /**
2 | * this file will be loaded before server started
3 | * you can define global functions used in controllers, models, templates
4 | */
5 |
6 | /**
7 | * use global.xxx to define global functions
8 | *
9 | * global.fn1 = function(){
10 | *
11 | * }
12 | */
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | cluster_on: true
7 | //key: value
8 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/config/db.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * db config
4 | * @type {Object}
5 | */
6 | export default {
7 | type: 'mysql',
8 | host: '127.0.0.1',
9 | port: '',
10 | name: '',
11 | user: '',
12 | pwd: '',
13 | prefix: 'think_',
14 | encoding: 'utf8',
15 | nums_per_page: 10,
16 | log_sql: true,
17 | log_connect: true,
18 | cache: {
19 | on: true,
20 | type: '',
21 | timeout: 3600
22 | }
23 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/config/env/testing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/config/locale/en.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default {
4 |
5 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/config/view.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * template config
4 | */
5 | export default {
6 | content_type: 'text/html',
7 | file_ext: '.html',
8 | file_depr: '_',
9 | root_path: think.ROOT_PATH + '/view',
10 | type: 'ejs',
11 | options: {}
12 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/common/config/websocket.js:
--------------------------------------------------------------------------------
1 | export default {
2 | on: true, //是否开启 WebSocket
3 | type: "sockjs",
4 | allow_origin: "",
5 | sub_protocal: "",
6 | adapter: undefined,
7 | path: "", //url path for websocket
8 | messages: {
9 | open: 'home/index/open',
10 | close: 'home/index/close',
11 | chat: 'home/index/chat',
12 | typing: 'home/index/typing',
13 | stoptyping: 'home/index/stoptyping',
14 | adduser: 'home/index/adduser'
15 | }
16 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/home/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * config
4 | */
5 | export default {
6 | //key: value
7 | };
--------------------------------------------------------------------------------
/websocket-sockjs/src/home/controller/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | export default class extends think.controller.base {
4 | /**
5 | * some base method in here
6 | */
7 | }
--------------------------------------------------------------------------------
/websocket-sockjs/src/home/logic/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * logic
4 | * @param {} []
5 | * @return {} []
6 | */
7 | export default class extends think.logic.base {
8 | /**
9 | * index action logic
10 | * @return {} []
11 | */
12 | indexAction(){
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/websocket-sockjs/src/home/model/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /**
3 | * model
4 | */
5 | export default class extends think.model.base {
6 |
7 | }
--------------------------------------------------------------------------------
/websocket-sockjs/www/index.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'development'
11 | });
12 | instance.compile(true);
13 | instance.run();
--------------------------------------------------------------------------------
/websocket-sockjs/www/production.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'production'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------
/websocket-sockjs/www/testing.js:
--------------------------------------------------------------------------------
1 | var thinkjs = require('thinkjs');
2 | var path = require('path');
3 |
4 | var rootPath = path.dirname(__dirname);
5 |
6 | var instance = new thinkjs({
7 | APP_PATH: rootPath + '/app',
8 | ROOT_PATH: rootPath,
9 | RESOURCE_PATH: __dirname,
10 | env: 'testing'
11 | });
12 |
13 | instance.run();
--------------------------------------------------------------------------------