Sharkey/src/server/api/endpoints/drive/folders/find.ts
syuilo 52774bbe64
Introduce OpenAPI specs (#4351)
* wip

* wip

* wip

* Update index.ts

* Update gen-openapi-spec.ts

* Update api.ja-JP.md

* Fix

* Improve doc

* Update gen-openapi-spec.ts

* Update redoc.html

* Improve doc

* Update gen-openapi-spec.ts

* Improve doc

* Update CHANGELOG.md
2019-02-23 11:20:58 +09:00

38 lines
731 B
TypeScript

import $ from 'cafy';
import ID, { transform } from '../../../../../misc/cafy-id';
import DriveFolder, { pack } from '../../../../../models/drive-folder';
import define from '../../../define';
export const meta = {
tags: ['drive'],
requireCredential: true,
kind: 'drive-read',
params: {
name: {
validator: $.str
},
parentId: {
validator: $.optional.nullable.type(ID),
transform: transform,
default: null as any,
desc: {
'ja-JP': 'フォルダID'
}
},
}
};
export default define(meta, async (ps, user) => {
const folders = await DriveFolder
.find({
name: ps.name,
userId: user._id,
parentId: ps.parentId
});
return await Promise.all(folders.map(folder => pack(folder)));
});