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

38 lines
1.2 KiB
JavaScript
Raw Normal View History

const { response } = require('express');
const router = require('express').Router();
router.get("/users", (request, response) => {
2024-05-26 16:29:12 +03:00
response.send(require("./json/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-11-30 14:54:07 +03:00
response.send(require("./json/auth/dogsitter.success.json"))
2024-11-30 12:16:27 +03:00
}
else if (phoneNumber === '89555555555') {
2024-11-30 14:54:07 +03:00
response.status(400).send(require("./json/auth/error.json"))
2024-11-30 12:16:27 +03:00
}
else {
2024-11-30 14:54:07 +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-11-30 14:54:07 +03:00
response.status(400).send(require("./json/register/error.json"))
2024-11-30 12:16:27 +03:00
}
else if (role === 'dogsitter') {
2024-11-30 14:54:07 +03:00
response.send(require("./json/register/dogsitter.success.json"))
2024-11-30 12:16:27 +03:00
}
else {
2024-11-30 14:54:07 +03:00
response.send(require("./json/register/owner.success.json"))
2024-11-30 12:16:27 +03:00
}
})
module.exports = router;