feat: podpora více odkazů na podnik při objednávání
This commit is contained in:
@@ -11,18 +11,18 @@ router.get("/", async (_req, res, next) => {
|
||||
});
|
||||
|
||||
router.post("/add", async (req, res, next) => {
|
||||
const { name, heslo, url } = req.body ?? {};
|
||||
const { name, heslo, urls } = req.body ?? {};
|
||||
if (!name || typeof name !== 'string') {
|
||||
return res.status(400).json({ error: 'Nebyl předán název obchodu' });
|
||||
}
|
||||
if (!heslo || typeof heslo !== 'string') {
|
||||
return res.status(400).json({ error: 'Nebylo předáno heslo' });
|
||||
}
|
||||
if (url != null && typeof url !== 'string') {
|
||||
return res.status(400).json({ error: 'Neplatná URL obchodu' });
|
||||
if (urls != null && (!Array.isArray(urls) || urls.some((u: unknown) => typeof u !== 'string'))) {
|
||||
return res.status(400).json({ error: 'Neplatný seznam URL obchodu' });
|
||||
}
|
||||
try {
|
||||
const stores = await addStore(name, heslo, url);
|
||||
const stores = await addStore(name, heslo, urls);
|
||||
res.status(200).json(stores);
|
||||
} catch (e: any) {
|
||||
if (e.message === 'UNAUTHORIZED') {
|
||||
|
||||
Reference in New Issue
Block a user