mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 19:44:15 +00:00
19 lines
465 B
JavaScript
Executable File
19 lines
465 B
JavaScript
Executable File
import { User } from "@db_models"
|
|
|
|
export default {
|
|
method: "GET",
|
|
route: "/user_id/:username",
|
|
middlewares: ["withAuthentication"],
|
|
fn: async (req, res) => {
|
|
const user = await User.findOne({ username: req.params.username })
|
|
|
|
if (!user) {
|
|
return res.status(404).json({ error: "User not exists" })
|
|
}
|
|
|
|
return res.json({
|
|
username: user.username,
|
|
user_id: user._id,
|
|
})
|
|
}
|
|
} |