UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Node.js/npm fort Apps/Games

    Scheduled Pinned Locked Moved App Development
    7 Posts 3 Posters 415 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Homer
      last edited by

      Hello,

      Since a while there is the node.js app which installs this server on the device.
      However, I struggle to understand how to use this for apps.
      For many of my webapps I need typescript packages which need to be served by a web server, for which I would need node.js for example.

      Can anyone help me getting started with this? How can I use the installed node.js server from my apps? Do I have to install packages in node.js from the terminal or can I do this inside my app?

      Many thanks for your support.

      I G 2 Replies Last reply Reply Quote 0
      • I Offline
        idonthatevests @Homer
        last edited by

        @Homer said:
        How can I use the installed node.js server from my apps?

        I think for native apps you should add portable nodejs runtime to your package.

        Do I have to install packages in node.js from the terminal or can I do this inside my app?

        Probably first, unless you make an unconfined app

        H 1 Reply Last reply Reply Quote 0
        • H Offline
          Homer @idonthatevests
          last edited by

          @idonthatevests that would include bundling the node.js package with my app and having a startup hook to start node.js when the app is launched?

          I 1 Reply Last reply Reply Quote 0
          • I Offline
            idonthatevests @Homer
            last edited by

            @Homer
            right, and now it's probably the only valid way for confined apps

            1 Reply Last reply Reply Quote 0
            • G Offline
              gpatel-fr @Homer
              last edited by

              @Homer said:

              need to be served by a web server, for which I would need node.js for example.

              Preliminary remark: I know nil about your use case so I hope my question don't sound snarky or condescending.

              I don't know why when you are searching for a web server, you say you need node.js.

              Is there something special in node.js that you need rather using the web server that is already available in python3 installed by default on any UT version ?

              H 1 Reply Last reply Reply Quote 0
              • H Offline
                Homer @gpatel-fr
                last edited by

                @gpatel-fr my go-to approach for app development is Qml with python template with a qml webview component. The app UI and logic exists in html/css/JavaScript. The app I want to develop would download bank account data for display and data science on the phone. In Germany there is fints/HBCI interface, for which typescript libraries exist.
                If I understood right, typescript libraries have to be served from a server, cannot just be statically linked local files.
                Therefore, my approach would only work, if I am able to spin up a node.js server which serves the library.

                Myother idea was 2D game development using pixI.js/hexI frameworks.

                I don't know how to utilize the node.js from the app store for that and as far as I know, the qml python integration only calls python functions, does not support starting a python server process.

                This is why I wanted to start a node.js in the background when my app starts and serve th javascript packages that the app requires.

                G 1 Reply Last reply Reply Quote 0
                • G Offline
                  gpatel-fr @Homer
                  last edited by

                  @Homer said:

                  typescript libraries have to be served from a server, cannot just be statically linked local files.

                  phablet@ubuntu-phablet:~/myserver$ systemctl --user cat myserv
                  # /home/phablet/.config/systemd/user/myserv.service
                  [Unit]
                  Description=my http server
                  After=network.target
                  
                  [Service]
                  WorkingDirectory=/home/phablet/myserver
                  ExecStart=/usr/bin/python3 -m http.server
                  Type=simple
                  
                  [Install]
                  WantedBy=multi-user.target
                  Alias=myserver.service
                  

                  systemctl --user daemon-reload
                  systemctl --user start myserv
                  then browse to http://localhost:8000

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post