multy-stub/server/routers/dogsitters-finder/index.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

const router = require('express').Router();
router.get("/users", (request, response) => {
2024-11-30 16:04:59 +03:00
response.send(require("./json/users/users.json"))
})
2024-11-30 12:16:27 +03:00
router.post("/auth", (request, response) => {
const {phoneNumber, password} = request.body;
console.log(phoneNumber, password);
if (phoneNumber === '89999999999') {
2024-12-01 21:47:55 +03:00
response.send(require("./json/auth/dogsitter.success.json"))
2024-11-30 12:16:27 +03:00
}
else if (phoneNumber === '89555555555') {
2024-12-01 21:47:55 +03:00
response.status(400).send(require("./json/auth/error.json"))
2024-11-30 12:16:27 +03:00
}
else {
2024-12-01 21:47:55 +03:00
response.send(require("./json/auth/owner.success.json"))
2024-11-30 12:16:27 +03:00
}
})
router.post("/register", (request, response) => {
const {firstName, secondName, phoneNumber, password, role} = request.body;
console.log(phoneNumber, password, role);
if (phoneNumber === '89283244141' || phoneNumber === '89872855893') {
2024-12-01 21:47:55 +03:00
response.status(400).send(require("./json/register/error.json"))
2024-11-30 12:16:27 +03:00
}
else if (role === 'dogsitter') {
2024-12-01 21:47:55 +03:00
response.send(require("./json/register/dogsitter.success.json"))
2024-11-30 12:16:27 +03:00
}
else {
2024-12-01 21:47:55 +03:00
response.send(require("./json/register/owner.success.json"))
2024-11-30 12:16:27 +03:00
}
})
module.exports = router;