Git Product home page Git Product logo

blog-backend's Introduction

前后端分离实践----blog's backend

前端地址---- blog's frontend

简介:通过vue.js框架与koa2框架分别搭建前后端,利用ngnix端口分发部署实现代码全分离,开发全分离。

nginx文件配置内容

   server {
   	listen       80;
   	server_name  localhost;
   	location / {
   	    proxy_pass http://127.0.0.1:8080;               #转发非api,与上传的静态资源的其他信息 
   	    proxy_redirect default;
   	}
   	location /api/ {
   	    proxy_pass http://127.0.0.1:3000/api/;          #转发至api接口
   	}
   		location ^~ /uploads/ {
   	    proxy_pass http://127.0.0.1:3000/uploads/;     #转发至上传的静态资源
   	}
   }

Getting Start

1. 开发环境
node.js 7.6+
mognodb 3.0+
2. 依赖于mongodb数据库

      先安装 mongodb 数据库,安装完成后运行数据库,开启27017(默认)端口

3. 克隆到本地,安装依赖,运行
> git clone https://github.com/FantasyGao/blog-backend.git
> cd blog-backend
> npm install 
> npm start

简要概述

1. 全部使用ES6语法,aysnc+await结构

2. 通过mongoose模块+promise模块操作mongodb数据库

3. 由jsonwebtoken模块完成权限控制

4. (可选)koa-sslify 模块,实现https,需要ssl证书和密钥

5. koa-multer模块协助完成静态文件上传

目录结构

➜  backend
.
├── README.md
├── app.js
├── node_modules
├── package.json
├── public
│   ├── images
│   ├── dist
│   └── upoloads
├── ssl
│   ├── server.cert
│   └── server.key
├── db
│   ├── config.js
│   └── model.js
├── api
│   ├── articleAPI.js
├── ├── userAPI.js
│   └── logAPI.js
├── route
│   ├── api.js
├── ├── auth.js
│   └── other.js
└── views
    ├── err.ejs
    └── index.ejs

License

MIT

blog-backend's People

Contributors

fantasygao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.