1
0
mirror of https://git.boykissers.com/pawkey/pawkey-sk.git synced 2025-12-20 04:04:16 +00:00
Files
pawkey-sk/packages/backend/src/server/api/endpoints/sponsors.ts
Leafus 06ff35a89f docs: change branding Pawkey (#1)
- Change string instances from Sharkey to Pawkey
- Change logos and art to Pawkey
- Change repository URL where possible to our git repo
- Puppy > Shonks
- Change repo in compose_example.yml

Co-Authored-By: Bluey Heeler <bluey@pawkey.dev>
2025-08-25 00:11:03 +09:30

88 lines
1.9 KiB
TypeScript

/*
* SPDX-FileCopyrightText: marie and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { SponsorsService } from '@/core/SponsorsService.js';
export const meta = {
tags: ['meta'],
description: 'Get Pawkey Sponsors or Instance Sponsors',
requireCredential: false,
requireCredentialPrivateMode: false,
res: {
type: 'object',
nullable: false, optional: false,
properties: {
sponsor_data: {
type: 'array',
nullable: false, optional: false,
items: {
type: 'object',
nullable: false, optional: false,
properties: {
name: {
type: 'string',
nullable: false, optional: false,
},
image: {
type: 'string',
nullable: true, optional: false,
},
website: {
type: 'string',
nullable: true, optional: false,
},
profile: {
type: 'string',
nullable: false, optional: false,
},
},
},
},
},
},
// 2 calls per second
limit: {
duration: 1000,
max: 2,
},
} as const;
export const paramDef = {
type: 'object',
properties: {
// TODO remove this or make staff-only to prevent DoS
forceUpdate: { type: 'boolean', default: false },
instance: { type: 'boolean', default: false },
},
required: [],
} as const;
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
constructor(
private sponsorsService: SponsorsService,
) {
super(meta, paramDef, async (ps) => {
const sponsors = ps.instance
? await this.sponsorsService.instanceSponsors(ps.forceUpdate)
: await this.sponsorsService.sharkeySponsors(ps.forceUpdate);
return {
sponsor_data: sponsors.map(s => ({
name: s.name,
image: s.image,
website: s.website,
profile: s.profile,
})),
};
});
}
}