Skip to content

Commit 7e115dc

Browse files
подчистил бек
1 parent a36234a commit 7e115dc

File tree

4 files changed

+0
-12
lines changed

4 files changed

+0
-12
lines changed

app.js

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const cors = require("cors");
77
const swaggerUi = require('swagger-ui-express');
88
const swaggerDocument = require('./swagger.json');
99

10-
// require('dotenv').config();
1110
require("dotenv").config({ path: path.join(__dirname, "./.env") });
1211

1312
const authRouter = require('./routes/api/auth');
@@ -30,7 +29,6 @@ app.use('/link', (req, res) => {
3029
});
3130
app.use("/api/books", booksRouter);
3231
app.use("/api/training", statsRouter);
33-
// app.use("/api/stats", statsRouter);
3432

3533
app.use('/', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
3634

controllers/books/getAll.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
const { Book } = require("../../models/book");
22

33
const getAll = async (req, res) => {
4-
// const result = await Book.find({}, "-createdAt -updatedAt");
5-
// res.json(result);
64

75
const { _id: owner } = req.user;
86
const result = await Book.find({ owner }, " -createdAt -updatedAt"
9-
// ).populate("owner", "email");
107
);
118

129
res.json(result);

routes/api/auth.js

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const {googleAuth, googleRedirect} = require('../google/auth_controller');
99

1010
const router = express.Router()
1111

12-
// router.post('/signup', validationBody(schemas.singupSchema) ,ctrlWrapper(controller.signup));
1312
router.post('/signup', validationBody(schemas.singupSchema) ,ctrlWrapper(controller.signupEndLogin));
1413

1514
router.post('/login', validationBody(schemas.loginSchema), ctrlWrapper(controller.login));

routes/google/auth_controller.js

-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ const googleAuth = async (req, res) => {
2727
};
2828

2929
const googleRedirect = async (req, res) => {
30-
// console.log('googleRedirect ');
3130
const fullUrl = `${req.protocol}://${req.get("host")}${req.originalUrl}`;
3231
const urlObj = new URL(fullUrl);
3332
const urlParams = queryString.parse(urlObj.search);
3433
const code = urlParams.code;
35-
// console.log(`code: ${code}`);
3634
const tokenData = await axios({
3735
url: `https://oauth2.googleapis.com/token`,
3836
method: "post",
@@ -49,8 +47,6 @@ const googleRedirect = async (req, res) => {
4947
method: "get",
5048
headers: { Authorization: `Bearer ${tokenData.data.access_token}`},
5149
});
52-
// console.log(`userData.email ${userData.data.email}`);
53-
// console.log(`userData.name ${userData.data.name}`);
5450
// GOOGLE END********************************************
5551

5652
// SINGUP *********************************************
@@ -59,7 +55,6 @@ const googleRedirect = async (req, res) => {
5955
let user = await User.findOne({ email });
6056
if (!user) {
6157
console.log(`user not found!`)
62-
// const password = "111111";
6358
const password = v4();
6459
const hashPassword = await bcrypt.hash(password, 10);
6560
user = await User.create({ name, email, password: hashPassword });
@@ -68,7 +63,6 @@ const googleRedirect = async (req, res) => {
6863
// ***************************************************
6964

7065
// LOGIN *********************************************
71-
// user = await User.findOne({ email });
7266
const peyload = { id: user._id };
7367
const token = jwt.sign(peyload, SECRET_KEY, { expiresIn: "24h" });
7468
await User.findByIdAndUpdate(user._id, { token });

0 commit comments

Comments
 (0)