技术选型

  • nodejs
  • mongodb
  • h5
  • 前后端分离

前后端分离

  • 前端
    • public下面的采用nginx做反向代理
    • 其他的采用express+jade精简代码(ajax与后端交互)
  • 后端json api

实例https://github.com/moajs/moa-frontend/blob/master/config/nginx.example.conf

  1. server {
  2. listen 8000;
  3. server_name localhost;
  4. #charset koi8-r;
  5. #access_log logs/host.access.log main;
  6. # redirect server error pages to the static page /50x.html
  7. #
  8. error_page 500 502 503 504 /50x.html;
  9. location = /50x.html {
  10. root html;
  11. }
  12. location / {
  13. proxy_redirect off;
  14. proxy_set_header Host $host;
  15. proxy_set_header X-Real-IP $remote_addr;
  16. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  17. proxy_set_header Host $http_host;
  18. proxy_set_header X-NginX-Proxy true;
  19. proxy_pass http://127.0.0.1:3010;
  20. proxy_redirect off;
  21. }
  22. # Load configuration files for the default server block.
  23. # include /etc/nginx/default.d/*.conf;
  24. # Load configuration files for the default server block.
  25. include /etc/nginx/default.d/*.conf;
  26. location /api {
  27. proxy_set_header X-Real-IP $remote_addr;
  28. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  29. proxy_set_header Host $http_host;
  30. proxy_set_header X-NginX-Proxy true;
  31. proxy_pass http://127.0.0.1:3005;
  32. proxy_redirect off;
  33. }
  34. }

注意

  • listen 8000; (nginx端口8000)
  • location / (前端端口3010)
  • location /api (后端端口3005)

后端api

前端h5

  • zepto
  • weui
  • iscroll
  • fastclick
  • swiper

高级h5

  • vux
  • jmui