[ABANDONED] API server for Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
5.5 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. // schemas.ts
  2. // Copyright (C) 2020 Dwayne Harris
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU General Public License for more details.
  11. // You should have received a copy of the GNU General Public License
  12. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. import { JSONSchema } from 'fastify'
  14. export const tokenResponseSchema: JSONSchema = {
  15. description: 'Token response.',
  16. type: 'object',
  17. properties: {
  18. id: { type: 'string' },
  19. access: { type: 'string' },
  20. refresh: { type: 'string' },
  21. expires: { type: 'number' },
  22. },
  23. }
  24. export const userSettingsSchema: JSONSchema = {
  25. type: 'object',
  26. properties: {
  27. allowThemeChange: { type: 'boolean' },
  28. alwaysReveal: { type: 'boolean' },
  29. autoPlayGifs: { type: 'boolean' },
  30. },
  31. }
  32. export const groupSchema: JSONSchema = {
  33. description: 'Group entity.',
  34. type: 'object',
  35. properties: {
  36. id: { type: 'string' },
  37. name: { type: 'string' },
  38. about: { type: 'string' },
  39. imageUrl: { type: 'string' },
  40. coverImageUrl: { type: 'string' },
  41. iconImageUrl: { type: 'string' },
  42. theme: { type: 'string' },
  43. requiresApproval: { type: 'boolean' },
  44. members: { type: 'number' },
  45. posts: { type: 'number' },
  46. points: { type: 'number' },
  47. created: { type: 'number' },
  48. membership: { type: 'string' },
  49. },
  50. }
  51. export const subscriptionSchema: JSONSchema = {
  52. type: 'object',
  53. properties: {
  54. from: { type: 'string' },
  55. to: { type: 'string' },
  56. pending: { type: 'boolean' },
  57. },
  58. }
  59. export const userSchema: JSONSchema = {
  60. description: 'User entity.',
  61. type: 'object',
  62. properties: {
  63. id: { type: 'string' },
  64. group: groupSchema,
  65. name: { type: 'string' },
  66. about: { type: 'string' },
  67. imageUrl: { type: 'string' },
  68. coverImageUrl: { type: 'string' },
  69. theme: { type: 'string' },
  70. subscriptions: {
  71. type: 'array',
  72. items: subscriptionSchema,
  73. },
  74. membership: { type: 'string' },
  75. intro: { type: 'string' },
  76. posts: { type: 'number' },
  77. points: { type: 'number' },
  78. created: { type: 'number' },
  79. },
  80. }
  81. export const attachmentSchema: JSONSchema = {
  82. type: 'object',
  83. properties: {
  84. url: { type: 'string' },
  85. text: { type: 'string' },
  86. cover: { type: 'string' },
  87. },
  88. }
  89. export const postSchema: JSONSchema = {
  90. description: 'Post entity.',
  91. type: 'object',
  92. properties: {
  93. id: { type: 'string' },
  94. userId: { type: 'string' },
  95. user: userSchema,
  96. appId: { type: 'string' },
  97. text: { type: 'string' },
  98. cover: { type: 'string' },
  99. attachments: {
  100. type: 'array',
  101. items: attachmentSchema,
  102. },
  103. data: {
  104. type: 'object',
  105. additionalProperties: true,
  106. },
  107. visible: { type: 'boolean' },
  108. replies: { type: 'number' },
  109. created: { type: 'number' },
  110. },
  111. }
  112. export const appSchema: JSONSchema = {
  113. description: 'App entity.',
  114. type: 'object',
  115. properties: {
  116. id: { type: 'string' },
  117. user: userSchema,
  118. name: { type: 'string' },
  119. displayName: { type: 'string' },
  120. imageUrl: { type: 'string' },
  121. coverImageUrl: { type: 'string' },
  122. iconImageUrl: { type: 'string' },
  123. about: { type: 'string' },
  124. websiteUrl: { type: 'string' },
  125. companyName: { type: 'string' },
  126. version: { type: 'string' },
  127. rating: { type: 'number' },
  128. users: { type: 'number' },
  129. updated: { type: 'number' },
  130. created: { type: 'number' },
  131. publicKey: { type: 'string' },
  132. privateKey: { type: 'string' },
  133. composerUrl: { type: 'string' },
  134. rendererUrl: { type: 'string' },
  135. revisions: {
  136. type: 'array',
  137. items: {
  138. type: 'object',
  139. },
  140. },
  141. }
  142. }
  143. export const selfSchema: JSONSchema = {
  144. description: 'Authenticated User entity.',
  145. type: 'object',
  146. properties: {
  147. id: { type: 'string' },
  148. group: groupSchema,
  149. name: { type: 'string' },
  150. email: { type: 'string' },
  151. about: { type: 'string' },
  152. settings: userSettingsSchema,
  153. imageUrl: { type: 'string' },
  154. coverImageUrl: { type: 'string' },
  155. theme: { type: 'string' },
  156. requiresApproval: { type: 'boolean' },
  157. privacy: { type: 'string' },
  158. membership: { type: 'string' },
  159. posts: { type: 'number' },
  160. points: { type: 'number' },
  161. admin: { type: 'boolean' },
  162. created: { type: 'number' },
  163. },
  164. }
  165. export const errorSchema: JSONSchema = {
  166. description: 'Client error.',
  167. type: 'object',
  168. properties: {
  169. message: { type: 'string' },
  170. errors: {
  171. type: 'array',
  172. items: {
  173. type: 'object',
  174. properties: {
  175. field: { type: 'string' },
  176. message: { type: 'string' },
  177. },
  178. },
  179. },
  180. },
  181. }