mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 11:53:08 +02:00
52774bbe64
* 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
30 lines
525 B
TypeScript
30 lines
525 B
TypeScript
import $ from 'cafy';
|
|
import User from '../../../../models/user';
|
|
import { validateUsername } from '../../../../models/user';
|
|
import define from '../../define';
|
|
|
|
export const meta = {
|
|
tags: ['users'],
|
|
|
|
requireCredential: false,
|
|
|
|
params: {
|
|
username: {
|
|
validator: $.str.pipe(validateUsername)
|
|
}
|
|
}
|
|
};
|
|
|
|
export default define(meta, async (ps) => {
|
|
// Get exist
|
|
const exist = await User.count({
|
|
host: null,
|
|
usernameLower: ps.username.toLowerCase()
|
|
}, {
|
|
limit: 1
|
|
});
|
|
|
|
return {
|
|
available: exist === 0
|
|
};
|
|
});
|