hippofish/packages/backend/src/server/api/endpoints/my/apps.ts
syuilo d071d18dd7
refactor: Use ESM (#8358)
* wip

* wip

* fix

* clean up

* Update tsconfig.json

* Update activitypub.ts

* wip
2022-02-27 11:07:39 +09:00

44 lines
862 B
TypeScript

import define from '../../define.js';
import { Apps } from '@/models/index.js';
export const meta = {
tags: ['account', 'app'],
requireCredential: true,
res: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'object',
optional: false, nullable: false,
ref: 'App',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
offset: { type: 'integer', default: 0 },
},
required: [],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = {
userId: user.id,
};
const apps = await Apps.find({
where: query,
take: ps.limit,
skip: ps.offset,
});
return await Promise.all(apps.map(app => Apps.pack(app, user, {
detail: true,
})));
});