Skip to content

Commit

Permalink
refactor 升级thinkjs 到 3.x 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
tumobi committed Sep 8, 2017
1 parent 157482f commit 9b83144
Show file tree
Hide file tree
Showing 105 changed files with 1,501 additions and 2,519 deletions.
8 changes: 0 additions & 8 deletions .babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "think"
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ node_modules/
output/
output.tar.gz

runtime/
app/

runtime/
config.development.js
adapter.development.js
5 changes: 0 additions & 5 deletions .thinkjsrc

This file was deleted.

5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
+ 服务端api基于Node.js+ThinkJS+MySQL
+ 计划添加基于Vue.js的后台管理系统、PC版、Wap版

**注意:当前版本功能还未完善,请勿商用。**


本项目需要配合微信小程序端使用,GitHub: [https://github.com/tumobi/nideshop-mini-program](https://github.com/tumobi/nideshop-mini-program)


Expand Down Expand Up @@ -54,7 +51,7 @@ npm start

### 线上部署

+ 没有域名部署参考文档:[通过新浪云部署Node.js微信小程序商城(不用买域名、不用备案、不用配置https](http://www.jianshu.com/p/78a0f5f424e1)
+ 没有域名部署参考文档:[通过新浪云部署NideShop微信小程序商城(基于Node.js+MySQL+ThinkJS](http://www.jianshu.com/p/78a0f5f424e1)

+ 如有域名且已备案,可参考:[阿里云Ubuntu 16.04 下部署Node.js+MySQL微信小程序商城](http://www.jianshu.com/p/38d13a7c1b78)

Expand Down
16 changes: 16 additions & 0 deletions development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const Application = require('thinkjs');
const babel = require('think-babel');
const watcher = require('think-watcher');
const notifier = require('node-notifier');

const instance = new Application({
ROOT_PATH: __dirname,
watcher: watcher,
transpiler: [babel, {
presets: ['think-node']
}],
notifier: notifier.notify.bind(notifier),
env: 'development'
});

instance.run();
94 changes: 2 additions & 92 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
server {
listen 80;
server_name example.com www.example.com;
root /home/jiaciwang/Code/tmp/you_thinkjs/www;
root D:\projects\nideshop/www;
set $node_port 8360;

index index.js index.html index.htm;
Expand All @@ -22,99 +22,9 @@ server {
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;
}
}




## http/2 nginx conf

# server {
# listen 80;
# server_name example.com www.example.com;
# rewrite ^(.*) https://example.com$1 permanent;
# }
#
# server {
# listen 443 ssl http2 fastopen=3 reuseport;
# server_name www.thinkjs.org thinkjs.org;
# set $node_port 8360;
#
# root /home/jiaciwang/Code/tmp/you_thinkjs/www;
#
# keepalive_timeout 70;
#
# ssl_certificate /path/to/certificate;
# ssl_certificate_key /path/to/certificate.key;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA";
# ssl_prefer_server_ciphers on;

# # openssl dhparam -out dhparams.pem 2048
# ssl_dhparam /path/to/dhparams.pem;
#
# ssl_session_cache shared:SSL:10m;
# ssl_session_timeout 10m;
#
# ssl_session_ticket_key /path/to/tls_session_ticket.key;
# ssl_session_tickets on;
#
# ssl_stapling on;
# ssl_stapling_verify on;
# ssl_trusted_certificate /path/to/startssl_trust_chain.crt;
#
#
# add_header x-Content-Type-Options nosniff;
# add_header X-Frame-Options deny;
# add_header Strict-Transport-Security "max-age=16070400";
#
# 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 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 = /production.js {
# deny all;
# }
#
# location = /testing.js {
# deny all;
# }
#
# location ~ /static/ {
# etag on;
# expires max;
# }
#}

}
49 changes: 29 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,42 @@
"description": "application created by thinkjs",
"version": "1.0.0",
"scripts": {
"start": "node www/development.js",
"compile": "babel src/ --out-dir app/",
"watch-compile": "node -e \"console.log('<npm run watch-compile> no longer need, use <npm start> command direct.');console.log();\"",
"watch": "npm run watch-compile"
"start": "node development.js",
"compile": "babel --no-babelrc src/ --presets think-node --out-dir app/",
"lint": "eslint src/",
"lint-fix": "eslint --fix src/"
},
"dependencies": {
"babel-runtime": "6.x.x",
"cheerio": "^0.22.0",
"gm": "^1.23.0",
"jsonwebtoken": "^7.4.1",
"jsonwebtoken": "^8.0.0",
"lodash": "^4.17.4",
"moment": "^2.18.1",
"redis": "^2.3.0",
"request": "^2.81.0",
"request-promise": "^4.2.1",
"source-map-support": "0.4.0",
"think-cors": "^1.1.2",
"thinkjs": "2.2.x",
"uid-safe": "^2.1.4"
"think-cache": "^1.0.0",
"think-cache-file": "^1.0.8",
"think-logger3": "^1.0.0",
"think-model": "^1.0.0",
"think-model-mysql": "^1.0.0",
"think-session": "^1.0.0",
"think-session-file": "^1.0.5",
"think-view": "^1.0.0",
"think-view-nunjucks": "^1.0.1",
"thinkjs": "^3.0.0"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-1": "^6.16.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-core": "^6.20.0"
"babel-cli": "^6.24.1",
"babel-preset-think-node": "^1.0.0",
"node-notifier": "^5.0.2",
"think-watcher": "^3.0.0",
"think-inspect": "0.0.2",
"think-babel": "^1.0.3",
"eslint": "^4.2.0",
"eslint-config-think": "^1.0.0"
},
"repository": "",
"license": "MIT"
}
"license": "MIT",
"engines": {
"node": ">=6.0.0"
},
"readmeFilename": "README.md"
}
11 changes: 5 additions & 6 deletions pm2.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"apps": [{
"name": "you_thinkjs",
"script": "www/production.js",
"cwd": "/home/jiaciwang/Code/tmp/you_thinkjs",
"exec_mode": "cluster",
"instances": 0,
"name": "nideshop",
"script": "production.js",
"cwd": "/var/www/nideshop",
"exec_mode": "fork",
"max_memory_restart": "1G",
"autorestart": true,
"node_args": [],
Expand All @@ -13,4 +12,4 @@

}
}]
}
}
9 changes: 9 additions & 0 deletions production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Application = require('thinkjs');

const instance = new Application({
ROOT_PATH: __dirname,
proxy: true, // use proxy
env: 'production'
});

instance.run();
7 changes: 0 additions & 7 deletions src/admin/config/config.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/admin/controller/base.js

This file was deleted.

84 changes: 0 additions & 84 deletions src/admin/controller/brand.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/admin/controller/index.js

This file was deleted.

Loading

0 comments on commit 9b83144

Please sign in to comment.