feat(api): add api endpoint for fetching all users that have matching usernames
This commit is contained in:
parent
62f71b12c8
commit
74995f626b
13
server/api/all-users.get.ts
Normal file
13
server/api/all-users.get.ts
Normal file
@ -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());
|
||||
});
|
Loading…
Reference in New Issue
Block a user