Sharkey/src/server/api/endpoints/antennas/show.ts
syuilo b9cb6d1c10 refactor: refactoring imports
将来ESMに移行しやすいように
Related: #7658

なんかmochaが起動しなくなってるけど理由不明
すぐ直したい
2021-08-19 18:33:41 +09:00

47 lines
900 B
TypeScript

import $ from 'cafy';
import { ID } from '@/misc/cafy-id.js';
import define from '../../define.js';
import { ApiError } from '../../error.js';
import { Antennas } from '@/models/index.js';
export const meta = {
tags: ['antennas', 'account'],
requireCredential: true as const,
kind: 'read:account',
params: {
antennaId: {
validator: $.type(ID),
},
},
errors: {
noSuchAntenna: {
message: 'No such antenna.',
code: 'NO_SUCH_ANTENNA',
id: 'c06569fb-b025-4f23-b22d-1fcd20d2816b'
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Antenna'
}
};
export default define(meta, async (ps, me) => {
// Fetch the antenna
const antenna = await Antennas.findOne({
id: ps.antennaId,
userId: me.id,
});
if (antenna == null) {
throw new ApiError(meta.errors.noSuchAntenna);
}
return await Antennas.pack(antenna);
});