[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.
 

179 lines
4.8 KiB

import { JSONSchema } from 'fastify'
export const tokenResponseSchema: JSONSchema = {
description: 'Token response.',
type: 'object',
properties: {
id: { type: 'string' },
access: { type: 'string' },
refresh: { type: 'string' },
expires: { type: 'number' },
},
}
export const userSettingsSchema: JSONSchema = {
type: 'object',
properties: {
allowThemeChange: { type: 'boolean' },
alwaysReveal: { type: 'boolean' },
autoPlayGifs: { type: 'boolean' },
},
}
export const groupSchema: JSONSchema = {
description: 'Group entity.',
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
about: { type: 'string' },
imageUrl: { type: 'string' },
coverImageUrl: { type: 'string' },
iconImageUrl: { type: 'string' },
theme: { type: 'string' },
requiresApproval: { type: 'boolean' },
members: { type: 'number' },
posts: { type: 'number' },
points: { type: 'number' },
created: { type: 'number' },
membership: { type: 'string' },
},
}
export const subscriptionSchema: JSONSchema = {
type: 'object',
properties: {
from: { type: 'string' },
to: { type: 'string' },
pending: { type: 'boolean' },
},
}
export const userSchema: JSONSchema = {
description: 'User entity.',
type: 'object',
properties: {
id: { type: 'string' },
group: groupSchema,
name: { type: 'string' },
about: { type: 'string' },
imageUrl: { type: 'string' },
coverImageUrl: { type: 'string' },
theme: { type: 'string' },
subscriptions: {
type: 'array',
items: subscriptionSchema,
},
membership: { type: 'string' },
intro: { type: 'string' },
posts: { type: 'number' },
points: { type: 'number' },
created: { type: 'number' },
},
}
export const attachmentSchema: JSONSchema = {
type: 'object',
properties: {
url: { type: 'string' },
text: { type: 'string' },
cover: { type: 'string' },
},
}
export const postSchema: JSONSchema = {
description: 'Post entity.',
type: 'object',
properties: {
id: { type: 'string' },
userId: { type: 'string' },
user: userSchema,
appId: { type: 'string' },
text: { type: 'string' },
cover: { type: 'string' },
attachments: {
type: 'array',
items: attachmentSchema,
},
data: {
type: 'object',
additionalProperties: true,
},
visible: { type: 'boolean' },
replies: { type: 'number' },
created: { type: 'number' },
},
}
export const appSchema: JSONSchema = {
description: 'App entity.',
type: 'object',
properties: {
id: { type: 'string' },
user: userSchema,
name: { type: 'string' },
displayName: { type: 'string' },
imageUrl: { type: 'string' },
coverImageUrl: { type: 'string' },
iconImageUrl: { type: 'string' },
about: { type: 'string' },
websiteUrl: { type: 'string' },
companyName: { type: 'string' },
version: { type: 'string' },
rating: { type: 'number' },
users: { type: 'number' },
updated: { type: 'number' },
created: { type: 'number' },
publicKey: { type: 'string' },
privateKey: { type: 'string' },
composerUrl: { type: 'string' },
rendererUrl: { type: 'string' },
revisions: {
type: 'array',
items: {
type: 'object',
},
},
}
}
export const selfSchema: JSONSchema = {
description: 'Authenticated User entity.',
type: 'object',
properties: {
id: { type: 'string' },
group: groupSchema,
name: { type: 'string' },
email: { type: 'string' },
about: { type: 'string' },
settings: userSettingsSchema,
imageUrl: { type: 'string' },
coverImageUrl: { type: 'string' },
theme: { type: 'string' },
requiresApproval: { type: 'boolean' },
privacy: { type: 'string' },
membership: { type: 'string' },
posts: { type: 'number' },
points: { type: 'number' },
admin: { type: 'boolean' },
created: { type: 'number' },
},
}
export const errorSchema: JSONSchema = {
description: 'Client error.',
type: 'object',
properties: {
message: { type: 'string' },
errors: {
type: 'array',
items: {
type: 'object',
properties: {
field: { type: 'string' },
message: { type: 'string' },
},
},
},
},
}