misskey/packages/backend/src/server/api/endpoints/antennas/show.ts
syuilo 1c67c26bd8
refactor: migrate to typeorm 3.0 (#8443)
* wip

* wip

* wip

* Update following.ts

* wip

* wip

* wip

* Update resolve-user.ts

* maxQueryExecutionTime

* wip

* wip
2022-03-26 15:34:00 +09:00

49 lines
973 B
TypeScript

import define from '../../define.js';
import { ApiError } from '../../error.js';
import { Antennas } from '@/models/index.js';
export const meta = {
tags: ['antennas', 'account'],
requireCredential: true,
kind: 'read:account',
errors: {
noSuchAntenna: {
message: 'No such antenna.',
code: 'NO_SUCH_ANTENNA',
id: 'c06569fb-b025-4f23-b22d-1fcd20d2816b',
},
},
res: {
type: 'object',
optional: false, nullable: false,
ref: 'Antenna',
},
} as const;
export const paramDef = {
type: 'object',
properties: {
antennaId: { type: 'string', format: 'misskey:id' },
},
required: ['antennaId'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, me) => {
// Fetch the antenna
const antenna = await Antennas.findOneBy({
id: ps.antennaId,
userId: me.id,
});
if (antenna == null) {
throw new ApiError(meta.errors.noSuchAntenna);
}
return await Antennas.pack(antenna);
});