Navigation

    Vietnam

    Nodejs.vn

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Groups
    • Search
    1. Home
    2. mariohandsome
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by mariohandsome

    • RE: Telegram Nodejs

      Code mình viết. có gì sai mọi người chỉ bảo ạ.

      const https = require('https')
      const { ConfigTelegram } = require('../helpers/Constant')
      
      /**
       * Config Domain
       */
      const Telegram = {
        host: ConfigTelegram.urlBasic,
        port: ConfigTelegram.port,
        method: ConfigTelegram.method
      }
      
      const sendMessage = async (message, res) => {
        let sendRequest, messageSend
      
        try {
          messageSend = encodeURI(message)    
          // Config path send API
          Telegram.path = ConfigTelegram.function.sendMessage + messageSend
      
          // create request
          sendRequest = await https.request(Telegram)
      
          // Proccess
          sendRequest.end()
      
          // Error
          sendRequest.on('error', function (e) {
            throw e
          })
      
          return res.status(200).json('Sucess')
      
        } catch (err) {
          return err
        }
      }
      
      module.exports = {
        sendMessage
      }
      
      posted in Node.JS
      mariohandsome
      mariohandsome
    • RE: Cấu trúc chuẩn tên thư mục, tên file cho project nodejs

      @Tieu-dang-van bác có cấu trúc ra git không. cho em xin tham khảo ạ. em cũng dân PHP sang node.

      posted in Hỏi Đáp
      mariohandsome
      mariohandsome