diff --git a/README.md b/README.md index 25b9eff..32813c4 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,32 @@ * 下载postgres http://postgresapp.com/ 并运行 * 下载redis, brew install redis 并运行: redis-server * git clone 代码 -* bundle install -* rake db:create, rake db:migrate -* rails s -* 运行 sidekiq, 在项目跟目录下: bundle exec sidekiq -C config/sidekiq.yml +#### 安装Ruby依赖文件 + +``` +bundle install +``` + +#### 初始化postgres数据库登陆信息 + +``` +create role twer with superuser; +alter user twer login; +``` + +``` +rake db:create +rake db:migrate +``` + +#### 运行Rails + +``` +rails s +#运行 sidekiq, 在项目跟目录下: +bundle exec sidekiq -C config/sidekiq.yml +``` #### API 调用 @@ -46,8 +67,8 @@ "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6IjU0MGU4OTU4ODg3ZmI1MGI5YTA5YzI4MjQ2NTZlYTRlIn0.XQBWCNRYVdDvZwuBtafCyOkNpP8FEzwRqk8AhaHlaFc" } } - ``` - + ``` + 3 提交分享资源 POST: http://localhost:3000/api/v1/posts - 参数 * 需要登录 传Authorization header @@ -55,7 +76,7 @@ * type article 或者 web_page * description 可选 - 返回 - + ``` json { "id": 32, @@ -81,7 +102,7 @@ - 参数 * 无 - 返回 - + ``` json [ { @@ -92,7 +113,7 @@ "url": "http://www.jianshu.com/p/bfbc77eecdb0", "title": null } - }, + }, { "description": "到底能不能成功啊,我去", "sharable_type": "Article", @@ -115,26 +136,26 @@ 5 关注follow 用户:POST http://localhost:3000/api/v1/users/2/follow 6 取消关注unfollow 用户: POST: http://localhost:3000/api/v1/users/2/unfollow - + 7 喜欢 post POST: http://localhost:3000/api/v1/posts/3/like - + - 返回结果 - + ``` json { "msg": "done", "likes_count": 1 } ``` - + 8 取消喜欢 post POST: http://localhost:3000/api/v1/posts/3/unlike 9 创建评论 POST: http://localhost:3000/api/v1/posts/1/comments - - 参数 + - 参数 * content - - 返回结果 - + - 返回结果 + ``` json { "msg": "done", @@ -142,7 +163,7 @@ } ``` -10 评论列表 GET http://localhost:3000/api/v1/posts/1/comments +10 评论列表 GET http://localhost:3000/api/v1/posts/1/comments - 返回结果: @@ -170,8 +191,8 @@ ``` 11 喜欢评论 comment: POST http://localhost:3000/api/v1/posts/1/comments/1/like - -- 返回结果: + +- 返回结果: ```json { @@ -179,7 +200,7 @@ "likes_count": 1 } ``` - + 12 取消喜欢评论 comment: POST http://localhost:3000/api/v1/posts/1/comments/1/unlike 13 增加文章的浏览数(当用户点击查看某个文章时使用),不需要关心返回值 POST http://localhost:3000/api/v1/posts/3/view @@ -187,9 +208,9 @@ 14 获取用户喜欢的文章 GET http://localhost:3000/api/v1/posts/liked - 支持分页 ?page=1 - + - 返回结果 - + ``` json [ { @@ -221,9 +242,8 @@ } ] ``` - + #### 注意 * 注意,API返回结果中的token是利用JWT 技术加密的token,密钥是每个用户的email * [jwt](http://jwt.io/) * 通常执行创建(POST) 操作时,如果没有返回结果,仅仅返回200,也是成功的表示, 当返回400时即为失败 -