You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rap2-delos/README.md

149 lines
3.8 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# RAP2-DELOS 开源社区版本 (后端 API 服务器)
[![Build Status](https://travis-ci.org/thx/rap2-delos.svg?branch=master)](https://travis-ci.org/thx/rap2-delos)
RAP2 是在 RAP1 基础上重做的新项目,它包含两个组件(对应两个 Github Repository)。
- rap2-delos: 后端数据 API 服务器,基于 Koa + MySQL[link](http://github.com/thx/rap2-delos)
- rap2-dolores: 前端静态资源,基于 React [link](http://github.com/thx/rap2-dolores)
***2019-09-27更新的用户请注意按照下面指引安装 pandoc 以启用文档导出功能***
### Resources
- [Official Site 官网: rap2.taobao.org](http://rap2.taobao.org)
- 钉钉群 ID: 11789704
- [热心网友提供的部署文档,供参考](https://github.com/thx/rap2-delos/issues/119)
## 快速部署(Docker)
```sh
# 1. 安装docker
# 2. 修改docker-compose.xml中的配置。默认使用mysql和redis的镜像。可修改为自己的配置
# 3. 下载源码并执行。
docker-compose up -d
# ⚠️注意: 第一次运行需要手动初始化mysql数据库。分别执行以下命令
docker-compose exec delos node scripts/init
# 部署成功后 访问
http://localhost:38081 # 前端
http://localhost:38080 # 后端
# 如果仍然有问题,重新启动
docker-compose down
# 重新运行
docker-compose up -d
```
## 部署
### 环境要求
- Node.js 8.9.4+
- MySQL 5.7+
- Redis 4.0+
- pandoc 2.73 (供文档生成使用)
### 开发模式
#### 安装 MySQL 和 Redis 服务器
请自行查找搭建方法mysql/redis 配置在 config.\*.ts 文件中,在不修改任何配置的情况下,
redis 会通过默认端口 + 本机即可正常访问,确保 redis-server 打开即可。
注意:修改 cofig 文件后需要重新 `npm run build` 才能生效
#### 安装 pandoc
我们使用 pandoc 来生成 Rap 的离线文档,安装 Pandoc 最通用的办法是在 pandoc 的 [release 页面](https://github.com/jgm/pandoc/releases/tag/2.7.3)下载对应平台的二进制文件安装即可。
其中 linux 版本最好放在`/usr/local/bin/pandoc` 让终端能直接找到,并执行 `chmod +x /usr/local/bin/pandoc` 给调用权限。
测试在命令行执行命令 `pandoc -h` 有响应即可。
#### 启动redis-server
```sh
redis-server
```
后台执行可以使用 nohup 或 pm2这里推荐使用 pm2下面命令会安装 pm2并通过 pm2 来启动 redis 缓存服务
```bash
npm install -g pm2
npm run start:redis
```
#### 先创建创建数据库
```bash
mysql -e 'CREATE DATABASE IF NOT EXISTS RAP2_DELOS_APP DEFAULT CHARSET utf8 COLLATE utf8_general_ci'
```
#### 初始化
```bash
npm install
```
confirm configurations in /config/config.dev.js (used in development mode),确认/config/config.dev.js 中的配置(.dev.js 后缀表示用于开发模式)。
#### 安装 && TypeScript 编译
```bash
npm install -g typescript
npm run build
```
#### 初始化数据库表
```bash
npm run create-db
```
#### 执行 mocha 测试用例和 js 代码规范检查
```bash
npm run check
```
#### 启动开发模式的服务器 监视并在发生代码变更时自动重启
```bash
npm run dev
```
### 生产模式
```sh
# 1. 修改/config/config.prod.js中的服务器配置
# 2. 启动生产模式服务器
npm start
```
## Author
- 版权: 阿里妈妈前端团队
- 作者:
- RAP2 2017/10 前版本作者为[墨智(@Nuysoft)](https://github.com/nuysoft/), [mockjs](mockjs.com)的作者。
- 2017/10 之后版本开发者
- [霍雍(Bosn)](http://github.com/bosn/)[RAP1](http://github.com/thx/RAP)作者RAP 最早的创始人。
- [承虎(alvarto)](http://github.com/alvarto/)
- [池冰(bigfengyu)](https://github.com/bigfengyu)
### Tech Arch
- 前端架构(rap2-dolores)
- React / Redux / Saga / Router
- Mock.js
- SASS / Bootstrap 4 beta
- server: nginx
- 后端架构(rap2-delos)
- Koa
- Sequelize
- MySQL
- Server
- server: node