2023-12-20 17:23:31 -05:00
|
|
|
import { User } from "@models/user";
|
2023-10-11 16:24:48 -04:00
|
|
|
|
|
|
|
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());
|
|
|
|
});
|