Skip to content
Permalink
Browse files

update

  • Loading branch information...
welefen committed Jan 7, 2016
0 parents commit f2b7eb32082a13b0442e763eb7b8a33b9fb40386
Showing 577 changed files with 12,690 additions and 0 deletions.
@@ -0,0 +1,43 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

mini-project/app
model-mongo/app
model-mysql/app
model-relation/app
websocket-socket.io/app
websocket-sockjs/app
template-nunjucks/app/
sqlite-rest/app
mongo-rest/app
file-session/app
template-handlebars/app
watch-compile/app
app-mode/app

nunjucks-locale/app
22 LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 奇舞团

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

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

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

@@ -0,0 +1,2 @@
# thinkjs2-demos
ThinkJS 2.0 demos
@@ -0,0 +1,5 @@
{
"createAt": "2015-11-14 07:37:41",
"mode": "module",
"es6": true
}
@@ -0,0 +1,22 @@

application created by [ThinkJS](http://www.thinkjs.org)

## install dependencies

```
npm install
```

## start server

```
npm start
```

## deploy with pm2

use pm2 to deploy app on production envrioment.

```
pm2 startOrReload pm2.json
```
@@ -0,0 +1,43 @@
server {
listen 80;
server_name localhost;
root /Users/welefen/Develop/git/thinkjs2-demos/app-mode/www;
set $node_port 8360;

index index.js index.html index.htm;
if ( -f $request_filename/index.html ){
rewrite (.*) $1/index.html break;
}
if ( !-f $request_filename ){
rewrite (.*) /index.js;
}
location = /index.js {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:$node_port$request_uri;
proxy_redirect off;
}

location = /development.js {
deny all;
}

location = /testing.js {
deny all;
}

location = /production.js {
deny all;
}

location ~ /static/ {
etag on;
expires max;
}
}
@@ -0,0 +1,11 @@
{
"name": "thinkjs-application",
"description": "application created by thinkjs",
"version": "1.0.0",
"scripts": {
"start": "node www/development.js"
},
"dependencies": {
"thinkjs": "2.0.x"
}
}
@@ -0,0 +1,14 @@
{
"apps": [{
"name": "app-mode",
"script": "www/production.js",
"cwd": "/Users/welefen/Develop/git/thinkjs2-demos/app-mode",
"max_memory_restart": "1G",
"autorestart": true,
"node_args": [],
"args": [],
"env": {

}
}]
}
@@ -0,0 +1,12 @@
/**
* this file will be loaded before server started
* you can define global functions used in controllers, models, templates
*/

/**
* use global.xxx to define global functions
*
* global.fn1 = function(){
*
* }
*/
@@ -0,0 +1,13 @@
/**
* this file will be loaded before server started
* you can register middleware
* https://thinkjs.org/doc/middleware.html
*/

/**
*
* think.middleware('xxx', http => {
*
* })
*
*/
@@ -0,0 +1,7 @@
'use strict';
/**
* config
*/
export default {
//key: value
};
@@ -0,0 +1,23 @@
'use strict';
/**
* db config
* @type {Object}
*/
export default {
type: 'mysql',
host: '127.0.0.1',
port: '',
name: '',
user: '',
pwd: '',
prefix: 'think_',
encoding: 'utf8',
nums_per_page: 10,
log_sql: true,
log_connect: true,
cache: {
on: true,
type: '',
timeout: 3600
}
};
@@ -0,0 +1,5 @@
'use strict';

export default {

};
@@ -0,0 +1,5 @@
'use strict';

export default {

};
@@ -0,0 +1,5 @@
'use strict';

export default {

};
@@ -0,0 +1,9 @@
'use strict';

/**
* hook config
* https://thinkjs.org/doc/middleware.html#toc-df6
*/
export default {

}
@@ -0,0 +1,5 @@
'use strict';

export default {

};
@@ -0,0 +1,20 @@
'use strict';

/**
* session configs
*/
export default {
name: 'thinkjs',
type: 'file',
secret: 'IQ#*Z$(1',
timeout: 24 * 3600,
cookie: { // cookie options
length: 32,
httponly: true
},
adapter: {
file: {
path: think.getPath('common', 'runtime') + '/session',
}
}
};
@@ -0,0 +1,14 @@
'use strict';
/**
* template config
*/
export default {
type: 'ejs',
content_type: 'text/html',
file_ext: '.html',
file_depr: '_',
root_path: think.ROOT_PATH + '/view',
adapter: {
ejs: {}
}
};
@@ -0,0 +1,68 @@
'use strict';
/**
* error controller
*/
export default class extends think.controller.base {
/**
* display error page
* @param {Number} status []
* @return {Promise} []
*/
displayErrorPage(status){

let errorConfig = this.config('error');
let message = this.http.error && this.http.error.message || 'error';
if(this.isJsonp()){
return this.jsonp({
[errorConfig.key]: status,
[errorConfig.msg]: message
})
}else if(this.isAjax()){
return this.fail(status, message);
}

let module = 'common';
if(think.mode !== think.mode_module){
module = this.config('default_module');
}
let file = `${module}/error/${status}.html`;
let options = this.config('tpl');
options = think.extend({}, options, {type: 'ejs', file_depr: '_'});
return this.display(file, options);
}
/**
* Bad Request
* @return {Promise} []
*/
_400Action(){
return this.displayErrorPage(400);
}
/**
* Forbidden
* @return {Promise} []
*/
_403Action(){
return this.displayErrorPage(403);
}
/**
* Not Found
* @return {Promise} []
*/
_404Action(){
return this.displayErrorPage(404);
}
/**
* Internal Server Error
* @return {Promise} []
*/
_500Action(){
return this.displayErrorPage(500);
}
/**
* Service Unavailable
* @return {Promise} []
*/
_503Action(){
return this.displayErrorPage(503);
}
}
@@ -0,0 +1,7 @@
'use strict';
/**
* config
*/
export default {
//key: value
};
Oops, something went wrong.

0 comments on commit f2b7eb3

Please sign in to comment.
You can’t perform that action at this time.