misskey/src/server/api/endpoints/users/lists/create.ts
syuilo 2756f553c6
Improve error handling of API (#4345)
* wip

* wip

* wip

* Update attached_notes.ts

* wip

* Refactor

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update call.ts

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* ✌️

* Fix
2019-02-22 11:46:58 +09:00

32 lines
581 B
TypeScript

import $ from 'cafy';
import UserList, { pack } from '../../../../../models/user-list';
import define from '../../../define';
export const meta = {
desc: {
'ja-JP': 'ユーザーリストを作成します。',
'en-US': 'Create a user list'
},
requireCredential: true,
kind: 'account-write',
params: {
title: {
validator: $.str.range(1, 100)
}
}
};
export default define(meta, async (ps, user) => {
const userList = await UserList.insert({
createdAt: new Date(),
userId: user._id,
title: ps.title,
userIds: []
});
return await pack(userList);
});