laba5xnext 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/jsLibraryMappings.xml +6 -0
 - package/.idea/lab5.iml +12 -0
 - package/.idea/modules.xml +8 -0
 - package/06-02.js +73 -0
 - package/06-03.js +30 -0
 - package/06-04.js +28 -0
 - package/index.html +32 -0
 - package/m0603.js +32 -0
 - package/maxpackage/m0603.js +33 -0
 - package/maxpackage/package.json +11 -0
 - package/package.json +23 -0
 
    
        package/.idea/lab5.iml
    ADDED
    
    | 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <?xml version="1.0" encoding="UTF-8"?>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <module type="WEB_MODULE" version="4">
         
     | 
| 
      
 3 
     | 
    
         
            +
              <component name="NewModuleRootManager">
         
     | 
| 
      
 4 
     | 
    
         
            +
                <content url="file://$MODULE_DIR$">
         
     | 
| 
      
 5 
     | 
    
         
            +
                  <excludeFolder url="file://$MODULE_DIR$/.tmp" />
         
     | 
| 
      
 6 
     | 
    
         
            +
                  <excludeFolder url="file://$MODULE_DIR$/temp" />
         
     | 
| 
      
 7 
     | 
    
         
            +
                  <excludeFolder url="file://$MODULE_DIR$/tmp" />
         
     | 
| 
      
 8 
     | 
    
         
            +
                </content>
         
     | 
| 
      
 9 
     | 
    
         
            +
                <orderEntry type="inheritedJdk" />
         
     | 
| 
      
 10 
     | 
    
         
            +
                <orderEntry type="sourceFolder" forTests="false" />
         
     | 
| 
      
 11 
     | 
    
         
            +
              </component>
         
     | 
| 
      
 12 
     | 
    
         
            +
            </module>
         
     | 
    
        package/06-02.js
    ADDED
    
    | 
         @@ -0,0 +1,73 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // Информация о пакете
         
     | 
| 
      
 2 
     | 
    
         
            +
            // npm view nodemailer;
         
     | 
| 
      
 3 
     | 
    
         
            +
            // npm info nodemailer;
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            // Установка пакета 
         
     | 
| 
      
 6 
     | 
    
         
            +
            // npm install nodemailer; - локально
         
     | 
| 
      
 7 
     | 
    
         
            +
            // npm install -g nodemailer - глобально
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            // Проверка установлен ли пакет
         
     | 
| 
      
 10 
     | 
    
         
            +
            // npm -v nodemailer 
         
     | 
| 
      
 11 
     | 
    
         
            +
            // Проверить зависимости в package.json
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            const {mailF} = require("./m0603");
         
     | 
| 
      
 14 
     | 
    
         
            +
            const http = require("http");
         
     | 
| 
      
 15 
     | 
    
         
            +
            const fs = require("fs");
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            const nodeMailer = require("nodemailer");
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            function Mail(from, to, message) {
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                let transporter = nodeMailer.createTransport({
         
     | 
| 
      
 23 
     | 
    
         
            +
                    host: 'smtp.mail.ru',
         
     | 
| 
      
 24 
     | 
    
         
            +
                    port: 465,
         
     | 
| 
      
 25 
     | 
    
         
            +
                    secure: true,
         
     | 
| 
      
 26 
     | 
    
         
            +
                    auth: {
         
     | 
| 
      
 27 
     | 
    
         
            +
                        user: from,
         
     | 
| 
      
 28 
     | 
    
         
            +
                        pass: '***'
         
     | 
| 
      
 29 
     | 
    
         
            +
                    }
         
     | 
| 
      
 30 
     | 
    
         
            +
                });
         
     | 
| 
      
 31 
     | 
    
         
            +
                // 'bstulearning@mail.ru'
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                let mailOptions = {
         
     | 
| 
      
 34 
     | 
    
         
            +
                    from: from,
         
     | 
| 
      
 35 
     | 
    
         
            +
                    to: to,
         
     | 
| 
      
 36 
     | 
    
         
            +
                    subject: 'Пересылка',
         
     | 
| 
      
 37 
     | 
    
         
            +
                    text: message,
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                };
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                transporter.sendMail(mailOptions, (error, info) => {
         
     | 
| 
      
 42 
     | 
    
         
            +
                    if (error) {
         
     | 
| 
      
 43 
     | 
    
         
            +
                        return console.log(error);
         
     | 
| 
      
 44 
     | 
    
         
            +
                    }
         
     | 
| 
      
 45 
     | 
    
         
            +
                    console.log('Message %s sent: %s', info.messageId, info.response);
         
     | 
| 
      
 46 
     | 
    
         
            +
                    res.render('index');
         
     | 
| 
      
 47 
     | 
    
         
            +
                });
         
     | 
| 
      
 48 
     | 
    
         
            +
            }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            let block;
         
     | 
| 
      
 52 
     | 
    
         
            +
            http.createServer((req, res) => {
         
     | 
| 
      
 53 
     | 
    
         
            +
                let data = fs.readFileSync("index.html", 'utf-8');
         
     | 
| 
      
 54 
     | 
    
         
            +
                if (req.url == "/") {
         
     | 
| 
      
 55 
     | 
    
         
            +
                    res.end(data);
         
     | 
| 
      
 56 
     | 
    
         
            +
                }
         
     | 
| 
      
 57 
     | 
    
         
            +
                if (req.method == "POST") {
         
     | 
| 
      
 58 
     | 
    
         
            +
                    if (req.url == '/send-email') {
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                        req.on('data', (data) => {
         
     | 
| 
      
 61 
     | 
    
         
            +
                            block = JSON.parse(data);
         
     | 
| 
      
 62 
     | 
    
         
            +
                            from = block.from;
         
     | 
| 
      
 63 
     | 
    
         
            +
                            to = block.toOne;
         
     | 
| 
      
 64 
     | 
    
         
            +
                            mesage = block.message;
         
     | 
| 
      
 65 
     | 
    
         
            +
                            Mail(from, to, mesage);
         
     | 
| 
      
 66 
     | 
    
         
            +
                        });
         
     | 
| 
      
 67 
     | 
    
         
            +
                    }
         
     | 
| 
      
 68 
     | 
    
         
            +
                }
         
     | 
| 
      
 69 
     | 
    
         
            +
            }).listen(5000, '127.0.0.1', () => {
         
     | 
| 
      
 70 
     | 
    
         
            +
                console.log("Сервер запущен!");
         
     | 
| 
      
 71 
     | 
    
         
            +
            });
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
             
         
     | 
    
        package/06-03.js
    ADDED
    
    | 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            const {mailF} = require("./m0603");
         
     | 
| 
      
 2 
     | 
    
         
            +
            const http = require("http");
         
     | 
| 
      
 3 
     | 
    
         
            +
            const fs = require("fs");
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            let block;
         
     | 
| 
      
 7 
     | 
    
         
            +
            http.createServer((req, res) => {
         
     | 
| 
      
 8 
     | 
    
         
            +
                let data = fs.readFileSync("index.html", 'utf-8');
         
     | 
| 
      
 9 
     | 
    
         
            +
                if (req.url == "/") {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    res.end(data);
         
     | 
| 
      
 11 
     | 
    
         
            +
                }
         
     | 
| 
      
 12 
     | 
    
         
            +
                if (req.method == "POST") {
         
     | 
| 
      
 13 
     | 
    
         
            +
                    if (req.url == '/send-email') {
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                        req.on('data', (data) => {
         
     | 
| 
      
 16 
     | 
    
         
            +
                            block = JSON.parse(data);
         
     | 
| 
      
 17 
     | 
    
         
            +
                            from = block.from;
         
     | 
| 
      
 18 
     | 
    
         
            +
                            to = block.toOne;
         
     | 
| 
      
 19 
     | 
    
         
            +
                            mesage = block.message;
         
     | 
| 
      
 20 
     | 
    
         
            +
                            mailF(from, to, mesage);
         
     | 
| 
      
 21 
     | 
    
         
            +
                        });
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25 
     | 
    
         
            +
                }
         
     | 
| 
      
 26 
     | 
    
         
            +
            }).listen(5000, '127.0.0.1', () => {
         
     | 
| 
      
 27 
     | 
    
         
            +
                console.log("Сервер запущен!");
         
     | 
| 
      
 28 
     | 
    
         
            +
            });
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
             
         
     | 
    
        package/06-04.js
    ADDED
    
    | 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            const {mailF} = require("maxpackage");
         
     | 
| 
      
 2 
     | 
    
         
            +
            const http = require("http");
         
     | 
| 
      
 3 
     | 
    
         
            +
            const fs = require("fs");
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            let block;
         
     | 
| 
      
 7 
     | 
    
         
            +
            http.createServer((req, res) => {
         
     | 
| 
      
 8 
     | 
    
         
            +
                let data = fs.readFileSync("index.html", 'utf-8');
         
     | 
| 
      
 9 
     | 
    
         
            +
                if (req.url == "/") {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    res.end(data);
         
     | 
| 
      
 11 
     | 
    
         
            +
                }
         
     | 
| 
      
 12 
     | 
    
         
            +
                if (req.method == "POST") {
         
     | 
| 
      
 13 
     | 
    
         
            +
                    if (req.url == '/send-email') {
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                        req.on('data', (data) => {
         
     | 
| 
      
 16 
     | 
    
         
            +
                            block = JSON.parse(data);
         
     | 
| 
      
 17 
     | 
    
         
            +
                            from = block.from;
         
     | 
| 
      
 18 
     | 
    
         
            +
                            to = block.toOne;
         
     | 
| 
      
 19 
     | 
    
         
            +
                            mesage = block.message;
         
     | 
| 
      
 20 
     | 
    
         
            +
                            mailF(from, to, mesage);
         
     | 
| 
      
 21 
     | 
    
         
            +
                        });
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25 
     | 
    
         
            +
                }
         
     | 
| 
      
 26 
     | 
    
         
            +
            }).listen(2000, '127.0.0.1', () => {
         
     | 
| 
      
 27 
     | 
    
         
            +
                console.log("Сервер запущен!");
         
     | 
| 
      
 28 
     | 
    
         
            +
            });
         
     | 
    
        package/index.html
    ADDED
    
    | 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <!DOCTYPE html>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <html lang="en">
         
     | 
| 
      
 3 
     | 
    
         
            +
            <head>
         
     | 
| 
      
 4 
     | 
    
         
            +
                <meta charset="UTF-8">
         
     | 
| 
      
 5 
     | 
    
         
            +
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
         
     | 
| 
      
 6 
     | 
    
         
            +
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
         
     | 
| 
      
 7 
     | 
    
         
            +
                <title>Document</title>
         
     | 
| 
      
 8 
     | 
    
         
            +
            </head>
         
     | 
| 
      
 9 
     | 
    
         
            +
            <body>
         
     | 
| 
      
 10 
     | 
    
         
            +
            <form method="post">
         
     | 
| 
      
 11 
     | 
    
         
            +
                <input id="from" name="from" type="text" placeholder="Отправитель"/>
         
     | 
| 
      
 12 
     | 
    
         
            +
                <input id="toOne" name="to" type="text" placeholder="Получатель"/>
         
     | 
| 
      
 13 
     | 
    
         
            +
                <input id="message" name="message" type="text" placeholder="Сообщение"/>
         
     | 
| 
      
 14 
     | 
    
         
            +
                <button id="send" type="submit" onclick="Post();">Отправить</button>
         
     | 
| 
      
 15 
     | 
    
         
            +
            </form>
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            <script>
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                function Post() {
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    fetch('/send-email', {
         
     | 
| 
      
 22 
     | 
    
         
            +
                        method: 'POST', mode: 'no-cors',
         
     | 
| 
      
 23 
     | 
    
         
            +
                        headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
         
     | 
| 
      
 24 
     | 
    
         
            +
                        body: JSON.stringify({from: from.value, toOne: toOne.value, message: message.value})
         
     | 
| 
      
 25 
     | 
    
         
            +
                    })
         
     | 
| 
      
 26 
     | 
    
         
            +
                        .then(response => response.json())
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                }
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            </script>
         
     | 
| 
      
 31 
     | 
    
         
            +
            </body>
         
     | 
| 
      
 32 
     | 
    
         
            +
            </html>
         
     | 
    
        package/m0603.js
    ADDED
    
    | 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            const nodeMailer = require("nodemailer");
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module.exports.mailF = function (from, to, message) {
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                let transporter = nodeMailer.createTransport({
         
     | 
| 
      
 6 
     | 
    
         
            +
                    host: 'smtp.mail.ru',
         
     | 
| 
      
 7 
     | 
    
         
            +
                    port: 465,
         
     | 
| 
      
 8 
     | 
    
         
            +
                    secure: true,
         
     | 
| 
      
 9 
     | 
    
         
            +
                    auth: {
         
     | 
| 
      
 10 
     | 
    
         
            +
                        user: from,
         
     | 
| 
      
 11 
     | 
    
         
            +
                        pass: '***'
         
     | 
| 
      
 12 
     | 
    
         
            +
                    }
         
     | 
| 
      
 13 
     | 
    
         
            +
                });
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                let mailOptions = {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    from: from,
         
     | 
| 
      
 18 
     | 
    
         
            +
                    to: to,
         
     | 
| 
      
 19 
     | 
    
         
            +
                    subject: 'Пересылка',
         
     | 
| 
      
 20 
     | 
    
         
            +
                    text: message,
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                };
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                transporter.sendMail(mailOptions, (error, info) => {
         
     | 
| 
      
 25 
     | 
    
         
            +
                    if (error) {
         
     | 
| 
      
 26 
     | 
    
         
            +
                        return console.log(error);
         
     | 
| 
      
 27 
     | 
    
         
            +
                    }
         
     | 
| 
      
 28 
     | 
    
         
            +
                    console.log('Message %s sent: %s', info.messageId, info.response);
         
     | 
| 
      
 29 
     | 
    
         
            +
                    res.render('index');
         
     | 
| 
      
 30 
     | 
    
         
            +
                });
         
     | 
| 
      
 31 
     | 
    
         
            +
            }
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            const nodeMailer = require("nodemailer");
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module.exports.mailF = function(from,to,message) {
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                let transporter = nodeMailer.createTransport({
         
     | 
| 
      
 7 
     | 
    
         
            +
                   host: 'smtp.mail.ru',
         
     | 
| 
      
 8 
     | 
    
         
            +
                   port: 465,
         
     | 
| 
      
 9 
     | 
    
         
            +
                   secure: true,
         
     | 
| 
      
 10 
     | 
    
         
            +
                   auth: {
         
     | 
| 
      
 11 
     | 
    
         
            +
                       user: from,
         
     | 
| 
      
 12 
     | 
    
         
            +
                       pass: '***'
         
     | 
| 
      
 13 
     | 
    
         
            +
                   }
         
     | 
| 
      
 14 
     | 
    
         
            +
               });
         
     | 
| 
      
 15 
     | 
    
         
            +
               // 'bstulearning@mail.ru'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
               let mailOptions = {
         
     | 
| 
      
 18 
     | 
    
         
            +
                   from: from, 
         
     | 
| 
      
 19 
     | 
    
         
            +
                   to: to, 
         
     | 
| 
      
 20 
     | 
    
         
            +
                   subject: 'Пересылка', 
         
     | 
| 
      
 21 
     | 
    
         
            +
                   text: message, 
         
     | 
| 
      
 22 
     | 
    
         
            +
               
         
     | 
| 
      
 23 
     | 
    
         
            +
               };
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
               transporter.sendMail(mailOptions, (error, info) => {
         
     | 
| 
      
 26 
     | 
    
         
            +
                   if (error) {
         
     | 
| 
      
 27 
     | 
    
         
            +
                       return console.log(error);
         
     | 
| 
      
 28 
     | 
    
         
            +
                   }
         
     | 
| 
      
 29 
     | 
    
         
            +
                   console.log('Message %s sent: %s', info.messageId, info.response);
         
     | 
| 
      
 30 
     | 
    
         
            +
                       res.render('index');
         
     | 
| 
      
 31 
     | 
    
         
            +
               });
         
     | 
| 
      
 32 
     | 
    
         
            +
            }
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
    
        package/package.json
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            {
         
     | 
| 
      
 2 
     | 
    
         
            +
              "dependencies": {
         
     | 
| 
      
 3 
     | 
    
         
            +
                "maxpackage": "^1.0.0",
         
     | 
| 
      
 4 
     | 
    
         
            +
                "nodemailer": "^6.9.1"
         
     | 
| 
      
 5 
     | 
    
         
            +
              },
         
     | 
| 
      
 6 
     | 
    
         
            +
              "name": "laba5xnext",
         
     | 
| 
      
 7 
     | 
    
         
            +
              "version": "1.0.0",
         
     | 
| 
      
 8 
     | 
    
         
            +
              "main": "m0603.js",
         
     | 
| 
      
 9 
     | 
    
         
            +
              "scripts": {
         
     | 
| 
      
 10 
     | 
    
         
            +
                "test": "echo \"Error: no test specified\" && exit 1"
         
     | 
| 
      
 11 
     | 
    
         
            +
              },
         
     | 
| 
      
 12 
     | 
    
         
            +
              "author": "xnext",
         
     | 
| 
      
 13 
     | 
    
         
            +
              "license": "ISC",
         
     | 
| 
      
 14 
     | 
    
         
            +
              "description": "qwerty",
         
     | 
| 
      
 15 
     | 
    
         
            +
              "devDependencies": {},
         
     | 
| 
      
 16 
     | 
    
         
            +
              "repository": {
         
     | 
| 
      
 17 
     | 
    
         
            +
                "type": "git",
         
     | 
| 
      
 18 
     | 
    
         
            +
                "url": "none"
         
     | 
| 
      
 19 
     | 
    
         
            +
              },
         
     | 
| 
      
 20 
     | 
    
         
            +
              "keywords": [
         
     | 
| 
      
 21 
     | 
    
         
            +
                "none"
         
     | 
| 
      
 22 
     | 
    
         
            +
              ]
         
     | 
| 
      
 23 
     | 
    
         
            +
            }
         
     |