feat(api): add api endpoint for fetching all users that have matching usernames

This commit is contained in:
parent 62f71b12c8
commit 74995f626b
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -0,0 +1,13 @@
import { User } from "~/models/user";
export default eventHandler(async (ev) => {
const q = getQuery(ev);
const regex = new RegExp(`.*${q.name}.*`, "i");
const users = await User.find({
username: regex,
banned: false,
})
.select("username _id")
.exec();
return users.map((a) => a.toObject());
});