2023-12-20 17:23:31 -05:00
|
|
|
import { usernameRegex } from "@server/constants";
|
|
|
|
import { User } from "@models/user";
|
2023-10-11 17:00:18 -04:00
|
|
|
|
|
|
|
export default eventHandler(async (event) => {
|
|
|
|
const query = getQuery(event);
|
|
|
|
const u = await User.findOne({
|
|
|
|
username: usernameRegex(query.username as string),
|
|
|
|
}).exec();
|
|
|
|
if (u) {
|
|
|
|
return {
|
|
|
|
exists: true,
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return { exists: false };
|
|
|
|
}
|
|
|
|
});
|