wip
This commit is contained in:
		| @@ -1,35 +1,15 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
| import { getJsonSchema } from '@/core/chart/core.js'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import ActiveUsersChart from '@/core/chart/charts/active-users.js'; | ||||
| import { schema } from '@/core/chart/charts/entities/active-users.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['charts', 'users'], | ||||
|  | ||||
| 	res: getJsonSchema(schema), | ||||
|  | ||||
| 	allowGet: true, | ||||
| 	cacheSec: 60 * 60, | ||||
| } as const; | ||||
|  | ||||
| export const paramDef = { | ||||
| 	type: 'object', | ||||
| 	properties: { | ||||
| 		span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 		limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 		offset: { type: 'integer', nullable: true, default: null }, | ||||
| 	}, | ||||
| 	required: ['span'], | ||||
| } as const; | ||||
|  | ||||
| // eslint-disable-next-line import/no-default-export | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| export default class extends Endpoint<'charts/active-users'> { | ||||
| 	name = 'charts/active-users' as const; | ||||
| 	constructor( | ||||
| 		private activeUsersChart: ActiveUsersChart, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 		super(async (ps, me) => { | ||||
| 			return await this.activeUsersChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); | ||||
| 		}); | ||||
| 	} | ||||
|   | ||||
| @@ -1,35 +1,15 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
| import { getJsonSchema } from '@/core/chart/core.js'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import ApRequestChart from '@/core/chart/charts/ap-request.js'; | ||||
| import { schema } from '@/core/chart/charts/entities/ap-request.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['charts'], | ||||
|  | ||||
| 	res: getJsonSchema(schema), | ||||
|  | ||||
| 	allowGet: true, | ||||
| 	cacheSec: 60 * 60, | ||||
| } as const; | ||||
|  | ||||
| export const paramDef = { | ||||
| 	type: 'object', | ||||
| 	properties: { | ||||
| 		span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 		limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 		offset: { type: 'integer', nullable: true, default: null }, | ||||
| 	}, | ||||
| 	required: ['span'], | ||||
| } as const; | ||||
|  | ||||
| // eslint-disable-next-line import/no-default-export | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| export default class extends Endpoint<'charts/ap-request'> { | ||||
| 	name = 'charts/ap-request' as const; | ||||
| 	constructor( | ||||
| 		private apRequestChart: ApRequestChart, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 		super(async (ps, me) => { | ||||
| 			return await this.apRequestChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); | ||||
| 		}); | ||||
| 	} | ||||
|   | ||||
| @@ -1,35 +1,15 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
| import { getJsonSchema } from '@/core/chart/core.js'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import DriveChart from '@/core/chart/charts/drive.js'; | ||||
| import { schema } from '@/core/chart/charts/entities/drive.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['charts', 'drive'], | ||||
|  | ||||
| 	res: getJsonSchema(schema), | ||||
|  | ||||
| 	allowGet: true, | ||||
| 	cacheSec: 60 * 60, | ||||
| } as const; | ||||
|  | ||||
| export const paramDef = { | ||||
| 	type: 'object', | ||||
| 	properties: { | ||||
| 		span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 		limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 		offset: { type: 'integer', nullable: true, default: null }, | ||||
| 	}, | ||||
| 	required: ['span'], | ||||
| } as const; | ||||
|  | ||||
| // eslint-disable-next-line import/no-default-export | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| export default class extends Endpoint<'charts/drive'> { | ||||
| 	name = 'charts/drive' as const; | ||||
| 	constructor( | ||||
| 		private driveChart: DriveChart, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 		super(async (ps, me) => { | ||||
| 			return await this.driveChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); | ||||
| 		}); | ||||
| 	} | ||||
|   | ||||
| @@ -1,35 +1,15 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
| import { getJsonSchema } from '@/core/chart/core.js'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import FederationChart from '@/core/chart/charts/federation.js'; | ||||
| import { schema } from '@/core/chart/charts/entities/federation.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['charts'], | ||||
|  | ||||
| 	res: getJsonSchema(schema), | ||||
|  | ||||
| 	allowGet: true, | ||||
| 	cacheSec: 60 * 60, | ||||
| } as const; | ||||
|  | ||||
| export const paramDef = { | ||||
| 	type: 'object', | ||||
| 	properties: { | ||||
| 		span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 		limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 		offset: { type: 'integer', nullable: true, default: null }, | ||||
| 	}, | ||||
| 	required: ['span'], | ||||
| } as const; | ||||
|  | ||||
| // eslint-disable-next-line import/no-default-export | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| export default class extends Endpoint<'charts/federation'> { | ||||
| 	name = 'charts/federation' as const; | ||||
| 	constructor( | ||||
| 		private federationChart: FederationChart, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 		super(async (ps, me) => { | ||||
| 			return await this.federationChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); | ||||
| 		}); | ||||
| 	} | ||||
|   | ||||
| @@ -1,36 +1,15 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
| import { getJsonSchema } from '@/core/chart/core.js'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import InstanceChart from '@/core/chart/charts/instance.js'; | ||||
| import { schema } from '@/core/chart/charts/entities/instance.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['charts'], | ||||
|  | ||||
| 	res: getJsonSchema(schema), | ||||
|  | ||||
| 	allowGet: true, | ||||
| 	cacheSec: 60 * 60, | ||||
| } as const; | ||||
|  | ||||
| export const paramDef = { | ||||
| 	type: 'object', | ||||
| 	properties: { | ||||
| 		span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 		limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 		offset: { type: 'integer', nullable: true, default: null }, | ||||
| 		host: { type: 'string' }, | ||||
| 	}, | ||||
| 	required: ['span', 'host'], | ||||
| } as const; | ||||
|  | ||||
| // eslint-disable-next-line import/no-default-export | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| export default class extends Endpoint<'charts/instance'> { | ||||
| 	name = 'charts/instance' as const; | ||||
| 	constructor( | ||||
| 		private instanceChart: InstanceChart, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 		super(async (ps, me) => { | ||||
| 			return await this.instanceChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.host); | ||||
| 		}); | ||||
| 	} | ||||
|   | ||||
| @@ -1,35 +1,15 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
| import { getJsonSchema } from '@/core/chart/core.js'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import NotesChart from '@/core/chart/charts/notes.js'; | ||||
| import { schema } from '@/core/chart/charts/entities/notes.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['charts', 'notes'], | ||||
|  | ||||
| 	res: getJsonSchema(schema), | ||||
|  | ||||
| 	allowGet: true, | ||||
| 	cacheSec: 60 * 60, | ||||
| } as const; | ||||
|  | ||||
| export const paramDef = { | ||||
| 	type: 'object', | ||||
| 	properties: { | ||||
| 		span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 		limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 		offset: { type: 'integer', nullable: true, default: null }, | ||||
| 	}, | ||||
| 	required: ['span'], | ||||
| } as const; | ||||
|  | ||||
| // eslint-disable-next-line import/no-default-export | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| export default class extends Endpoint<'charts/notes'> { | ||||
| 	name = 'charts/notes' as const; | ||||
| 	constructor( | ||||
| 		private notesChart: NotesChart, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 		super(async (ps, me) => { | ||||
| 			return await this.notesChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); | ||||
| 		}); | ||||
| 	} | ||||
|   | ||||
| @@ -1,35 +1,15 @@ | ||||
| import { Injectable } from '@nestjs/common'; | ||||
| import { getJsonSchema } from '@/core/chart/core.js'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import UsersChart from '@/core/chart/charts/users.js'; | ||||
| import { schema } from '@/core/chart/charts/entities/users.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['charts', 'users'], | ||||
|  | ||||
| 	res: getJsonSchema(schema), | ||||
|  | ||||
| 	allowGet: true, | ||||
| 	cacheSec: 60 * 60, | ||||
| } as const; | ||||
|  | ||||
| export const paramDef = { | ||||
| 	type: 'object', | ||||
| 	properties: { | ||||
| 		span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 		limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 		offset: { type: 'integer', nullable: true, default: null }, | ||||
| 	}, | ||||
| 	required: ['span'], | ||||
| } as const; | ||||
|  | ||||
| // eslint-disable-next-line import/no-default-export | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| export default class extends Endpoint<'charts/users'> { | ||||
| 	name = 'charts/users' as const; | ||||
| 	constructor( | ||||
| 		private usersChart: UsersChart, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 		super(async (ps, me) => { | ||||
| 			return await this.usersChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null); | ||||
| 		}); | ||||
| 	} | ||||
|   | ||||
| @@ -3088,6 +3088,140 @@ export const endpoints = { | ||||
| 			res: chartSchemaToJSONSchema(chartsSchemas.perUserReactions) satisfies JSONSchema7, | ||||
| 		}], | ||||
| 	}, | ||||
| 	'charts/active-users': { | ||||
| 		tags: ['charts', 'users'], | ||||
|  | ||||
| 		allowGet: true, | ||||
| 		cacheSec: 60 * 60, | ||||
|  | ||||
| 		defines: [{ | ||||
| 			req: { | ||||
| 				type: 'object', | ||||
| 				properties: { | ||||
| 					span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 					limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 					offset: { type: 'integer', nullable: true, default: null }, | ||||
| 				}, | ||||
| 				required: ['span'], | ||||
| 			}, | ||||
| 			res: chartSchemaToJSONSchema(chartsSchemas.activeUsers) satisfies JSONSchema7, | ||||
| 		}], | ||||
| 	}, | ||||
| 	'charts/ap-request': { | ||||
| 		tags: ['charts'], | ||||
|  | ||||
| 		allowGet: true, | ||||
| 		cacheSec: 60 * 60, | ||||
|  | ||||
| 		defines: [{ | ||||
| 			req: { | ||||
| 				type: 'object', | ||||
| 				properties: { | ||||
| 					span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 					limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 					offset: { type: 'integer', nullable: true, default: null }, | ||||
| 				}, | ||||
| 				required: ['span'], | ||||
| 			}, | ||||
| 			res: chartSchemaToJSONSchema(chartsSchemas.apRequest) satisfies JSONSchema7, | ||||
| 		}], | ||||
| 	}, | ||||
| 	'charts/drive': { | ||||
| 		tags: ['charts', 'drive'], | ||||
|  | ||||
| 		allowGet: true, | ||||
| 		cacheSec: 60 * 60, | ||||
|  | ||||
| 		defines: [{ | ||||
| 			req: { | ||||
| 				type: 'object', | ||||
| 				properties: { | ||||
| 					span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 					limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 					offset: { type: 'integer', nullable: true, default: null }, | ||||
| 				}, | ||||
| 				required: ['span'], | ||||
| 			}, | ||||
| 			res: chartSchemaToJSONSchema(chartsSchemas.drive) satisfies JSONSchema7, | ||||
| 		}], | ||||
| 	}, | ||||
| 	'charts/federation': { | ||||
| 		tags: ['charts'], | ||||
|  | ||||
| 		allowGet: true, | ||||
| 		cacheSec: 60 * 60, | ||||
|  | ||||
| 		defines: [{ | ||||
| 			req: { | ||||
| 				type: 'object', | ||||
| 				properties: { | ||||
| 					span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 					limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 					offset: { type: 'integer', nullable: true, default: null }, | ||||
| 				}, | ||||
| 				required: ['span'], | ||||
| 			}, | ||||
| 			res: chartSchemaToJSONSchema(chartsSchemas.federation) satisfies JSONSchema7, | ||||
| 		}], | ||||
| 	}, | ||||
| 	'charts/instance': { | ||||
| 		tags: ['charts'], | ||||
|  | ||||
| 		allowGet: true, | ||||
| 		cacheSec: 60 * 60, | ||||
|  | ||||
| 		defines: [{ | ||||
| 			req: { | ||||
| 				type: 'object', | ||||
| 				properties: { | ||||
| 					span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 					limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 					offset: { type: 'integer', nullable: true, default: null }, | ||||
| 					host: { type: 'string' }, | ||||
| 				}, | ||||
| 				required: ['span', 'host'], | ||||
| 			}, | ||||
| 			res: chartSchemaToJSONSchema(chartsSchemas.instance) satisfies JSONSchema7, | ||||
| 		}], | ||||
| 	}, | ||||
| 	'charts/notes': { | ||||
| 		tags: ['charts', 'notes'], | ||||
|  | ||||
| 		allowGet: true, | ||||
| 		cacheSec: 60 * 60, | ||||
|  | ||||
| 		defines: [{ | ||||
| 			req: { | ||||
| 				type: 'object', | ||||
| 				properties: { | ||||
| 					span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 					limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 					offset: { type: 'integer', nullable: true, default: null }, | ||||
| 				}, | ||||
| 				required: ['span'], | ||||
| 			}, | ||||
| 			res: chartSchemaToJSONSchema(chartsSchemas.notes) satisfies JSONSchema7, | ||||
| 		}], | ||||
| 	}, | ||||
| 	'charts/users': { | ||||
| 		tags: ['charts', 'users'], | ||||
|  | ||||
| 		allowGet: true, | ||||
| 		cacheSec: 60 * 60, | ||||
|  | ||||
| 		defines: [{ | ||||
| 			req: { | ||||
| 				type: 'object', | ||||
| 				properties: { | ||||
| 					span: { type: 'string', enum: ['day', 'hour'] }, | ||||
| 					limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 }, | ||||
| 					offset: { type: 'integer', nullable: true, default: null }, | ||||
| 				}, | ||||
| 				required: ['span'], | ||||
| 			}, | ||||
| 			res: chartSchemaToJSONSchema(chartsSchemas.users) satisfies JSONSchema7, | ||||
| 		}], | ||||
| 	}, | ||||
| 	//#endregion | ||||
| } as const satisfies { [x: string]: IEndpointMeta; }; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 tamaina
					tamaina