Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. # TwitterClon Backend
  2.  
  3. ## Endpoints:
  4.  
  5. ### Usuarios [/users/]
  6.  
  7. - Crear una cuenta [/users/][POST]
  8.  
  9. **Resquest**
  10.  
  11. ```
  12. {
  13. mail: 'mail@mail.com'
  14. username: 'username01',
  15. password: '123456789'
  16. name: 'Roberto'
  17. lastname: 'Roberson'
  18. }
  19. ```
  20.  
  21. **Response**
  22.  
  23. ### Login [/login/]
  24.  
  25. - Autenticar [/login][POST]
  26.  
  27. **Request**
  28. ```
  29. {
  30. username: 'username01',
  31. password: '123456789'
  32. }
  33. ```
  34.  
  35. **Response**
  36.  
  37. ```
  38. {
  39. token: 'asdasdashdjñlasdkasiduopisadksaldñ'
  40. }
  41. ```
  42.  
  43. ## Twits
  44.  
  45. - Todos los twits [/twits/?username={value}][GET]
  46.  
  47. **Query**
  48.  
  49. - username, es el nombre de usuarion [OPCIONAL]
  50.  
  51. **Response**
  52.  
  53. ```
  54. [
  55. {
  56. _id: '6534fsdlkfjsd9804382',
  57. message: 'Llalaal mi twit',
  58. creation_date: '2017/10/01 20:20:00',
  59. modification_date: null,
  60. creator: {
  61. name: 'Usuario',
  62. Lastanme: 'Usuario',
  63. nickname: 'username01'
  64. }
  65. },
  66. {
  67. _id: '6534f64lkfjsd9804382',
  68. message: 'El segundo twit',
  69. creation_date: '2017/10/01 20:20:00',
  70. modification_date: '2017/10/01 20:20:00',
  71. creator: {
  72. name: 'Usuario',
  73. Lastanme: 'Usuario',
  74. nickname: 'username01'
  75. }
  76. }
  77. ]
  78. ```
  79. - Crear Twit [/twits/][POST]
  80.  
  81. **Login**
  82.  
  83. Header: 'x-access-token' : 'asd78a6s786das7d8'
  84.  
  85. **Resquest**
  86.  
  87. ```
  88. {
  89. message: 'Te envio mi twitt!'
  90. }
  91. ```
  92.  
  93. **Response**
  94.  
  95. ```
  96. {
  97. _id: '897sa89dyhjkasdl',
  98. message: 'Te envio mi twitt!',
  99. creation_date: '2017/10/01 20:20:00',
  100. modification_date: null,
  101. creator: {
  102. username: 'UsuatioLogueado'
  103. }
  104. }
  105. ```
  106.  
  107. - Editar un Twit [/twit/:id][PUT]
  108.  
  109. **Regla**
  110.  
  111. Solamente el dueño del twitt lo puede modificar.
  112.  
  113. **params**
  114.  
  115. - id - Id del twit
  116.  
  117. **Login**
  118.  
  119. Header: 'x-access-token' : 'asd78a6s786das7d8'
  120.  
  121. **Request**
  122.  
  123. ```
  124. {
  125. _id: '897sa89dyhjkasdl',
  126. message: 'Mensaje Actualizado',
  127. creation_date: '2017/10/01 20:20:00',
  128. modification_date: null,
  129. creator: {
  130. username: 'UsuatioLogueado'
  131. }
  132. }
  133. ```
  134.  
  135. **Response**
  136.  
  137. - 200
  138. ```
  139. {
  140. _id: '897sa89dyhjkasdl',
  141. message: 'Mensaje Actualizado',
  142. creation_date: '2017/10/01 20:20:00',
  143. modification_date: '2017/10/01 20:21:00',
  144. creator: {
  145. username: 'UsuatioLogueado'
  146. }
  147. }
  148. ```
  149.  
  150. - 401
  151. ```
  152. {
  153. message: 'No podes editar un twit que no es tuyo'
  154. }
  155. ```
  156.  
  157.  
  158. - Borrar Twit [/twit/:id][DELETE]
  159.  
  160. **Regla**
  161.  
  162. Solamente el dueño del twitt lo puede borrar.
  163.  
  164. **params**
  165.  
  166. - id - Id del twit
  167.  
  168. **Login**
  169.  
  170. Header: 'x-access-token' : 'asd78a6s786das7d8'
  171.  
  172. **Request**
  173.  
  174. **Response**
  175.  
  176. - 200
  177. ```
  178. {
  179. message: 'Twit borrado con exito'
  180. }
  181. ```
  182.  
  183. - 401
  184. ```
  185. {
  186. message: 'No podes borrar un twit que no es tuyo'
  187. }
  188. ```
  189.  
  190. ## Comentarios
  191.  
  192. - Crear un comentario [/twits/:id/comments][POST]
  193.  
  194. **Regla**
  195. El usuario tiene que estar logueado para generar comentario.
  196.  
  197. **params**
  198.  
  199. id - id del twitt donde se genera el comentario.
  200.  
  201. **Login**
  202.  
  203. Header: 'x-access-token' : 'asd78a6s786das7d8'
  204.  
  205. **Resquest**
  206.  
  207. ```
  208. {
  209. message: 'Que bien twit!!!'
  210. }
  211. ```
  212.  
  213. **Response**
  214.  
  215. ```
  216. {
  217. _id: '12312312312536ygfsda',
  218. message: 'Que bien twit!!!',
  219. creator: {
  220. username: 'UsuatioLogueado'
  221. }
  222. }
  223. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement