1.0-3.0 account search support

This commit is contained in:
Lawin0129
2023-04-17 00:58:30 +01:00
parent 93f712e9fb
commit a8e244d8bc
+22 -1
View File
@@ -55,12 +55,33 @@ app.get("/account/api/public/account/displayName/:displayName", async (req, res)
});
});
app.get("/persona/api/public/account/lookup", async (req, res) => {
if (typeof req.query.q != "string") return res.status(400).json(error.createError(
"errors.com.epicgames.bad_request",
"Required String parameter 'q' is invalid or not present",
undefined, 1001, undefined)
);
let user = await User.findOne({ username_lower: req.query.q.toLowerCase(), banned: false }).lean();
if (!user) return res.status(404).json(error.createError(
"errors.com.epicgames.account.account_not_found",
`Sorry, we couldn't find an account for ${req.query.q}`,
[req.query.q], 18007, undefined)
);
res.json({
id: user.accountId,
displayName: user.username,
externalAuths: {}
});
});
app.get("/api/v1/search/:accountId", async (req, res) => {
let response = [];
if (typeof req.query.prefix != "string") return res.status(400).json(error.createError(
"errors.com.epicgames.bad_request",
"Required String parameter 'prefix' is not present",
"Required String parameter 'prefix' is invalid or not present",
undefined, 1001, undefined)
);