const init = (data) => {
    const controller = {
        getSearch(req, res) {
            let searchValue = req.query.searchValue;
            const filter = {
                $or: [
                    {
                        'name': {
                            '$regex': searchValue,
                            '$options': 'i',
                        },
                    },
                    {
                        'description': {
                            '$regex': searchValue,
                            '$options': 'i',
                        },
                    },
                ],
            };
            return data.projects.getAll(filter)
                .then((projects) => {
                    if (projects.length < 1) {
                        searchValue = `No results found for "${searchValue}"`;
                    }
                    return res.render('projects/search', {
                        model: {
                            value: `${searchValue}`,
                            projects: projects,
                        },
                    },
                        (err, html) => {
                            res.send(html);
                        });
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        getProjects(req, res) {
            let { category, page } = req.query;
            page = parseInt(page, 10) || 1;
            const size = 8;

            category = category ? { category: category } : {};

            return data.projects.getAll(category)
                .then((projects) => {
                    if (projects.length < 1) {
                        return res.send('<h3>No projects in category <span class="capitalize">' + category.category + '</span></h3>');
                    } else {
                        projects = projects.slice((page - 1) * size, page * size);
                        return res.render('projects/projects', { model: projects },
                            (err, html) => {
                                res.send(html);
                            });
                    }
                })
                .catch((err) => {
                    console.log('--- ERROR in api.router.js getAll --- ');
                    console.log(err);
                });
        },
        updateUser(req, res) {
            const username = req.params.username;
            console.log(new Date().toLocaleTimeString());
            let obj = {};
            if (req.body.amount < 0) {
                req.flash('error', 'Amount should be between 0 and 10 000!');
                res.locals.messages = req.flash();
                return res.render('flash_message_template');
            }

            if (req.body.amount) {
                obj = {
                    'amount': req.body.amount,
                };
            } else {
                obj = {
                    'firstName': req.body.firstName.trim(),
                    'lastName': req.body.lastName.trim(),
                    'email': req.body.email.trim(),
                };
            }

            if (req.body.amount) {
                obj = {
                    'amount': req.body.amount,
                };
            } else {
                obj = {
                    'firstName': req.body.firstName.trim(),
                    'lastName': req.body.lastName.trim(),
                    'email': req.body.email.trim(),
                };
            }

            return data.users.updateProfile(username, obj)
                .then((result) => {
                    if (!result.value) {
                        req.flash('error', 'Failed to update profile..');
                    } else {
                        req.flash('info', 'Succesfuly updated!');
                    }
                    res.locals.messages = req.flash();
                    return res.render('flash_message_template');
                })
                .catch(() => {
                    req.flash('error', 'Something happened');
                    res.locals.messages = req.flash();
                    return res.render('flash_message_template');
                });
        },
        postSubscribe(req, res) {
            const email = req.body.email;
            return data.subscribers.findByEmail(email)
                .then((subscriber) => {
                    if (subscriber) {
                        return res
                            .send({ message: 'Email already registered' });
                    }

                    const newSubscriber = {
                        email: email,
                        name: '',
                    };
                    return data.subscribers
                        .create(newSubscriber)
                        .then(() => {
                            return res
                                .send({ message: 'Thank you for subscribing' });
                        })
                        .catch((err) => {
                            const msg = 'Invalid email format';
                            return res.send({ message: msg });
                        });
                });
        },
        postFeedback(req, res) {
            return data.feedback
                .create(req.body)
                .then((result) => {
                    req.flash('info', 'Thank you for your feedback');
                    res.locals.messages = req.flash();

                    return res.render('flash_message_template');
                })
                .catch((err) => {
                    req.flash('error', 'Error sending feedback');
                    res.locals.messages = req.flash();

                    return res.render('flash_message_template');
                });
        },
        postDonation(req, res) {
            const user = req.user;
            if (!user) {
                const msg = 'You need to be logged to donate!';
                req.flash('info', msg);
                const redirect = {};
                redirect.message = msg;
                redirect.redirect = true;
                redirect.redirecturl = '/auth/log-in';
                return res.send(redirect);
            }

            const project = req.body.project;
            const donation = parseInt(req.body.donation, 10);

            return data.projects.donateToProject(project, donation)
                .then((proj) => {
                    if (!proj) {
                        return res.send({ message: 'Invalid project ref' });
                    }

                    data.users.addToDonated(user.username, [project])
                        .catch((er) => console.log(er));

                    const response = {};
                    response.message = 'You successfully donated ' +
                        `$${donation} to` + `'${proj.title}'. Thank you!`;
                    response.updatedAmount = proj.donated;
                    response.total = proj.amount;

                    return res.send(response);
                })

                .catch((err) => {
                    console.log('--- ERROR in api.router.js donate --- ' + err);
                });
        },
    };

    return controller;
};

module.exports = { init };

@@ -1711,32 +1711,30 @@
         
-return res.send(
+const fPart = 
 '%3Ch3%3ENo 
@@ -1758,56 +1758,106 @@
 ory 
-%3Cspan class=%22capitalize%22%3E' + category.category +
+' +%0A                            '%3Cspan class=%22capitalize%22%3E';%0A                        const sPart =
  '%3C/
@@ -1867,17 +1867,16 @@
 n%3E%3C/h3%3E'
-)
 ;%0A      
@@ -1885,32 +1885,79 @@
             
-%7D else %7B
+    return res.send(fPart + category.category + sPart);
 %0A           
@@ -1968,57 +1968,93 @@
     
+ %7D%0A
      
-projects = projects.slice((page - 1) * size,
+               const one = (page - 1) * size;%0A                    const two =
  pag
@@ -2061,23 +2061,75 @@
 e * size
-)
 ;%0A    
+                projects = projects.slice(one, two);%0A
         
@@ -2178,16 +2178,40 @@
 ojects',
+%0A                       
  %7B model
@@ -2240,36 +2240,32 @@
                 
-  
-  
 (err, html) =%3E %7B
@@ -2257,36 +2257,32 @@
 err, html) =%3E %7B%0A
-    
                 
@@ -2337,37 +2337,11 @@
     
-    %7D);%0A                    %7D
+%7D);
 %0A   

Fix eslint api controller