| <!doctype html><html itemscope itemtype=http://schema.org/WebPage lang=en class=no-js><head><script>(function(){const t=localStorage.getItem("theme");t==="dark"?document.documentElement.classList.add("dark-mode"):t==="light"&&document.documentElement.classList.remove("dark-mode");const n=document.documentElement.classList.contains("dark-mode"),e=document.getElementById("theme-icon");e&&(e.classList&&e.classList.toggle("fa-sun",!n),e.classList&&e.classList.toggle("fa-moon",n))})()</script><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><link rel=canonical type=text/html href=/docs/reference/runtimes/nodejs/><link rel=alternate type=application/rss+xml href=/docs/reference/runtimes/nodejs/index.xml><meta name=robots content="noindex, nofollow"><link rel="shortcut icon" href=/favicons/favicon.ico><link rel=apple-touch-icon href=/favicons/apple-touch-icon-180x180.png sizes=180x180><link rel=icon type=image/png href=/favicons/favicon-16x16.png sizes=16x16><link rel=icon type=image/png href=/favicons/favicon-32x32.png sizes=32x32><link rel=icon type=image/png href=/favicons/android-36x36.png sizes=36x36><link rel=icon type=image/png href=/favicons/android-48x48.png sizes=48x48><link rel=icon type=image/png href=/favicons/android-72x72.png sizes=72x72><link rel=icon type=image/png href=/favicons/android-96x96.png sizes=96x96><link rel=icon type=image/png href=/favicons/android-144x144.png sizes=144x144><link rel=icon type=image/png href=/favicons/android-192x192.png sizes=192x192><title>NodeJS | Apache OpenServerless™</title> |
| <meta name=description content="A Docsy example site"><meta property="og:url" content="/docs/reference/runtimes/nodejs/"><meta property="og:site_name" content="Apache OpenServerless™"><meta property="og:title" content="NodeJS"><meta property="og:description" content="Creating and invoking JavaScript actions The process of creating JavaScript actions is similar to that of other actions. The following sections guide you through creating and invoking a single JavaScript action, and demonstrate how to bundle multiple JavaScript files and third party dependencies."><meta property="og:locale" content="en"><meta property="og:type" content="website"><meta itemprop=name content="NodeJS"><meta itemprop=description content="Creating and invoking JavaScript actions The process of creating JavaScript actions is similar to that of other actions. The following sections guide you through creating and invoking a single JavaScript action, and demonstrate how to bundle multiple JavaScript files and third party dependencies."><meta itemprop=dateModified content="2025-08-01T16:51:57+02:00"><meta itemprop=wordCount content="1594"><meta name=twitter:card content="summary"><meta name=twitter:title content="NodeJS"><meta name=twitter:description content="Creating and invoking JavaScript actions The process of creating JavaScript actions is similar to that of other actions. The following sections guide you through creating and invoking a single JavaScript action, and demonstrate how to bundle multiple JavaScript files and third party dependencies."><link rel=preload href=/scss/main.min.63d3665407fbf8c19373c7376d20ae27b458d1c085cc6645b75d65bbf044b537.css as=style><link href=/scss/main.min.63d3665407fbf8c19373c7376d20ae27b458d1c085cc6645b75d65bbf044b537.css rel=stylesheet integrity><script src=/js/jquery-3.7.1.min.js></script><script defer src=/js/lunr-2.3.9.min.js></script><link rel=stylesheet href=/css/prism.css></head><body class=td-section><header><nav class="td-navbar js-navbar-scroll" data-bs-theme=dark><div class="container-fluid flex-column flex-md-row"><a class=navbar-brand href=/><span class="navbar-brand__logo navbar-logo"><svg viewBox="0 0 1024 781"><g stroke-width="2" fill="none" stroke-linecap="butt"><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M438.8 120.98Q435.57 121.88 434.78 122.21 431.12 123.7 423.21 127.52"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M423.21 127.52C416.56 130.57 409.18 133.39 403.28 136.68Q394.42 141.62 387.66 147.15 379.83 153.54 367.83 164.27C360.8 170.55 354.15 177.8 347.45 184.72"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M347.45 184.72 342.5 189.88Q342.21 190.18 341.84 190.38 341.07 190.8 341.03 191.71 341.01 192.11 340.65 191.92 340.53 191.86 340.4 191.9 339.91 192.07 339.71 192.6 339.03 194.41 337.73 195.89 337.39 196.28 337.81 195.97 337.86 195.93 337.92 195.9 338.54 195.6 338.12 196.15 335.04 200.12 332.21 203.99 332.03 204.23 331.79 204.04L331.46 203.78Q331.41 203.74 331.44 203.69 332.29 202.33 333.12 201.24 333.2 201.13 333.11 201 333.07 200.95 333.03 201 332.05 202.53 330.7 203.79 330.54 203.94 330.75 203.87 330.79 203.85 330.84 203.87 331.05 203.97 331.06 204.2 331.13 205.63 329.99 206.5A1.85 1.78 81.9 00329.4 207.32Q329.06 208.29 328.39 209.14 328.09 209.52 327.61 209.58 325.89 209.82 326 211.78A1.3 1.27-28 01325.72 212.66Q324.07 214.8 323.12 217.7"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M323.12 217.7 318.02 228.46"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M318.02 228.46Q313.27 234.86 311.76 237.75 309.37 242.33 305.99 252.05 304.46 256.44 305.93 254.25"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M305.93 254.25Q305.62 255.63 304.89 256.82 304.77 257.01 304.97 257.12L305.2 257.24Q305.23 257.26 305.24 257.22 306.13 255.05 307.26 252.78 307.34 252.62 307.51 252.71L307.73 252.82Q307.75 252.84 307.74 252.86 306.25 255.22 305.41 257.9 304.19 261.82 302.64 265.97 302.35 266.75 301.89 267.38C300.98 268.59 301.07 270.27 300.39 271.68Q299.06 274.47 298.36 277.53 298.26 277.97 297.92 278.28 297.32 278.84 297.16 279.76 296.53 283.42 295.29 287.79C294.38 290.99 294.69 294.16 293.83 297.36 292.99 300.5 293.12 303.75 292.59 306.9Q290.82 317.42 290.83 332.15C290.83 348.21 291.88 362.54 296.59 377.96Q298.48 384.15 300.49 390.37 301.18 392.52 299.65 390.86 298.11 389.19 295.54 387.72 290.29 384.72 285.05 381.84"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M285.05 381.84Q283.43 380.56 281.9 380.1C279.89 379.5 278.26 378.64 276.39 378.23 274.28 377.77 271.98 376.83 270.21 376.37Q255.65 372.58 240.43 373.13"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M240.43 373.13Q233.74 372.8 227 373.57 218.25 374.57 209.52 375.73 205.54 376.26 202.03 377.1 198.41 377.96 194.65 378.96 194.3 379.05 194.13 379.39A.74.72-79.5 01193.55 379.8Q189.92 380.15 187.2 381.49 184.73 382.71 182.18 383.81 179.39 385.01 177.01 386.52q-10.2 6.5-21.71 15.23-11.53 8.75-19.24 19.06C135.77 421.2 135.78 421.58 135.55 421.95Q132.47 426.87 128.69 431.08 125.96 434.1 123.91 437.19 121.72 440.47 119.57 443.8 119.26 444.28 119.09 444.83 118.95 445.24 118.63 445.53 116.84 447.17 116 449.6A1.7 1.69 80.4 01115.47 450.35Q115.1 450.66 114.87 451.08 111.96 456.46 110.57 460.85 109.15 465.35 107.7 469.25 104.74 477.22 102.44 485.43 102.33 485.83 102.71 485.65 103.01 485.5 102.86 485.13 102.81 485.01 102.88 485.11 102.9 485.13 102.93 485.15 102.99 485.16 102.97 485.22 101.22 490.96 100.5 495.31 98.77 505.78 98.79 517.39 98.79 517.88 98.5 518.29 98.25 518.63 98.23 519.04 97.87 528.44 98.18 537.77"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M98.18 537.77Q98.75 547.92 100.1 554.97q3.73 19.49 13.1 38.62 15.56 31.76 43.03 52.74Q162.21 650.9 172.97 656.97 173.4 657.21 173.93 657.11 174.27 657.04 174.47 657.33 175.25 658.44 176.62 658.35 176.74 658.34 176.63 658.37 176.5 658.41 176.38 658.48 176.21 658.58 176.36 658.71 179.72 661.6 184.36 663.69 193.12 667.64 200.92 670.96 203.51 672.06 206.39 672.09C213.79 672.17 220.75 674.59 227.85 675.5Q241.51 677.25 258.42 677.27 335.37 677.38 410.89 677.26 415.61 677.25 421.31 677.06A.94.94.0 00422.22 676.12L422.48 603.46"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M422.48 603.46C422.72 519.97 422.5 436.49 422.59 353Q422.59 348.1 423.66 344.48C424.85 340.39 429.55 336.76 433.9 336.21Q436.66 335.85 439.49 335.86 494.27 335.98 572.06 335.69 584.93 335.64 589.91 334.78 597.94 333.4 606.26 330.74C615.95 327.65 626.03 324.05 635.5 320.14Q646.37 315.66 657.62 312.96 667.09 310.69 676.08 307.82 691.68 302.85 706.51 297.5 712.77 295.24 718.01 296.26"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M718.01 296.26Q725.51 299 729.94 305.03 734.73 311.55 735.73 318.39 736.01 320.31 736.08 332.62 736.25 364.24 736.19 397 736.19 399.08 736.23 400.97"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M736.23 400.97Q735.9 449.45 735.46 497.75 735.19 527.79 736.15 604.08"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M736.15 604.08 736.67 675.56A2.19 2.19.0 00738.87 677.73Q767.94 677.54 795.44 677.62 817.97 677.68 841.39 674.15 847.16 673.28 852.49 671.66C860.03 669.38 868.01 666.67 874.77 663.04 886.51 656.73 899.29 648.52 907.95 640.2Q915.92 632.55 923.63 625.37 929.31 620.09 933.33 613.73C935.19 610.8 937.51 608.42 939.12 605.35 940.33 603.02 941.92 600.89 943.21 598.54Q943.45 598.12 943.29 597.67L943.16 597.31A.83.81 57.5 01943.33 596.5Q944.29 595.46 944.39 593.99A1.71 1.69-26.2 01944.69 593.13Q945.61 591.77 945.97 590.12 946.3 588.59 946.91 587.17 949.11 582.1 951.27 576.84 951.72 575.76 951.83 574.56 951.94 573.38 952.44 572.26 953.13 570.7 953.66 569.03 955.4 563.55 956.49 558.44 958.79 547.6 959.78 535.62 961.35 516.61 958.61 497.75C957.77 492.01 956.07 486.17 954.92 480.43Q954.15 476.64 952.59 472.89 950.98 469.01 950.1 465.43 949.18 461.64 947.3 458.42C946.62 457.26 946.43 456.23 946.02 455.01Q945.59 453.76 944.8 452.54 943.11 449.92 941.65 447.11C941.28 446.4 941.38 445.57 941.14 445Q940.04 442.39 934.75 436.96"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M934.75 436.96c-13.04-17.58-27.99-33.32-46.72-44.66"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M888.03 392.3Q882.24 387.36 875.24 384.36 875.2 384.34 875.22 384.3L875.35 384.08Q875.43 383.93 875.59 384L877.96 385.14Q877.99 385.16 878 385.13L878.15 384.9Q878.28 384.7 878.05 384.62 872.13 382.5 867.06 380.02 863.08 378.07 858.83 376.66 854.27 375.14 850.01 374.21 849.95 374.2 849.93 374.26L849.87 374.51A.03.03.0 00849.9 374.55Q857.11 375.83 861.77 378.39 864.48 379.88 861.51 379.04 859.01 378.34 856.67 377.6 852.48 376.26 846.15 375.67 846.1 375.67 846.08 375.63 846.06 375.57 846.12 375.55 846.17 375.54 846.21 375.55 847.25 375.84 848.13 375.69 848.82 375.58 848.13 375.43 844.1 374.56 840.02 375.3"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M840.02 375.3C831.63 374.33 823.73 372.69 814.84 373.31 813.35 373.41 812.06 372.84 810.51 372.87Q803.01 373.01 796.27 374.55C793.63 375.15 790.95 375.45 788.28 375.61Q787.88 375.64 787.61 375.92 787.23 376.32 786.68 376.4 780.74 377.31 775.04 379.37 770.87 380.88 764.64 384.8 759.7 387.91 754.7 391.19"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M754.7 391.19Q756.26 383.46 757.81 375.98 759.76 366.58 760.51 360.7 763.46 337.48 761.63 314.17 760.99 306.01 758.91 294.37 757.01 283.7 754.89 272.75 752.59 260.84 747.54 249.46 745.67 245.25 743.7 240.2 741.38 234.25 736.66 226.75C735.76 225.32 735.24 223.86 734.21 222.51Q733.24 221.24 732.62 219.78C731.88 218.02 730.63 216.88 729.84 215.09 728.87 212.88 727.16 211.39 726.04 209.26Q724.69 206.7 722.92 204.55 721.11 202.35 719.49 200.03C716.95 196.39 714.67 192.59 711.27 189.61Q707.54 186.33 704.82 182.42C701.84 178.13 697.85 175.09 694.54 171.01 691.17 166.84 686.76 163.44 682.74 159.88 681.82 159.06 681.72 157.86 680.73 157.06Q677.63 154.54 674.69 152.45A.07.06-54.1 00674.6 152.47L674.46 152.68Q674.33 152.89 674.54 153.03 676.02 153.98 677.32 155.07 677.52 155.24 677.29 155.11C674.74 153.75 672.51 152.11 670.69 149.82Q669.3 148.07 667.31 146.74 660.44 142.14 653.7 138.48 648.98 135.92 644.35 132.84 639.79 129.81 632.39 126.59 617.15 119.97 605.94 116.26C604.1 115.65 602.23 115.81 600.47 115.15"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M600.47 115.15Q599.76 114.79 599.28 114.25"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M599.28 114.25Q596.64 112.8 593.69 111.95 583.64 109.04 573.39 106.9 563.66 104.88 556.72 105.12"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M556.72 105.12Q535.59 102.85 519.25 103.18 496.98 103.62 471.85 109.31C463.27 111.26 455.62 114.24 447.42 117.07Q446.79 117.29 446.29 117.73 445.73 118.22 445.1 118.66 444.28 119.23 443.25 119.55 441.01 120.23 438.8 120.98"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M556.72 105.12Q564.58 106.17 572.15 108.42C574.83 109.21 577.17 109.07 579.82 109.64Q580.27 109.74 580.44 110.18 580.67 110.82 581.38 110.86 584.36 111.04 587.12 112.11C589.32 112.96 591.64 112.98 593.93 113.32Q594.18 113.36 596.46 114.17 597.76 114.63 599.28 114.25"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M600.47 115.15Q594.24 113.95 588.04 112.66 587.87 112.62 587.83 112.79 587.79 112.96 587.95 113.01 608.88 119.22 628.21 129.72C633.49 132.58 638.52 136.35 642.99 140.24q14.51 12.64 31.59 30.96Q681.7 178.84 686.51 185.46 692.99 194.41 696.62 201.36q10.9 20.91 18.41 47.15Q719.1 262.72 719.73 277.51 719.97 283.23 720.2 288.75 720.33 291.8 718.01 296.26"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M422.48 603.46 422.19 604.18Q421.98 604.7 421.43 604.61 416.66 603.86 412.59 603.87 348.88 604.09 284.71 603.84 267.13 603.77 251.02 602.46q-26.06-2.13-48.84-16.86C192.75 579.51 184.08 570.63 176.23 562.27 168.02 553.53 162.76 544.13 157.62 533.43Q155.23 528.46 153.32 520.84 150.92 511.24 149.17 502.91 148.38 499.18 148.32 495.49 148.17 486.3 148.6 475.52 148.73 472.34 149.5 469.45C150.03 467.49 149.69 465.7 150.07 463.83Q151.96 454.51 155.02 444.09 155.48 442.53 153.86 442.72 152.56 442.88 151.06 444.55 146.57 449.55 141.46 455.04 139.5 457.14 138.35 459.6C134.82 467.17 129.7 474.41 125.5 481.29Q121.17 488.38 116.92 498.43q-5.45 12.9-6.99 23.22C108.92 528.49 108.26 535.39 107.3 542.31Q107.23 542.83 106.78 543.08C101.52 546 99.61 542.27 98.18 537.77"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M240.43 373.13Q248.72 374.13 256.93 375.23C258.7 375.47 260.5 375.38 262.22 375.92Q264.38 376.6 266.46 376.63 268.9 376.67 270.74 377.14 278.05 378.99 285.05 381.84"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M305.93 254.25l12.09-25.79"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M323.12 217.7 323.73 217.65Q324.29 217.6 324.32 217.04 324.34 216.71 324.56 216.47 325.2 215.76 324.74 216.59 324.56 216.9 324.39 217.19 324.34 217.28 324.42 217.33 324.53 217.4 324.61 217.5 324.73 217.67 324.8 217.48L327.22 210.74Q327.33 210.44 327.62 210.57L327.88 210.69Q327.9 210.7 327.87 210.75L326.51 213.47Q326.35 213.8 326.68 213.96L326.95 214.1A.12.12.0 00327.11 214.04Q328.64 210.79 330.13 208.73 334.34 202.94 338.25 196.98C340.99 192.8 344.46 188.91 347.45 184.72"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M423.21 127.52l11.43-4.11Q434.84 123.34 434.69 123.5 434.59 123.61 434.43 123.71 433.68 124.17 434.55 124.09 434.86 124.06 435.14 123.85 436.98 122.44 438.8 120.98"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M754.7 391.19Q747.41 397.76 741.58 399.89 740.39 400.32 736.23 400.97"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M840.02 375.3Q848.37 376.89 856.74 378.43 858.39 378.73 859.67 379.4 861.35 380.28 862.67 380.11 863.04 380.06 862.71 380.22 862.58 380.28 862.61 380.45A.15.15.0 00862.73 380.57Q866.19 381.33 869.24 383.34 871.62 384.91 874.77 386.12 881.6 388.74 888.03 392.3"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M934.75 436.96Q933.36 439.7 931.62 440.82 930.42 441.59 929.18 440.89C920.72 436.1 912.25 432.32 903.95 427.51Q895.85 422.81 887.81 419.18A.49.49.0 00887.11 419.62Q887.09 420.94 887.79 422.07C891.49 428.02 895.07 433.53 898.27 440Q900.43 444.36 901.68 448 905.05 457.86 905.65 470.46 906.19 481.77 906.47 492.77 906.79 505.08 902.92 519.5C901.13 526.18 898.98 532.57 895.88 538.78Q889.94 550.64 883.64 559.19 875.85 569.75 866.31 577.47 846.68 593.35 821.44 600.21C811.7 602.85 801.87 603.19 791.75 603.52Q762.45 604.46 736.15 604.08"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M572.05 680.95Q573.46 683.34 577.75 683.35 578.25 683.35 578.66 683.64 580.2 684.7 582 685.13 584.37 685.69 585.95 686.1 588.82 686.85 591.3 687.21C595.8 687.86 600.29 689.82 604.84 691.11Q618.05 694.87 630.86 698.4 635.66 699.73 651.25 702.9 652.68 703.19 654.31 703.37 655.83 703.54 657.52 704.26 660.29 705.43 664.46 705.55"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M664.46 705.55 700.51 716.23A.45.45.0 00701.07 715.67Q700.51 713.85 700.53 711.75 701.4 620.4 700.42 518.5 700.28 504.3 700.93 458.5 701.46 420.35 700.4 335.5 700.38 334.25 700.52 333.01A.89.88 85.1 00699.4 332.06Q679.62 337.71 665.91 342.7 641.72 351.5 619.65 358.49 592.44 367.1 572.6 374.15A1.9 1.89-9.9 00571.34 375.93Q571.18 513.33 571.39 654.5 571.41 667.76 572.05 680.95"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M664.46 705.55Q662.11 704.49 659.7 703.75 657.6 703.1 655.67 702.18 653.66 701.22 651.42 700.83C647.87 700.21 644.58 699.9 641.14 698.5Q637.25 696.91 633.31 695.66 624.29 692.77 614.98 690.12 607.98 688.12 599.95 686.55 588.3 684.27 584.74 683.66 576.99 682.31 572.05 680.95"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M506.73 508.96Q507.23 508.97 507.24 509.47L507.61 567.73A1.71 1.71.0 00509.29 569.43L512.14 569.48Q513.67 569.51 513.68 567.99L514.06 509.31A.65.65.0 01514.72 508.66Q524.38 508.75 533.37 508.51 534.45 508.49 535.45 508.14 536.77 507.68 535.94 506.56 525.56 492.62 516.03 477.72 513.11 473.15 510.64 468.22A.71.71.0 00509.34 468.32Q508.89 469.68 508.14 470.81 499.59 483.62 490.59 498.33C488.69 501.42 486.13 503.98 484.7 507.4A.85.84-75.5 00485.38 508.57C492.34 509.35 499.77 508.84 506.73 508.96"/><path stroke="#e2f3ff" vector-effect="non-scaling-stroke" d="M323.4069 219.9496A.86.45 98.9 00323.9846 219.1696.86.45 98.9 00323.6731 218.2504.86.45 98.9 00323.0954 219.0304.86.45 98.9 00323.4069 219.9496"/><path stroke="#76a3c4" vector-effect="non-scaling-stroke" d="M562.87 105.64Q563.01 105.79 563.21 105.74 563.58 105.65 563.24 105.48 563.06 105.39 562.89 105.5A.09.09.0 00562.87 105.64"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M679.22 372.53C679.23 371.09 679.54 369.88 679.85 368.51A.54.54.0 00679.29 367.85Q677.1 368.03 675.2 368.64 662.08 372.86 652.04 375.23 641.91 377.62 633.09 380.61 616.35 386.29 597.27 393.54C595.19 394.33 594.11 394.37 594.1 396.75Q593.82 453.73 594.23 510.63A.53.53.0 00594.87 511.14C612.16 507.54 629.52 503.71 647.2 500.59Q662.96 497.81 678.69 494.94 679.2 494.85 679.2 494.33 679.02 429.9 679.22 372.53"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M679.1894 535.7817a14.73 13.11 84.9 0011.7487-15.8371 14.73 13.11 84.9 00-14.3675-13.5063 14.73 13.11 84.9 00-11.7487 15.8371 14.73 13.11 84.9 0014.3675 13.5063"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M653.47 677.48C653.58 677.65 653.78 677.81 653.97 677.85Q666.29 680.76 678.03 684.83A.8.79-79.7 00679.09 684.09C679.65 637.75 679.02 593.21 679.12 547.6Q679.12 546.36 677.91 546.11 673.94 545.3 670.08 544.24C662.1 542.05 657.76 536.87 655.27 529.33A.58.57 76.9 00654.64 528.93Q625.29 532.84 594.78 537.76A.97.97.0 00593.96 538.72L594.14 660.05A1.82 1.81-79.8 00595.31 661.75Q600.8 663.83 606.74 665.66 624.02 670.98 642.31 674.66 645.11 675.22 647.69 676.02 650.42 676.85 653.38 677.42 653.44 677.43 653.47 677.48"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M663.15 390.16A.99.99.0 00661.85 389.22l-51.99 17.14A.99.99.0 00609.19 407.31L609.77 491.24A.99.99.0 00610.99 492.19L662.55 480A.99.99.0 00663.31 479.04L663.15 390.16"/><path stroke="#93b0c4" vector-effect="non-scaling-stroke" d="M610.01 645.38C610.01 646.98 610.77 648.42 612.26 649.06 620.63 652.63 629.2 654.01 637.6 656.47Q649.19 659.86 661.88 663.03 663.27 663.38 663.33 661.95 663.43 659.77 663.43 657.69 663.36 600.71 663.09 550.52A1.49 1.48 1.9 00661.71 549.05Q658.24 548.79 654.88 548.95 640.98 549.6 624.11 551.2 617.1 551.87 609.98 552.02A.46.45-1.3 00609.53 552.48Q609.94 600.04 610.01 645.38"/></g><path fill="#276089" d="M255.43 337.58A1.16 1.15-8 00256.16 336.62Q256.94 329.44 256.97 321.89 257.01 312.67 258.49 300.83 260.97 280.96 264.63 264.23 267.08 253.08 270.94 243.18C272.28 239.75 274.57 236.93 276.22 233.52 282.54 220.44 289.18 206.77 297.09 195.08c14.64-21.65 32.53-44.29 51-59.85Q358.75 126.26 377.98 112.74 386.74 106.58 396.21 101.52q32.66-17.44 64.71-24.98C478.3 72.45 497.66 69.39 516.24 68.95Q539.13 68.4 559.76 70.68 603.35 75.49 639 92.39c15.7 7.44 31.16 15.56 45.33 25.63C708.06 134.9 728.25 153.79 745.77 178.17q28.53 39.69 41.12 83.29C789.89 271.86 792.34 283.71 793.66 294.66Q796.2 315.76 797.41 337.48A1.29 1.29.0 00798.69 338.7Q815.49 338.72 831.21 339.39C868.91 341 905.17 359.29 933.64 383.01 939.46 387.86 944.72 394.3 949.76 400.34 970.1 424.7 985.53 454.74 991.58 486.07Q997.12 514.79 994.49 540.6 989.42 590.5 960.66 630.97 946.97 650.24 931.32 664.82 918.69 676.6 899.38 686.96 880.83 696.92 863.47 701.77 836.07 709.42 806.25 710.24 774.38 711.1 736.61 711.19A1.97 1.96 7.1 00734.72 712.66C734.18 714.76 733.61 717.01 733.65 719.2 733.84 728.71 732.87 743.34 721.34 746.39Q718.5 747.14 716.12 748.82 715.67 749.14 715.13 749.15 713.55 749.18 711.03 748.73C690.73 745.11 671.12 739.21 651.67 733.55 640.94 730.43 629.8 726.69 618.56 723.66Q594.7 717.23 575.34 712.41 569.8 711.03 554.9 710.73C535.85 710.34 517.09 709.97 498.26 710.05Q426.4 710.36 354.01 711.11C327.54 711.39 300.74 711.31 273.96 711.36Q244.61 711.41 219.84 708.3 208.25 706.84 188 700.75 172.03 695.95 155.79 686.75 144.05 680.09 137 674.83c-19.35-14.45-34.77-33.51-48.28-53.75C85.29 615.94 82.26 610.27 79.9 604.58 72.57 586.93 66.35 568.74 63.94 550.49 62.68 540.98 61.35 531.56 61.65 521.49q1.04-35.65 13.88-70.2Q79.3 441.12 83.46 433.44q17.03-31.42 43.33-53.64c21.23-17.94 45.35-29.63 72.03-36.95C216.78 337.93 234.03 338.04 253.26 337.98Q254.42 337.98 255.43 337.58zM438.8 120.98Q435.57 121.88 434.78 122.21 431.12 123.7 423.21 127.52C416.56 130.57 409.18 133.39 403.28 136.68Q394.42 141.62 387.66 147.15 379.83 153.54 367.83 164.27C360.8 170.55 354.15 177.8 347.45 184.72L342.5 189.88Q342.21 190.18 341.84 190.38 341.07 190.8 341.03 191.71 341.01 192.11 340.65 191.92 340.53 191.86 340.4 191.9 339.91 192.07 339.71 192.6 339.03 194.41 337.73 195.89 337.39 196.28 337.81 195.97 337.86 195.93 337.92 195.9 338.54 195.6 338.12 196.15 335.04 200.12 332.21 203.99 332.03 204.23 331.79 204.04L331.46 203.78Q331.41 203.74 331.44 203.69 332.29 202.33 333.12 201.24 333.2 201.13 333.11 201 333.07 200.95 333.03 201 332.05 202.53 330.7 203.79 330.54 203.94 330.75 203.87 330.79 203.85 330.84 203.87 331.05 203.97 331.06 204.2 331.13 205.63 329.99 206.5A1.85 1.78 81.9 00329.4 207.32Q329.06 208.29 328.39 209.14 328.09 209.52 327.61 209.58 325.89 209.82 326 211.78A1.3 1.27-28 01325.72 212.66Q324.07 214.8 323.12 217.7L318.02 228.46Q313.27 234.86 311.76 237.75 309.37 242.33 305.99 252.05 304.46 256.44 305.93 254.25 305.62 255.63 304.89 256.82 304.77 257.01 304.97 257.12L305.2 257.24Q305.23 257.26 305.24 257.22 306.13 255.05 307.26 252.78 307.34 252.62 307.51 252.71L307.73 252.82Q307.75 252.84 307.74 252.86 306.25 255.22 305.41 257.9 304.19 261.82 302.64 265.97 302.35 266.75 301.89 267.38C300.98 268.59 301.07 270.27 300.39 271.68Q299.06 274.47 298.36 277.53 298.26 277.97 297.92 278.28 297.32 278.84 297.16 279.76 296.53 283.42 295.29 287.79C294.38 290.99 294.69 294.16 293.83 297.36 292.99 300.5 293.12 303.75 292.59 306.9Q290.82 317.42 290.83 332.15C290.83 348.21 291.88 362.54 296.59 377.96Q298.48 384.15 300.49 390.37 301.18 392.52 299.65 390.86 298.11 389.19 295.54 387.72 290.29 384.72 285.05 381.84 283.43 380.56 281.9 380.1C279.89 379.5 278.26 378.64 276.39 378.23 274.28 377.77 271.98 376.83 270.21 376.37Q255.65 372.58 240.43 373.13 233.74 372.8 227 373.57 218.25 374.57 209.52 375.73 205.54 376.26 202.03 377.1 198.41 377.96 194.65 378.96 194.3 379.05 194.13 379.39A.74.72-79.5 01193.55 379.8Q189.92 380.15 187.2 381.49 184.73 382.71 182.18 383.81 179.39 385.01 177.01 386.52q-10.2 6.5-21.71 15.23-11.53 8.75-19.24 19.06C135.77 421.2 135.78 421.58 135.55 421.95Q132.47 426.87 128.69 431.08 125.96 434.1 123.91 437.19 121.72 440.47 119.57 443.8 119.26 444.28 119.09 444.83 118.95 445.24 118.63 445.53 116.84 447.17 116 449.6A1.7 1.69 80.4 01115.47 450.35Q115.1 450.66 114.87 451.08 111.96 456.46 110.57 460.85 109.15 465.35 107.7 469.25 104.74 477.22 102.44 485.43 102.33 485.83 102.71 485.65 103.01 485.5 102.86 485.13 102.81 485.01 102.88 485.11 102.9 485.13 102.93 485.15 102.99 485.16 102.97 485.22 101.22 490.96 100.5 495.31 98.77 505.78 98.79 517.39 98.79 517.88 98.5 518.29 98.25 518.63 98.23 519.04 97.87 528.44 98.18 537.77 98.75 547.92 100.1 554.97q3.73 19.49 13.1 38.62 15.56 31.76 43.03 52.74Q162.21 650.9 172.97 656.97 173.4 657.21 173.93 657.11 174.27 657.04 174.47 657.33 175.25 658.44 176.62 658.35 176.74 658.34 176.63 658.37 176.5 658.41 176.38 658.48 176.21 658.58 176.36 658.71 179.72 661.6 184.36 663.69 193.12 667.64 200.92 670.96 203.51 672.06 206.39 672.09C213.79 672.17 220.75 674.59 227.85 675.5Q241.51 677.25 258.42 677.27 335.37 677.38 410.89 677.26 415.61 677.25 421.31 677.06A.94.94.0 00422.22 676.12L422.48 603.46C422.72 519.97 422.5 436.49 422.59 353Q422.59 348.1 423.66 344.48C424.85 340.39 429.55 336.76 433.9 336.21Q436.66 335.85 439.49 335.86 494.27 335.98 572.06 335.69 584.93 335.64 589.91 334.78 597.94 333.4 606.26 330.74C615.95 327.65 626.03 324.05 635.5 320.14Q646.37 315.66 657.62 312.96 667.09 310.69 676.08 307.82 691.68 302.85 706.51 297.5 712.77 295.24 718.01 296.26 725.51 299 729.94 305.03 734.73 311.55 735.73 318.39 736.01 320.31 736.08 332.62 736.25 364.24 736.19 397 736.19 399.08 736.23 400.97 735.9 449.45 735.46 497.75 735.19 527.79 736.15 604.08L736.67 675.56A2.19 2.19.0 00738.87 677.73Q767.94 677.54 795.44 677.62 817.97 677.68 841.39 674.15 847.16 673.28 852.49 671.66C860.03 669.38 868.01 666.67 874.77 663.04 886.51 656.73 899.29 648.52 907.95 640.2Q915.92 632.55 923.63 625.37 929.31 620.09 933.33 613.73C935.19 610.8 937.51 608.42 939.12 605.35 940.33 603.02 941.92 600.89 943.21 598.54Q943.45 598.12 943.29 597.67L943.16 597.31A.83.81 57.5 01943.33 596.5Q944.29 595.46 944.39 593.99A1.71 1.69-26.2 01944.69 593.13Q945.61 591.77 945.97 590.12 946.3 588.59 946.91 587.17 949.11 582.1 951.27 576.84 951.72 575.76 951.83 574.56 951.94 573.38 952.44 572.26 953.13 570.7 953.66 569.03 955.4 563.55 956.49 558.44 958.79 547.6 959.78 535.62 961.35 516.61 958.61 497.75C957.77 492.01 956.07 486.17 954.92 480.43Q954.15 476.64 952.59 472.89 950.98 469.01 950.1 465.43 949.18 461.64 947.3 458.42C946.62 457.26 946.43 456.23 946.02 455.01Q945.59 453.76 944.8 452.54 943.11 449.92 941.65 447.11C941.28 446.4 941.38 445.57 941.14 445Q940.04 442.39 934.75 436.96c-13.04-17.58-27.99-33.32-46.72-44.66Q882.24 387.36 875.24 384.36 875.2 384.34 875.22 384.3L875.35 384.08Q875.43 383.93 875.59 384L877.96 385.14Q877.99 385.16 878 385.13L878.15 384.9Q878.28 384.7 878.05 384.62 872.13 382.5 867.06 380.02 863.08 378.07 858.83 376.66 854.27 375.14 850.01 374.21 849.95 374.2 849.93 374.26L849.87 374.51A.03.03.0 00849.9 374.55Q857.11 375.83 861.77 378.39 864.48 379.88 861.51 379.04 859.01 378.34 856.67 377.6 852.48 376.26 846.15 375.67 846.1 375.67 846.08 375.63 846.06 375.57 846.12 375.55 846.17 375.54 846.21 375.55 847.25 375.84 848.13 375.69 848.82 375.58 848.13 375.43 844.1 374.56 840.02 375.3C831.63 374.33 823.73 372.69 814.84 373.31 813.35 373.41 812.06 372.84 810.51 372.87Q803.01 373.01 796.27 374.55C793.63 375.15 790.95 375.45 788.28 375.61Q787.88 375.64 787.61 375.92 787.23 376.32 786.68 376.4 780.74 377.31 775.04 379.37 770.87 380.88 764.64 384.8 759.7 387.91 754.7 391.19 756.26 383.46 757.81 375.98 759.76 366.58 760.51 360.7 763.46 337.48 761.63 314.17 760.99 306.01 758.91 294.37 757.01 283.7 754.89 272.75 752.59 260.84 747.54 249.46 745.67 245.25 743.7 240.2 741.38 234.25 736.66 226.75C735.76 225.32 735.24 223.86 734.21 222.51Q733.24 221.24 732.62 219.78C731.88 218.02 730.63 216.88 729.84 215.09 728.87 212.88 727.16 211.39 726.04 209.26Q724.69 206.7 722.92 204.55 721.11 202.35 719.49 200.03C716.95 196.39 714.67 192.59 711.27 189.61Q707.54 186.33 704.82 182.42C701.84 178.13 697.85 175.09 694.54 171.01 691.17 166.84 686.76 163.44 682.74 159.88 681.82 159.06 681.72 157.86 680.73 157.06Q677.63 154.54 674.69 152.45A.07.06-54.1 00674.6 152.47L674.46 152.68Q674.33 152.89 674.54 153.03 676.02 153.98 677.32 155.07 677.52 155.24 677.29 155.11C674.74 153.75 672.51 152.11 670.69 149.82Q669.3 148.07 667.31 146.74 660.44 142.14 653.7 138.48 648.98 135.92 644.35 132.84 639.79 129.81 632.39 126.59 617.15 119.97 605.94 116.26C604.1 115.65 602.23 115.81 600.47 115.15Q599.76 114.79 599.28 114.25 596.64 112.8 593.69 111.95 583.64 109.04 573.39 106.9 563.66 104.88 556.72 105.12 535.59 102.85 519.25 103.18 496.98 103.62 471.85 109.31C463.27 111.26 455.62 114.24 447.42 117.07Q446.79 117.29 446.29 117.73 445.73 118.22 445.1 118.66 444.28 119.23 443.25 119.55 441.01 120.23 438.8 120.98zM572.05 680.95Q573.46 683.34 577.75 683.35 578.25 683.35 578.66 683.64 580.2 684.7 582 685.13 584.37 685.69 585.95 686.1 588.82 686.85 591.3 687.21C595.8 687.86 600.29 689.82 604.84 691.11Q618.05 694.87 630.86 698.4 635.66 699.73 651.25 702.9 652.68 703.19 654.31 703.37 655.83 703.54 657.52 704.26 660.29 705.43 664.46 705.55L700.51 716.23A.45.45.0 00701.07 715.67Q700.51 713.85 700.53 711.75 701.4 620.4 700.42 518.5 700.28 504.3 700.93 458.5 701.46 420.35 700.4 335.5 700.38 334.25 700.52 333.01A.89.88 85.1 00699.4 332.06Q679.62 337.71 665.91 342.7 641.72 351.5 619.65 358.49 592.44 367.1 572.6 374.15A1.9 1.89-9.9 00571.34 375.93Q571.18 513.33 571.39 654.5 571.41 667.76 572.05 680.95zM506.73 508.96Q507.23 508.97 507.24 509.47L507.61 567.73A1.71 1.71.0 00509.29 569.43L512.14 569.48Q513.67 569.51 513.68 567.99L514.06 509.31A.65.65.0 01514.72 508.66Q524.38 508.75 533.37 508.51 534.45 508.49 535.45 508.14 536.77 507.68 535.94 506.56 525.56 492.62 516.03 477.72 513.11 473.15 510.64 468.22A.71.71.0 00509.34 468.32Q508.89 469.68 508.14 470.81 499.59 483.62 490.59 498.33C488.69 501.42 486.13 503.98 484.7 507.4A.85.84-75.5 00485.38 508.57C492.34 509.35 499.77 508.84 506.73 508.96z"/><path fill="#fff" d="M556.72 105.12Q564.58 106.17 572.15 108.42C574.83 109.21 577.17 109.07 579.82 109.64Q580.27 109.74 580.44 110.18 580.67 110.82 581.38 110.86 584.36 111.04 587.12 112.11C589.32 112.96 591.64 112.98 593.93 113.32Q594.18 113.36 596.46 114.17 597.76 114.63 599.28 114.25 599.76 114.79 600.47 115.15 594.24 113.95 588.04 112.66 587.87 112.62 587.83 112.79 587.79 112.96 587.95 113.01 608.88 119.22 628.21 129.72C633.49 132.58 638.52 136.35 642.99 140.24q14.51 12.64 31.59 30.96Q681.7 178.84 686.51 185.46 692.99 194.41 696.62 201.36q10.9 20.91 18.41 47.15Q719.1 262.72 719.73 277.51 719.97 283.23 720.2 288.75 720.33 291.8 718.01 296.26 712.77 295.24 706.51 297.5 691.68 302.85 676.08 307.82 667.09 310.69 657.62 312.96 646.37 315.66 635.5 320.14C626.03 324.05 615.95 327.65 606.26 330.74Q597.94 333.4 589.91 334.78 584.93 335.64 572.06 335.69 494.27 335.98 439.49 335.86 436.66 335.85 433.9 336.21C429.55 336.76 424.85 340.39 423.66 344.48Q422.59 348.1 422.59 353C422.5 436.49 422.72 519.97 422.48 603.46L422.19 604.18Q421.98 604.7 421.43 604.61 416.66 603.86 412.59 603.87 348.88 604.09 284.71 603.84 267.13 603.77 251.02 602.46q-26.06-2.13-48.84-16.86C192.75 579.51 184.08 570.63 176.23 562.27 168.02 553.53 162.76 544.13 157.62 533.43Q155.23 528.46 153.32 520.84 150.92 511.24 149.17 502.91 148.38 499.18 148.32 495.49 148.17 486.3 148.6 475.52 148.73 472.34 149.5 469.45C150.03 467.49 149.69 465.7 150.07 463.83Q151.96 454.51 155.02 444.09 155.48 442.53 153.86 442.72 152.56 442.88 151.06 444.55 146.57 449.55 141.46 455.04 139.5 457.14 138.35 459.6C134.82 467.17 129.7 474.41 125.5 481.29Q121.17 488.38 116.92 498.43q-5.45 12.9-6.99 23.22C108.92 528.49 108.26 535.39 107.3 542.31Q107.23 542.83 106.78 543.08C101.52 546 99.61 542.27 98.18 537.77Q97.87 528.44 98.23 519.04 98.25 518.63 98.5 518.29 98.79 517.88 98.79 517.39 98.77 505.78 100.5 495.31 101.22 490.96 102.97 485.22 102.99 485.16 102.93 485.15 102.9 485.13 102.88 485.11 102.81 485.01 102.86 485.13 103.01 485.5 102.71 485.65 102.33 485.83 102.44 485.43 104.74 477.22 107.7 469.25 109.15 465.35 110.57 460.85 111.96 456.46 114.87 451.08 115.1 450.66 115.47 450.35A1.7 1.69 80.4 00116 449.6Q116.84 447.17 118.63 445.53 118.95 445.24 119.09 444.83 119.26 444.28 119.57 443.8 121.72 440.47 123.91 437.19 125.96 434.1 128.69 431.08 132.47 426.87 135.55 421.95C135.78 421.58 135.77 421.2 136.06 420.81Q143.77 410.5 155.3 401.75 166.81 393.02 177.01 386.52 179.39 385.01 182.18 383.81 184.73 382.71 187.2 381.49 189.92 380.15 193.55 379.8A.74.72-79.5 00194.13 379.39Q194.3 379.05 194.65 378.96 198.41 377.96 202.03 377.1 205.54 376.26 209.52 375.73 218.25 374.57 227 373.57 233.74 372.8 240.43 373.13 248.72 374.13 256.93 375.23C258.7 375.47 260.5 375.38 262.22 375.92Q264.38 376.6 266.46 376.63 268.9 376.67 270.74 377.14 278.05 378.99 285.05 381.84 290.29 384.72 295.54 387.72 298.11 389.19 299.65 390.86 301.18 392.52 300.49 390.37 298.48 384.15 296.59 377.96C291.88 362.54 290.83 348.21 290.83 332.15Q290.82 317.42 292.59 306.9C293.12 303.75 292.99 300.5 293.83 297.36 294.69 294.16 294.38 290.99 295.29 287.79Q296.53 283.42 297.16 279.76 297.32 278.84 297.92 278.28 298.26 277.97 298.36 277.53 299.06 274.47 300.39 271.68C301.07 270.27 300.98 268.59 301.89 267.38Q302.35 266.75 302.64 265.97 304.19 261.82 305.41 257.9 306.25 255.22 307.74 252.86 307.75 252.84 307.73 252.82L307.51 252.71Q307.34 252.62 307.26 252.78 306.13 255.05 305.24 257.22 305.23 257.26 305.2 257.24L304.97 257.12Q304.77 257.01 304.89 256.82 305.62 255.63 305.93 254.25l12.09-25.79L323.12 217.7 323.73 217.65Q324.29 217.6 324.32 217.04 324.34 216.71 324.56 216.47 325.2 215.76 324.74 216.59 324.56 216.9 324.39 217.19 324.34 217.28 324.42 217.33 324.53 217.4 324.61 217.5 324.73 217.67 324.8 217.48L327.22 210.74Q327.33 210.44 327.62 210.57L327.88 210.69Q327.9 210.7 327.87 210.75L326.51 213.47Q326.35 213.8 326.68 213.96L326.95 214.1A.12.12.0 00327.11 214.04Q328.64 210.79 330.13 208.73 334.34 202.94 338.25 196.98C340.99 192.8 344.46 188.91 347.45 184.72 354.15 177.8 360.8 170.55 367.83 164.27q12-10.73 19.83-17.12Q394.42 141.62 403.28 136.68C409.18 133.39 416.56 130.57 423.21 127.52l11.43-4.11Q434.84 123.34 434.69 123.5 434.59 123.61 434.43 123.71 433.68 124.17 434.55 124.09 434.86 124.06 435.14 123.85 436.98 122.44 438.8 120.98 441.01 120.23 443.25 119.55 444.28 119.23 445.1 118.66 445.73 118.22 446.29 117.73 446.79 117.29 447.42 117.07C455.62 114.24 463.27 111.26 471.85 109.31q25.13-5.69 47.4-6.13Q535.59 102.85 556.72 105.12zM323.4069 219.9496A.86.45 98.9 00323.9846 219.1696.86.45 98.9 00323.6731 218.2504.86.45 98.9 00323.0954 219.0304.86.45 98.9 00323.4069 219.9496z"/><path fill="#c4e6ff" d="M599.28 114.25Q597.76 114.63 596.46 114.17 594.18 113.36 593.93 113.32C591.64 112.98 589.32 112.96 587.12 112.11Q584.36 111.04 581.38 110.86 580.67 110.82 580.44 110.18 580.27 109.74 579.82 109.64C577.17 109.07 574.83 109.21 572.15 108.42Q564.58 106.17 556.72 105.12 563.66 104.88 573.39 106.9 583.64 109.04 593.69 111.95 596.64 112.8 599.28 114.25zm-36.41-8.61Q563.01 105.79 563.21 105.74 563.58 105.65 563.24 105.48 563.06 105.39 562.89 105.5A.09.09.0 00562.87 105.64z"/><path fill="#276089" d="M562.87 105.64A.09.09.0 01562.89 105.5Q563.06 105.39 563.24 105.48 563.58 105.65 563.21 105.74 563.01 105.79 562.87 105.64z"/><path fill="#c4e6ff" d="M600.47 115.15C602.23 115.81 604.1 115.65 605.94 116.26Q617.15 119.97 632.39 126.59 639.79 129.81 644.35 132.84 648.98 135.92 653.7 138.48 660.44 142.14 667.31 146.74 669.3 148.07 670.69 149.82C672.51 152.11 674.74 153.75 677.29 155.11Q677.52 155.24 677.32 155.07 676.02 153.98 674.54 153.03 674.33 152.89 674.46 152.68L674.6 152.47A.07.06-54.1 01674.69 152.45Q677.63 154.54 680.73 157.06C681.72 157.86 681.82 159.06 682.74 159.88 686.76 163.44 691.17 166.84 694.54 171.01 697.85 175.09 701.84 178.13 704.82 182.42Q707.54 186.33 711.27 189.61C714.67 192.59 716.95 196.39 719.49 200.03Q721.11 202.35 722.92 204.55 724.69 206.7 726.04 209.26C727.16 211.39 728.87 212.88 729.84 215.09 730.63 216.88 731.88 218.02 732.62 219.78Q733.24 221.24 734.21 222.51C735.24 223.86 735.76 225.32 736.66 226.75Q741.38 234.25 743.7 240.2 745.67 245.25 747.54 249.46 752.59 260.84 754.89 272.75 757.01 283.7 758.91 294.37 760.99 306.01 761.63 314.17 763.46 337.48 760.51 360.7 759.76 366.58 757.81 375.98 756.26 383.46 754.7 391.19 747.41 397.76 741.58 399.89 740.39 400.32 736.23 400.97 736.19 399.08 736.19 397 736.25 364.24 736.08 332.62 736.01 320.31 735.73 318.39 734.73 311.55 729.94 305.03 725.51 299 718.01 296.26 720.33 291.8 720.2 288.75 719.97 283.23 719.73 277.51 719.1 262.72 715.03 248.51 707.52 222.27 696.62 201.36 692.99 194.41 686.51 185.46 681.7 178.84 674.58 171.2q-17.08-18.32-31.59-30.96C638.52 136.35 633.49 132.58 628.21 129.72q-19.33-10.5-40.26-16.71Q587.79 112.96 587.83 112.79 587.87 112.62 588.04 112.66 594.24 113.95 600.47 115.15z"/><path fill="#c4e6ff" d="M438.8 120.98Q436.98 122.44 435.14 123.85 434.86 124.06 434.55 124.09 433.68 124.17 434.43 123.71 434.59 123.61 434.69 123.5 434.84 123.34 434.64 123.41l-11.43 4.11Q431.12 123.7 434.78 122.21 435.57 121.88 438.8 120.98z"/><path fill="#c4e6ff" d="M347.45 184.72C344.46 188.91 340.99 192.8 338.25 196.98Q334.34 202.94 330.13 208.73 328.64 210.79 327.11 214.04A.12.12.0 01326.95 214.1L326.68 213.96Q326.35 213.8 326.51 213.47L327.87 210.75Q327.9 210.7 327.88 210.69L327.62 210.57Q327.33 210.44 327.22 210.74L324.8 217.48Q324.73 217.67 324.61 217.5 324.53 217.4 324.42 217.33 324.34 217.28 324.39 217.19 324.56 216.9 324.74 216.59 325.2 215.76 324.56 216.47 324.34 216.71 324.32 217.04 324.29 217.6 323.73 217.65L323.12 217.7Q324.07 214.8 325.72 212.66A1.3 1.27-28 00326 211.78Q325.89 209.82 327.61 209.58 328.09 209.52 328.39 209.14 329.06 208.29 329.4 207.32A1.85 1.78 81.9 01329.99 206.5Q331.13 205.63 331.06 204.2 331.05 203.97 330.84 203.87 330.79 203.85 330.75 203.87 330.54 203.94 330.7 203.79 332.05 202.53 333.03 201 333.07 200.95 333.11 201 333.2 201.13 333.12 201.24 332.29 202.33 331.44 203.69 331.41 203.74 331.46 203.78L331.79 204.04Q332.03 204.23 332.21 203.99 335.04 200.12 338.12 196.15 338.54 195.6 337.92 195.9 337.86 195.93 337.81 195.97 337.39 196.28 337.73 195.89 339.03 194.41 339.71 192.6 339.91 192.07 340.4 191.9 340.53 191.86 340.65 191.92 341.01 192.11 341.03 191.71 341.07 190.8 341.84 190.38 342.21 190.18 342.5 189.88L347.45 184.72z"/><ellipse fill="#c4e6ff" cx="0" cy="0" transform="translate(323.54,219.10) rotate(98.9)" rx=".86" ry=".45"/><path fill="#c4e6ff" d="M305.93 254.25Q304.46 256.44 305.99 252.05 309.37 242.33 311.76 237.75 313.27 234.86 318.02 228.46l-12.09 25.79z"/><path fill="#fff" d="M664.46 705.55Q662.11 704.49 659.7 703.75 657.6 703.1 655.67 702.18 653.66 701.22 651.42 700.83C647.87 700.21 644.58 699.9 641.14 698.5Q637.25 696.91 633.31 695.66 624.29 692.77 614.98 690.12 607.98 688.12 599.95 686.55 588.3 684.27 584.74 683.66 576.99 682.31 572.05 680.95 571.41 667.76 571.39 654.5 571.18 513.33 571.34 375.93A1.9 1.89-9.9 01572.6 374.15Q592.44 367.1 619.65 358.49 641.72 351.5 665.91 342.7 679.62 337.71 699.4 332.06A.89.88 85.1 01700.52 333.01Q700.38 334.25 700.4 335.5 701.46 420.35 700.93 458.5 700.28 504.3 700.42 518.5 701.4 620.4 700.53 711.75 700.51 713.85 701.07 715.67A.45.45.0 01700.51 716.23L664.46 705.55zm14.76-333.02C679.23 371.09 679.54 369.88 679.85 368.51A.54.54.0 00679.29 367.85Q677.1 368.03 675.2 368.64 662.08 372.86 652.04 375.23 641.91 377.62 633.09 380.61 616.35 386.29 597.27 393.54C595.19 394.33 594.11 394.37 594.1 396.75Q593.82 453.73 594.23 510.63A.53.53.0 00594.87 511.14C612.16 507.54 629.52 503.71 647.2 500.59Q662.96 497.81 678.69 494.94 679.2 494.85 679.2 494.33 679.02 429.9 679.22 372.53zM679.1894 535.7817a14.73 13.11 84.9 0011.7487-15.8371 14.73 13.11 84.9 00-14.3675-13.5063 14.73 13.11 84.9 00-11.7487 15.8371 14.73 13.11 84.9 0014.3675 13.5063zM653.47 677.48C653.58 677.65 653.78 677.81 653.97 677.85Q666.29 680.76 678.03 684.83A.8.79-79.7 00679.09 684.09C679.65 637.75 679.02 593.21 679.12 547.6Q679.12 546.36 677.91 546.11 673.94 545.3 670.08 544.24C662.1 542.05 657.76 536.87 655.27 529.33A.58.57 76.9 00654.64 528.93Q625.29 532.84 594.78 537.76A.97.97.0 00593.96 538.72L594.14 660.05A1.82 1.81-79.8 00595.31 661.75Q600.8 663.83 606.74 665.66 624.02 670.98 642.31 674.66 645.11 675.22 647.69 676.02 650.42 676.85 653.38 677.42 653.44 677.43 653.47 677.48z"/><path fill="#276089" d="M679.22 372.53Q679.02 429.9 679.2 494.33 679.2 494.85 678.69 494.94 662.96 497.81 647.2 500.59C629.52 503.71 612.16 507.54 594.87 511.14A.53.53.0 01594.23 510.63Q593.82 453.73 594.1 396.75C594.11 394.37 595.19 394.33 597.27 393.54Q616.35 386.29 633.09 380.61 641.91 377.62 652.04 375.23 662.08 372.86 675.2 368.64 677.1 368.03 679.29 367.85A.54.54.0 01679.85 368.51C679.54 369.88 679.23 371.09 679.22 372.53zM663.15 390.16A.99.99.0 00661.85 389.22l-51.99 17.14A.99.99.0 00609.19 407.31L609.77 491.24A.99.99.0 00610.99 492.19L662.55 480A.99.99.0 00663.31 479.04L663.15 390.16z"/><path fill="#fff" d="M840.02 375.3Q848.37 376.89 856.74 378.43 858.39 378.73 859.67 379.4 861.35 380.28 862.67 380.11 863.04 380.06 862.71 380.22 862.58 380.28 862.61 380.45A.15.15.0 00862.73 380.57Q866.19 381.33 869.24 383.34 871.62 384.91 874.77 386.12 881.6 388.74 888.03 392.3C906.76 403.64 921.71 419.38 934.75 436.96Q933.36 439.7 931.62 440.82 930.42 441.59 929.18 440.89C920.72 436.1 912.25 432.32 903.95 427.51Q895.85 422.81 887.81 419.18A.49.49.0 00887.11 419.62Q887.09 420.94 887.79 422.07C891.49 428.02 895.07 433.53 898.27 440Q900.43 444.36 901.68 448 905.05 457.86 905.65 470.46 906.19 481.77 906.47 492.77 906.79 505.08 902.92 519.5C901.13 526.18 898.98 532.57 895.88 538.78Q889.94 550.64 883.64 559.19 875.85 569.75 866.31 577.47 846.68 593.35 821.44 600.21C811.7 602.85 801.87 603.19 791.75 603.52Q762.45 604.46 736.15 604.08 735.19 527.79 735.46 497.75 735.9 449.45 736.23 400.97 740.39 400.32 741.58 399.89 747.41 397.76 754.7 391.19 759.7 387.91 764.64 384.8 770.87 380.88 775.04 379.37 780.74 377.31 786.68 376.4 787.23 376.32 787.61 375.92 787.88 375.64 788.28 375.61C790.95 375.45 793.63 375.15 796.27 374.55Q803.01 373.01 810.51 372.87C812.06 372.84 813.35 373.41 814.84 373.31 823.73 372.69 831.63 374.33 840.02 375.3z"/><path fill="#c4e6ff" d="M285.05 381.84Q278.05 378.99 270.74 377.14 268.9 376.67 266.46 376.63 264.38 376.6 262.22 375.92C260.5 375.38 258.7 375.47 256.93 375.23Q248.72 374.13 240.43 373.13 255.65 372.58 270.21 376.37C271.98 376.83 274.28 377.77 276.39 378.23 278.26 378.64 279.89 379.5 281.9 380.1Q283.43 380.56 285.05 381.84z"/><path fill="#c4e6ff" d="M888.03 392.3Q881.6 388.74 874.77 386.12 871.62 384.91 869.24 383.34 866.19 381.33 862.73 380.57A.15.15.0 01862.61 380.45Q862.58 380.28 862.71 380.22 863.04 380.06 862.67 380.11 861.35 380.28 859.67 379.4 858.39 378.73 856.74 378.43 848.37 376.89 840.02 375.3 844.1 374.56 848.13 375.43 848.82 375.58 848.13 375.69 847.25 375.84 846.21 375.55 846.17 375.54 846.12 375.55 846.06 375.57 846.08 375.63 846.1 375.67 846.15 375.67 852.48 376.26 856.67 377.6 859.01 378.34 861.51 379.04 864.48 379.88 861.77 378.39 857.11 375.83 849.9 374.55A.03.03.0 01849.87 374.51L849.93 374.26Q849.95 374.2 850.01 374.21 854.27 375.14 858.83 376.66 863.08 378.07 867.06 380.02 872.13 382.5 878.05 384.62 878.28 384.7 878.15 384.9L878 385.13Q877.99 385.16 877.96 385.14L875.59 384Q875.43 383.93 875.35 384.08L875.22 384.3Q875.2 384.34 875.24 384.36q7 3 12.79 7.94z"/><path fill="#fff" d="M663.15 390.16 663.31 479.04A.99.99.0 01662.55 480L610.99 492.19A.99.99.0 01609.77 491.24L609.19 407.31A.99.99.0 01609.86 406.36l51.99-17.14A.99.99.0 01663.15 390.16z"/><path fill="#c4e6ff" d="M934.75 436.96Q940.04 442.39 941.14 445C941.38 445.57 941.28 446.4 941.65 447.11Q943.11 449.92 944.8 452.54 945.59 453.76 946.02 455.01C946.43 456.23 946.62 457.26 947.3 458.42Q949.18 461.64 950.1 465.43 950.98 469.01 952.59 472.89 954.15 476.64 954.92 480.43C956.07 486.17 957.77 492.01 958.61 497.75Q961.35 516.61 959.78 535.62 958.79 547.6 956.49 558.44 955.4 563.55 953.66 569.03 953.13 570.7 952.44 572.26 951.94 573.38 951.83 574.56 951.72 575.76 951.27 576.84 949.11 582.1 946.91 587.17 946.3 588.59 945.97 590.12 945.61 591.77 944.69 593.13A1.71 1.69-26.2 00944.39 593.99Q944.29 595.46 943.33 596.5A.83.81 57.5 00943.16 597.31L943.29 597.67Q943.45 598.12 943.21 598.54C941.92 600.89 940.33 603.02 939.12 605.35 937.51 608.42 935.19 610.8 933.33 613.73Q929.31 620.09 923.63 625.37 915.92 632.55 907.95 640.2C899.29 648.52 886.51 656.73 874.77 663.04 868.01 666.67 860.03 669.38 852.49 671.66Q847.16 673.28 841.39 674.15 817.97 677.68 795.44 677.62 767.94 677.54 738.87 677.73A2.19 2.19.0 01736.67 675.56L736.15 604.08Q762.45 604.46 791.75 603.52C801.87 603.19 811.7 602.85 821.44 600.21Q846.68 593.35 866.31 577.47 875.85 569.75 883.64 559.19 889.94 550.64 895.88 538.78C898.98 532.57 901.13 526.18 902.92 519.5Q906.79 505.08 906.47 492.77 906.19 481.77 905.65 470.46 905.05 457.86 901.68 448 900.43 444.36 898.27 440C895.07 433.53 891.49 428.02 887.79 422.07Q887.09 420.94 887.11 419.62A.49.49.0 01887.81 419.18Q895.85 422.81 903.95 427.51C912.25 432.32 920.72 436.1 929.18 440.89Q930.42 441.59 931.62 440.82 933.36 439.7 934.75 436.96z"/><path fill="#c4e6ff" d="M422.48 603.46 422.22 676.12A.94.94.0 01421.31 677.06Q415.61 677.25 410.89 677.26 335.37 677.38 258.42 677.27 241.51 677.25 227.85 675.5C220.75 674.59 213.79 672.17 206.39 672.09Q203.51 672.06 200.92 670.96 193.12 667.64 184.36 663.69 179.72 661.6 176.36 658.71 176.21 658.58 176.38 658.48 176.5 658.41 176.63 658.37 176.74 658.34 176.62 658.35 175.25 658.44 174.47 657.33 174.27 657.04 173.93 657.11 173.4 657.21 172.97 656.97 162.21 650.9 156.23 646.33q-27.47-20.98-43.03-52.74Q103.83 574.46 100.1 554.97 98.75 547.92 98.18 537.77C99.61 542.27 101.52 546 106.78 543.08Q107.23 542.83 107.3 542.31C108.26 535.39 108.92 528.49 109.93 521.65Q111.47 511.33 116.92 498.43q4.25-10.05 8.58-17.14C129.7 474.41 134.82 467.17 138.35 459.6Q139.5 457.14 141.46 455.04 146.57 449.55 151.06 444.55 152.56 442.88 153.86 442.72 155.48 442.53 155.02 444.09 151.96 454.51 150.07 463.83C149.69 465.7 150.03 467.49 149.5 469.45Q148.73 472.34 148.6 475.52 148.17 486.3 148.32 495.49 148.38 499.18 149.17 502.91 150.92 511.24 153.32 520.84 155.23 528.46 157.62 533.43C162.76 544.13 168.02 553.53 176.23 562.27 184.08 570.63 192.75 579.51 202.18 585.6q22.78 14.73 48.84 16.86Q267.13 603.77 284.71 603.84 348.88 604.09 412.59 603.87 416.66 603.86 421.43 604.61 421.98 604.7 422.19 604.18L422.48 603.46z"/><path fill="#fff" d="M506.73 508.96C499.77 508.84 492.34 509.35 485.38 508.57A.85.84-75.5 01484.7 507.4C486.13 503.98 488.69 501.42 490.59 498.33q9-14.71 17.55-27.52Q508.89 469.68 509.34 468.32A.71.71.0 01510.64 468.22Q513.11 473.15 516.03 477.72 525.56 492.62 535.94 506.56 536.77 507.68 535.45 508.14 534.45 508.49 533.37 508.51 524.38 508.75 514.72 508.66A.65.65.0 00514.06 509.31L513.68 567.99Q513.67 569.51 512.14 569.48L509.29 569.43A1.71 1.71.0 01507.61 567.73L507.24 509.47Q507.23 508.97 506.73 508.96z"/><ellipse fill="#276089" cx="0" cy="0" transform="translate(677.88,521.11) rotate(84.9)" rx="14.73" ry="13.11"/><path fill="#276089" d="M653.38 677.42Q650.42 676.85 647.69 676.02 645.11 675.22 642.31 674.66 624.02 670.98 606.74 665.66 600.8 663.83 595.31 661.75A1.82 1.81-79.8 01594.14 660.05L593.96 538.72A.97.97.0 01594.78 537.76Q625.29 532.84 654.64 528.93A.58.57 76.9 01655.27 529.33C657.76 536.87 662.1 542.05 670.08 544.24Q673.94 545.3 677.91 546.11 679.12 546.36 679.12 547.6C679.02 593.21 679.65 637.75 679.09 684.09A.8.79-79.7 01678.03 684.83Q666.29 680.76 653.97 677.85C653.78 677.81 653.58 677.65 653.47 677.48Q653.44 677.43 653.38 677.42zm-43.37-32.04C610.01 646.98 610.77 648.42 612.26 649.06 620.63 652.63 629.2 654.01 637.6 656.47Q649.19 659.86 661.88 663.03 663.27 663.38 663.33 661.95 663.43 659.77 663.43 657.69 663.36 600.71 663.09 550.52A1.49 1.48 1.9 00661.71 549.05Q658.24 548.79 654.88 548.95 640.98 549.6 624.11 551.2 617.1 551.87 609.98 552.02A.46.45-1.3 00609.53 552.48Q609.94 600.04 610.01 645.38z"/><path fill="#fff" d="M612.26 649.06C610.77 648.42 610.01 646.98 610.01 645.38Q609.94 600.04 609.53 552.48A.46.45-1.3 01609.98 552.02Q617.1 551.87 624.11 551.2 640.98 549.6 654.88 548.95 658.24 548.79 661.71 549.05A1.49 1.48 1.9 01663.09 550.52Q663.36 600.71 663.43 657.69 663.43 659.77 663.33 661.95 663.27 663.38 661.88 663.03 649.19 659.86 637.6 656.47C629.2 654.01 620.63 652.63 612.26 649.06z"/><path fill="#c4e6ff" d="M664.46 705.55Q660.29 705.43 657.52 704.26 655.83 703.54 654.31 703.37 652.68 703.19 651.25 702.9 635.66 699.73 630.86 698.4 618.05 694.87 604.84 691.11C600.29 689.82 595.8 687.86 591.3 687.21Q588.82 686.85 585.95 686.1 584.37 685.69 582 685.13 580.2 684.7 578.66 683.64 578.25 683.35 577.75 683.35 573.46 683.34 572.05 680.95 576.99 682.31 584.74 683.66 588.3 684.27 599.95 686.55 607.98 688.12 614.98 690.12 624.29 692.77 633.31 695.66 637.25 696.91 641.14 698.5C644.58 699.9 647.87 700.21 651.42 700.83Q653.66 701.22 655.67 702.18 657.6 703.1 659.7 703.75 662.11 704.49 664.46 705.55z"/></svg></span><span class=navbar-brand__name>Apache OpenServerless™</span></a><div class="td-navbar-nav-scroll ms-md-auto" id=main_navbar><ul class=navbar-nav><li class=nav-item><a class=nav-link href=/about/><span>About</span></a></li><li class=nav-item><a class=nav-link href=/blog/><span>Blog</span></a></li><li class=nav-item><a class="nav-link active" href=/docs/><span>Docs</span></a></li><li class=nav-item><a class=nav-link href=/community/><span>Community</span></a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" role=button data-bs-toggle=dropdown aria-haspopup=true aria-expanded=false href><span>Apache Software Foundation</span></a><ul class=dropdown-menu><li><a class=dropdown-item href=https://www.apache.org/>Apache Homepage</a></li><li><a class=dropdown-item href=https://www.apache.org/licenses/>License</a></li><li><a class=dropdown-item href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a></li><li><a class=dropdown-item href=https://www.apache.org/foundation/thanks.html>Thanks</a></li><li><a class=dropdown-item href=https://www.apache.org/security/>Security</a></li><li><a class=dropdown-item href=https://privacy.apache.org/policies/privacy-policy-public.html>Privacy</a></li><li><a class=dropdown-item href=https://www.apache.org/events/current-event>Events</a></li></ul></li></ul></div></div></nav></header><div class="container-fluid td-outer"><div class=td-main><div class="row flex-xl-nowrap"><main class="col-12 col-md-9 col-xl-8 ps-md-5" role=main><div class=td-content><div class="pageinfo pageinfo-primary d-print-none"><p>This is the multi-page printable view of this section. |
| <a href=# onclick="return print(),!1">Click here to print</a>.</p><p><a href=/docs/reference/runtimes/nodejs/>Return to the regular view of this page</a>.</p></div><h1 class=title>NodeJS</h1><ul><li>1: <a href=#pg-fdecfd86ec6b5e3e00c712af11901812>nodejs:v18</a></li><ul></ul><li>2: <a href=#pg-bc1423321f87745f6a281e9fba6d9300>nodejs:v20</a></li><ul></ul><li>3: <a href=#pg-63523ff3a1f21def755694971e193a9e>nodejs:v21</a></li><ul></ul></ul><div class=content><h2 id=creating-and-invoking-javascript-actions>Creating and invoking JavaScript actions</h2><p>The process of creating JavaScript actions is similar to that of other actions. |
| The following sections guide you through creating and invoking a single JavaScript action, |
| and demonstrate how to bundle multiple JavaScript files and third party dependencies.</p><ol><li>Create a package <code>directory</code>. Create a JavaScript file with the following content inside our <code>packages/nodejs</code>. For this example, the file name is <code>hello.js</code>.</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#8f5902;font-style:italic>//--web true |
| </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>//--kind nodejs:default |
| </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#204a87;font-weight:700>function</span> <span style=color:#000>main</span><span style=color:#000;font-weight:700>()</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>return</span> <span style=color:#000;font-weight:700>{</span> <span style=color:#000>msg</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>'Hello world'</span> <span style=color:#000;font-weight:700>};</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><p>The JavaScript file might contain additional functions. |
| However, by convention, a function called <code>main</code> must exist to provide the entry point for the action.</p><p>You directory structure should looks like this:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell><span style=display:flex><span>nodejs_app |
| </span></span><span style=display:flex><span>└── packages |
| </span></span><span style=display:flex><span> └── nodejs |
| </span></span><span style=display:flex><span> └── hello.js |
| </span></span></code></pre></div><ol start=2><li>Create an action from the following JavaScript function. For this example, the action is called <code>hello</code>.</li></ol><pre tabindex=0><code>/home/openserverless/.ops/tmp/deploy.pid |
| PID 278075 |
| > Scan: |
| >> Action: packages/nodejs/hello.js |
| > Deploying: |
| >> Package: nodejs |
| $ $OPS package update nodejs |
| ok: updated package nodejs |
| >>> Action: packages/nodejs/hello.js |
| $ $OPS action update nodejs/hello packages/nodejs/hello.js --web true --kind nodejs:default |
| ok: updated action nodejs/hello |
| build process exited with code 0 |
| UPLOAD ASSETS FROM web |
| ==================| UPLOAD RESULTS |================== |
| | FILES : 0 |
| | COMPLETED : 0 |
| | ERRORS : 0 |
| | SKIPPED : 0 |
| | EXEC. TIME : 2.37 ms |
| ====================================================== |
| URL: http://opstutorial.localhost:80 |
| </code></pre><p>Note: To use a specific version of NodeJs runtime, change the kind property <code>--kind nodejs:18</code>, or <code>--kind nodejs:20</code> in the <code>hello.js</code> file.</p><h2 id=creating-asynchronous-actions>Creating asynchronous actions</h2><p>JavaScript functions that run asynchronously may need to return the activation result after the <code>main</code> function has returned. You can accomplish this by returning a Promise in your action.</p><ol><li>Save the following content in a file called <code>asyncAction.js</code> inside the folder <code>packages/nodejs</code>.</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#8f5902;font-style:italic>//--web true |
| </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>//--kind nodejs:default |
| </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#204a87;font-weight:700>function</span> <span style=color:#000>main</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>args</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>return</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#204a87>Promise</span><span style=color:#000;font-weight:700>(</span><span style=color:#204a87;font-weight:700>function</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>resolve</span><span style=color:#000;font-weight:700>,</span> <span style=color:#000>reject</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>setTimeout</span><span style=color:#000;font-weight:700>(</span><span style=color:#204a87;font-weight:700>function</span><span style=color:#000;font-weight:700>()</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>resolve</span><span style=color:#000;font-weight:700>({</span> <span style=color:#000>done</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>true</span> <span style=color:#000;font-weight:700>});</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span> <span style=color:#0000cf;font-weight:700>2000</span><span style=color:#000;font-weight:700>);</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>})</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><p>Notice that the <code>main</code> function returns a Promise, which indicates that the activation hasn’t completed yet, but is expected to in the future.</p><p>The <code>setTimeout()</code> JavaScript function in this case waits for two seconds before calling the callback function. This represents the asynchronous code and goes inside the Promise’s callback function.</p><p>The Promise’s callback takes two arguments, resolve and reject, which are both functions. The call to <code>resolve()</code> fulfills the Promise and indicates that the activation has completed normally.</p><p>A call to <code>reject()</code> can be used to reject the Promise and signal that the activation has completed abnormally.</p><ol start=2><li>Run the following commands to create the action and invoke it:</li></ol><pre tabindex=0><code>ops ide deploy |
| </code></pre><pre tabindex=0><code>ops action invoke nodejs/asyncAction --result |
| </code></pre><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"done"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>true</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><p>Notice that you performed a blocking invocation of an asynchronous action.</p><ol start=3><li>Fetch the activation log to see how long the activation took to complete:</li></ol><pre tabindex=0><code>ops activation list --limit 1 nodejs/asyncAction |
| </code></pre><pre> |
| Datetime Activation ID Kind Start Duration Status Entity |
| 2024-03-27 19:46:43 64581426b44e4b3d981426b44e3b3d19 nodejs:21 cold 2.033s success openserverless/asyncAction:0.0.1 |
| </pre><pre tabindex=0><code>ops activation get 64581426b44e4b3d981426b44e3b3d19 |
| </code></pre><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#a40000>...</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"start"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>1743101268649</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"end"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>1743101270964</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#a40000>...</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><p>Comparing the <code>start</code> and <code>end</code> time stamps in the activation record, you can see that this activation took slightly over two seconds to complete.</p><h2 id=using-actions-to-call-an-external-api>Using actions to call an external API</h2><p>The examples so far have been self-contained JavaScript functions. You can also create an action that calls an external API.</p><p>This example invokes a Yahoo Weather service to get the current conditions at a specific location.</p><ol><li>Save the following content in a file called <code>weather.js</code>.</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>fetch</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>require</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>'node-fetch'</span><span style=color:#000;font-weight:700>)</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>getWeatherForecast</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>async</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>latitude</span><span style=color:#000;font-weight:700>,</span> <span style=color:#000>longitude</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>=></span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>url</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#4e9a06>`https://api.open-meteo.com/v1/forecast?latitude=</span><span style=color:#4e9a06>${</span><span style=color:#000>latitude</span><span style=color:#4e9a06>}</span><span style=color:#4e9a06>&longitude=</span><span style=color:#4e9a06>${</span><span style=color:#000>longitude</span><span style=color:#4e9a06>}</span><span style=color:#4e9a06>&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m`</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>try</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>response</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>await</span> <span style=color:#000>fetch</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>url</span><span style=color:#000;font-weight:700>)</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>if</span> <span style=color:#000;font-weight:700>(</span><span style=color:#ce5c00;font-weight:700>!</span><span style=color:#000>response</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>ok</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>throw</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#204a87>Error</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>'Error during the request'</span><span style=color:#000;font-weight:700>)</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>data</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>await</span> <span style=color:#000>response</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>json</span><span style=color:#000;font-weight:700>()</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>return</span> <span style=color:#000>data</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span> <span style=color:#204a87;font-weight:700>catch</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>error</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>console</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>error</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>'Error:'</span><span style=color:#000;font-weight:700>,</span> <span style=color:#000>error</span><span style=color:#000;font-weight:700>)</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>return</span> <span style=color:#000>JSON</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>Stringify</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>error</span><span style=color:#000;font-weight:700>)</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>};</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>function</span> <span style=color:#000>main</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>args</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000;font-weight:700>{</span><span style=color:#000>latitude</span><span style=color:#000;font-weight:700>,</span> <span style=color:#000>longitude</span><span style=color:#000;font-weight:700>}</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>args</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>return</span> <span style=color:#204a87;font-weight:700>await</span> <span style=color:#000>getWeatherForecast</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>latitude</span><span style=color:#000;font-weight:700>,</span> <span style=color:#000>longitude</span><span style=color:#000;font-weight:700>)</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><p>Note that the action in the example uses a Node.js library to fetch forecast data. However, you can use a library available in runtime dependencies or you can add a package.json file and specify the action’s dependencies.</p><p>Check a specific version of the Node.js runtime for packages available in the runtime environment.</p><p>This example also shows the need for asynchronous actions. The action returns uses ‘async/await’ to fetch the data from another system. When the action is completed, the action will return the values from the other sistem.</p><ol start=2><li>Create an action from the <code>weather.js</code> file:</li></ol><pre tabindex=0><code>ops ide deploy |
| </code></pre><ol start=3><li>Use the following command to run the action, and observe the output:</li></ol><pre tabindex=0><code>ops action invoke nodejs/weather --param latitude "51.509865" --param longitude "-0.118092" --result |
| </code></pre><p>Using the <code>--result</code> flag means that the value returned from the action is shown as output on the command-line:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"elevation"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>21</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"generationtime_ms"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>0.03039836883544922</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"hourly"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"temperature_2m"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span> |
| </span></span><span style=display:flex><span> <span style=color:#0000cf;font-weight:700>12.8</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#0000cf;font-weight:700>12.9</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#a40000>...</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"time"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span> |
| </span></span><span style=display:flex><span> <span style=color:#4e9a06>"2025-03-27T00:00"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#4e9a06>"2025-03-27T01:00"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#a40000>...</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"hourly_units"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"temperature_2m"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"°C"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"time"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"iso8601"</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"latitude"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>51.5</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"longitude"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>-0.120000124</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"timezone"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"GMT"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"timezone_abbreviation"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"GMT"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"utc_offset_seconds"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>0</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><p>This example also passed a parameter to the action by using the <code>--param</code> flag and a value that can be changed each time the action is invoked.</p><h2 id=packaging-actions-as-nodejs-modules-with-npm-libraries>Packaging actions as Node.js modules with NPM libraries</h2><p>Instead of writing all your action code in a single JavaScript source file, actions can be deployed from a zip file containing a <a href=https://nodejs.org/docs/latest-v10.x/api/modules.html#modules_modules>Node.js module</a>.</p><p>Archive zip files are extracted into the runtime environment and dynamically imported using <code>require()</code> during initialisation. <strong>Actions packaged as a zip file MUST contain a valid <code>package.json</code> with a <code>main</code> field used to denote the <a href=https://nodejs.org/docs/latest-v10.x/api/modules.html#modules_folders_as_modules>module index file</a> to return.</strong></p><p><code>ops ide deploy</code> will include automatically <code>node_modules</code> folder in a zip file means external NPM libraries can be used on the platform.</p><p>Note: remember that each runtime has a set of dependecies already installed. if it’s possible use this set of libraries. It’s better to don’t load too much external libraries because it will deteriorate the action’s performance</p><h3 id=simple-example>Simple Example</h3><ul><li><p>Create a folder called <code>packageAction</code> inside packages/nodejs folder</p></li><li><p>Create the following <code>package.json</code> file:</p></li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"name"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"my-action"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"main"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"index.js"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"dependencies"</span> <span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"left-pad"</span> <span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"1.1.3"</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><ul><li>Create the following <code>index.js</code> file:</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#8f5902;font-style:italic>//--web true |
| </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>//--kind nodejs:default |
| </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>leftPad</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>require</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>"left-pad"</span><span style=color:#000;font-weight:700>)</span> |
| </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>function</span> <span style=color:#000>main</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>args</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>lines</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>args</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>lines</span> <span style=color:#ce5c00;font-weight:700>||</span> <span style=color:#000;font-weight:700>[];</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>return</span> <span style=color:#000;font-weight:700>{</span> <span style=color:#000>padded</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#000>lines</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>map</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>l</span> <span style=color:#000;font-weight:700>=></span> <span style=color:#000>leftPad</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>l</span><span style=color:#000;font-weight:700>,</span> <span style=color:#0000cf;font-weight:700>30</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>"."</span><span style=color:#000;font-weight:700>))</span> <span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><ul><li><p>Now you should have this folder structure:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell><span style=display:flex><span>nodejs_app |
| </span></span><span style=display:flex><span>└── packages |
| </span></span><span style=display:flex><span> └── nodejs |
| </span></span><span style=display:flex><span> └── packageAction |
| </span></span><span style=display:flex><span> ├── hello.js |
| </span></span><span style=display:flex><span> └── package.json |
| </span></span></code></pre></div></li><li><p>Create the action</p></li></ul><pre tabindex=0><code>ops ide deploy |
| </code></pre><p>When creating an action from a folder, <code>ops ide deploy</code> will create automatically the following artifacts:</p><ul><li>node_modules</li><li>package-lock.json</li><li><foldername>.zip</li></ul><p>the zip fill is used by <code>ops</code> to create/update the function in your ops environment</p><ul><li>Invoke the action as normal.</li></ul><pre tabindex=0><code>ops action invoke nodejs/packageAction --param lines "[\"and now\", \"for something completely\", \"different\" ]" --result |
| </code></pre><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"padded"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span> |
| </span></span><span style=display:flex><span> <span style=color:#4e9a06>".......................and now"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#4e9a06>"......for something completely"</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#4e9a06>".....................different"</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span></code></pre></div><h2 id=using-javascript-bundlers-to-package-action-source-files>Using JavaScript Bundlers to package action source files</h2><p>Using a JavaScript module bundler can transform application source files (with external dependencies) into a single compressed JavaScript file. This can lead to faster deployments, lower cold-starts and allow you to deploy large applications where individual sources files in a zip archive are larger than the action size limit.</p><p>Here are the instructions for how to use three popular module bundlers with the Node.js runtime. The “left pad” action example will be used as the source file for bundling along with the external library.</p><h3 id=using-rollupjs>Using rollup.js</h3><p>In this example we will use <a href=https://rollupjs.org>rollupjs</a> to deliver the action</p><ul><li>Create rollupAction folder inside packages/nodejs. Then re-write the <code>index.js</code> to use ES6 Modules, rather than CommonJS module format. |
| Create the <code>package.json</code> and copy the content from the previous example</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>leftPad</span> <span style=color:#000>from</span> <span style=color:#4e9a06>'left-pad'</span><span style=color:#000;font-weight:700>;</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>function</span> <span style=color:#000>myAction</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>args</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>lines</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>args</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>lines</span> <span style=color:#ce5c00;font-weight:700>||</span> <span style=color:#000;font-weight:700>[];</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>return</span> <span style=color:#000;font-weight:700>{</span> <span style=color:#000>padded</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#000>lines</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>map</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>l</span> <span style=color:#000;font-weight:700>=></span> <span style=color:#000>leftPad</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>l</span><span style=color:#000;font-weight:700>,</span> <span style=color:#0000cf;font-weight:700>30</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>"."</span><span style=color:#000;font-weight:700>))</span> <span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>export</span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>main</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>myAction</span> |
| </span></span></code></pre></div><p><em>Make sure you export the function using the <code>const main = ...</code> pattern. Using <code>export {myAction as main}</code> does not work due to tree-shaking. See this <a href=https://boneskull.com/rollup-for-javascript-actions-on-openwhisk/>blog post</a> for full details on why this is necessary.</em></p><ul><li>Create the Rollup.js configuration file in <code>rollup.config.js</code> with the following contents.</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>commonjs</span> <span style=color:#000>from</span> <span style=color:#4e9a06>'rollup-plugin-commonjs'</span><span style=color:#000;font-weight:700>;</span> |
| </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>resolve</span> <span style=color:#000>from</span> <span style=color:#4e9a06>'rollup-plugin-node-resolve'</span><span style=color:#000;font-weight:700>;</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>export</span> <span style=color:#204a87;font-weight:700>default</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>input</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>'index.js'</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>output</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>file</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>'bundle.js'</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>format</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>'cjs'</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>plugins</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>resolve</span><span style=color:#000;font-weight:700>(),</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>commonjs</span><span style=color:#000;font-weight:700>()</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>};</span> |
| </span></span></code></pre></div><p>Note: run the following command inside the rollupAction folder</p><ul><li>Install the Rollup.js library and plugins using NPM.</li></ul><pre tabindex=0><code>npm install rollup rollup-plugin-commonjs rollup-plugin-node-resolve --save-dev |
| </code></pre><ul><li>Run the Rollup.js tool using the configuration file.</li></ul><pre tabindex=0><code>npx rollup --config |
| </code></pre><ul><li>Create an action using the bundle source file.</li></ul><pre tabindex=0><code>ops action create nodejs/rollupAction bundle.js --kind nodejs:20 |
| </code></pre><ul><li>Invoke the action as normal. Results should be the same as the example above.</li></ul><pre tabindex=0><code>ops action invoke nodejs/rollupAction --result --param lines "[\"and now\", \"for something completely\", \"different\" ]" |
| </code></pre><h3 id=using-webpack>Using webpack</h3><p>In this example we will use <a href=https://webpack.js.org/>webpack</a> to deliver the action</p><ul><li>Create webpackAction folder inside packages/nodejs. Then re-write the <code>index.js</code> to export the <code>main</code> function using as a global reference. |
| Then, create the <code>package.json</code> and copy the content from the previous example</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>leftPad</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>require</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>'left-pad'</span><span style=color:#000;font-weight:700>);</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>function</span> <span style=color:#000>myAction</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>args</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>lines</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>args</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>lines</span> <span style=color:#ce5c00;font-weight:700>||</span> <span style=color:#000;font-weight:700>[];</span> |
| </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>return</span> <span style=color:#000;font-weight:700>{</span> <span style=color:#000>padded</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#000>lines</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>map</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>l</span> <span style=color:#000;font-weight:700>=></span> <span style=color:#000>leftPad</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>l</span><span style=color:#000;font-weight:700>,</span> <span style=color:#0000cf;font-weight:700>30</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>"."</span><span style=color:#000;font-weight:700>))</span> <span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span> |
| </span></span><span style=display:flex><span><span style=color:#000>global</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>main</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>myAction</span> |
| </span></span></code></pre></div><p>This allows the bundle source to “break out” of the closures Webpack uses when defining the modules.</p><ul><li>Create the Webpack configuration file in <code>webpack.config.js</code> with the following contents.</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#000>module</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>exports</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>entry</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>'./index.js'</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>target</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>'node'</span><span style=color:#000;font-weight:700>,</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>output</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span> |
| </span></span><span style=display:flex><span> <span style=color:#000>filename</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>'bundle.js'</span> |
| </span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span> |
| </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>};</span> |
| </span></span></code></pre></div><ul><li>Install the Webpack library and CLI using NPM.</li></ul><pre tabindex=0><code>npm install webpack-cli --save-dev |
| </code></pre><ul><li>Run the Webpack tool using the configuration file.</li></ul><pre tabindex=0><code>npx webpack --config webpack.config.js |
| </code></pre><ul><li>Create an action using the bundle source file.</li></ul><pre tabindex=0><code>ops action create nodejs/webpackAction dist/bundle.js --kind nodejs:21 |
| </code></pre><ul><li>Invoke the action as normal. Results should be the same as the example above.</li></ul><pre tabindex=0><code>ops action invoke nodejs/webpackAction --result --param lines "[\"and now\", \"for something completely\", \"different\" ]" |
| </code></pre></div></div><div class=td-content style=page-break-before:always><h1 id=pg-fdecfd86ec6b5e3e00c712af11901812>1 - nodejs:v18</h1><h2 id=nodejsv18-default-false>nodejs:v18 (default: false)</h2><table><thead><tr><th>Library</th><th>Version</th><th>Link</th></tr></thead><tbody><tr><td>@azure/openai</td><td>^1.0.0-beta.11</td><td><a href=https://npmjs.com/package/v/1.0.0-beta.11>npm</a></td></tr><tr><td>@langchain/community</td><td>^0.0.34</td><td><a href=https://npmjs.com/package/v/0.0.34>npm</a></td></tr><tr><td>minio</td><td>^7.1.3</td><td><a href=https://npmjs.com/package/v/7.1.3>npm</a></td></tr><tr><td>mongodb</td><td>^6.4.0</td><td><a href=https://npmjs.com/package/v/6.4.0>npm</a></td></tr><tr><td>node-auth0</td><td>^1.0.0</td><td><a href=https://npmjs.com/package/v/1.0.0>npm</a></td></tr><tr><td>ollama</td><td>^0.5.0</td><td><a href=https://npmjs.com/package/v/0.5.0>npm</a></td></tr><tr><td>openai</td><td>^4.28.4</td><td><a href=https://npmjs.com/package/v/4.28.4>npm</a></td></tr><tr><td>openwhisk</td><td>^3.21.8</td><td><a href=https://npmjs.com/package/v/3.21.8>npm</a></td></tr><tr><td>pg</td><td>^8.11.3</td><td><a href=https://npmjs.com/package/v/8.11.3>npm</a></td></tr><tr><td>plotly</td><td>^1.0.6</td><td><a href=https://npmjs.com/package/v/1.0.6>npm</a></td></tr><tr><td>redis</td><td>^4.6.13</td><td><a href=https://npmjs.com/package/v/4.6.13>npm</a></td></tr><tr><td>uuid</td><td>^9.0.1</td><td><a href=https://npmjs.com/package/v/9.0.1>npm</a></td></tr></tbody></table></div><div class=td-content style=page-break-before:always><h1 id=pg-bc1423321f87745f6a281e9fba6d9300>2 - nodejs:v20</h1><h2 id=nodejsv20-default-false>nodejs:v20 (default: false)</h2><table><thead><tr><th>Library</th><th>Version</th><th>Link</th></tr></thead><tbody><tr><td>@azure/openai</td><td>^1.0.0-beta.11</td><td><a href=https://npmjs.com/package/v/1.0.0-beta.11>npm</a></td></tr><tr><td>@langchain/community</td><td>^0.0.34</td><td><a href=https://npmjs.com/package/v/0.0.34>npm</a></td></tr><tr><td>minio</td><td>^7.1.3</td><td><a href=https://npmjs.com/package/v/7.1.3>npm</a></td></tr><tr><td>mongodb</td><td>^6.4.0</td><td><a href=https://npmjs.com/package/v/6.4.0>npm</a></td></tr><tr><td>node-auth0</td><td>^1.0.0</td><td><a href=https://npmjs.com/package/v/1.0.0>npm</a></td></tr><tr><td>ollama</td><td>^0.5.0</td><td><a href=https://npmjs.com/package/v/0.5.0>npm</a></td></tr><tr><td>openai</td><td>^4.28.4</td><td><a href=https://npmjs.com/package/v/4.28.4>npm</a></td></tr><tr><td>openwhisk</td><td>^3.21.8</td><td><a href=https://npmjs.com/package/v/3.21.8>npm</a></td></tr><tr><td>pg</td><td>^8.11.3</td><td><a href=https://npmjs.com/package/v/8.11.3>npm</a></td></tr><tr><td>plotly</td><td>^1.0.6</td><td><a href=https://npmjs.com/package/v/1.0.6>npm</a></td></tr><tr><td>redis</td><td>^4.6.13</td><td><a href=https://npmjs.com/package/v/4.6.13>npm</a></td></tr><tr><td>uuid</td><td>^9.0.1</td><td><a href=https://npmjs.com/package/v/9.0.1>npm</a></td></tr></tbody></table></div><div class=td-content style=page-break-before:always><h1 id=pg-63523ff3a1f21def755694971e193a9e>3 - nodejs:v21</h1><h2 id=nodejsv21-default-true>nodejs:v21 (default: true)</h2><table><thead><tr><th>Library</th><th>Version</th><th>Link</th></tr></thead><tbody><tr><td>@azure/openai</td><td>^1.0.0-beta.11</td><td><a href=https://npmjs.com/package/v/1.0.0-beta.11>npm</a></td></tr><tr><td>@langchain/community</td><td>^0.0.34</td><td><a href=https://npmjs.com/package/v/0.0.34>npm</a></td></tr><tr><td>minio</td><td>^7.1.3</td><td><a href=https://npmjs.com/package/v/7.1.3>npm</a></td></tr><tr><td>mongodb</td><td>^6.4.0</td><td><a href=https://npmjs.com/package/v/6.4.0>npm</a></td></tr><tr><td>node-auth0</td><td>^1.0.0</td><td><a href=https://npmjs.com/package/v/1.0.0>npm</a></td></tr><tr><td>ollama</td><td>^0.5.0</td><td><a href=https://npmjs.com/package/v/0.5.0>npm</a></td></tr><tr><td>openai</td><td>^4.28.4</td><td><a href=https://npmjs.com/package/v/4.28.4>npm</a></td></tr><tr><td>openwhisk</td><td>^3.21.8</td><td><a href=https://npmjs.com/package/v/3.21.8>npm</a></td></tr><tr><td>pg</td><td>^8.11.3</td><td><a href=https://npmjs.com/package/v/8.11.3>npm</a></td></tr><tr><td>plotly</td><td>^1.0.6</td><td><a href=https://npmjs.com/package/v/1.0.6>npm</a></td></tr><tr><td>redis</td><td>^4.6.13</td><td><a href=https://npmjs.com/package/v/4.6.13>npm</a></td></tr><tr><td>uuid</td><td>^9.0.1</td><td><a href=https://npmjs.com/package/v/9.0.1>npm</a></td></tr></tbody></table></div></main></div></div><footer class="td-footer row d-print-none"><div class=container-fluid><div class="disclaimer text-center"><div class="row mx-md-2"><div class="td-footer__left col-6 col-sm-2 order-sm-1"> </div><div class="td-footer__right col-6 col-sm-2 order-sm-3"> </div><div class="td-footer__center col-12 col-sm-8 py-2 order-sm-2"><p>Apache Openserverless™ is an effort undergoing incubation at The Apache Software Foundation (ASF), |
| sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a |
| further review indicates that the infrastructure, communications, and decision making process |
| have stabilized in a manner consistent with other successful ASF projects. While incubation |
| status is not necessarily a reflection of the completeness or stability of the code, it does |
| indicate that the project has yet to be fully endorsed by the ASF.</p><br><br><p>Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. |
| Apache Openserverless, the names of other Apache projects, and the ASF logo are either |
| registered trademarks or trademarks of the Apache Software Foundation in the United States |
| and/or other countries.</p></div></div><div class="row mx-md-2"><div class="td-footer__left col-6 col-sm-4 order-sm-1"> </div><div class="td-footer__right col-6 col-sm-4 order-sm-3"> </div><div class="td-footer__center col-12 col-sm-4 py-2 order-sm-2"><a href=https://www.apache.org/><img class="asf-logo rounded-image" src=/images/asf.webp width=256 height=104> |
| </a><a href=https://incubator.apache.org/projects/openserverless.html><img class="asf-logo rounded-image" src=/images/apache_incubator.webp width=256 height=104></a></div></div></div></div><div class=container-fluid><div class="row mx-md-2"><div class="td-footer__left col-6 col-sm-4 order-sm-1"><ul class=td-footer__links-list><li class=td-footer__links-item data-bs-toggle=tooltip title="Developer mailing list" aria-label="Developer mailing list"><a target=_blank rel=noopener href=mailto:dev-subscribe@openserverless.apache.org aria-label="Developer mailing list"><i class="fa fa-envelope"></i></a></li><li class=td-footer__links-item data-bs-toggle=tooltip title=X.com aria-label=X.com><a target=_blank rel=noopener href=https://x.com/open_serverless aria-label=X.com><i class="fab fa-x-twitter"></i></a></li><li class=td-footer__links-item data-bs-toggle=tooltip title=Reddit aria-label=Reddit><a target=_blank rel=noopener href=https://reddit.com/r/openserverless aria-label=Reddit><i class="fab fa-reddit"></i></a></li></ul></div><div class="td-footer__right col-6 col-sm-4 order-sm-3"><ul class=td-footer__links-list><li class=td-footer__links-item data-bs-toggle=tooltip title=GitHub aria-label=GitHub><a target=_blank rel=noopener href=https://github.com/apache/openserverless aria-label=GitHub><i class="fab fa-github"></i></a></li><li class=td-footer__links-item data-bs-toggle=tooltip title=Discord aria-label=Discord><a target=_blank rel=noopener href=https://discord.com/invite/PkD7CcHgGP aria-label=Discord><i class="fab fa-discord"></i></a></li><li class=td-footer__links-item data-bs-toggle=tooltip title=Slack aria-label=Slack><a target=_blank rel=noopener href=https://the-asf.slack.com/archives/C07B6K5R3F0 aria-label=Slack><i class="fab fa-slack"></i></a></li></ul></div><div class="td-footer__center col-12 col-sm-4 py-2 order-sm-2"><span class=td-footer__copyright>© |
| 2024–2025 |
| <span class=td-footer__authors>The Apache Software Foundation, Licensed under the Apache License, Version 2.0.</span></span><span class=td-footer__all_rights_reserved>All Rights Reserved</span></div></div></div></footer><div id=theme-toggler-container><button id=theme-toggler class="btn btn-light-dark" aria-label="Toggle theme"> |
| <span id=theme-icon class="fa fa-sun"></span></button></div><script>const themeToggler=document.getElementById("theme-toggler"),themeIcon=document.getElementById("theme-icon"),currentTheme=localStorage.getItem("theme")||"light";themeToggler.addEventListener("click",()=>{document.documentElement.classList.toggle("dark-mode");const e=document.documentElement.classList.contains("dark-mode");themeIcon.classList.toggle("fa-sun",!e),themeIcon.classList.toggle("fa-moon",e),localStorage.setItem("theme",e?"dark":"light")})</script><style>#theme-toggler-container{position:fixed;bottom:70px;right:20px;z-index:1000}.btn-light-dark{background:#fff;border:1px solid #ddd;border-radius:50%;width:50px;height:50px;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 6px rgba(0,0,0,.1);cursor:pointer;transition:background-color .3s,transform .2s}.btn-light-dark:hover{background:#f0f0f0;transform:scale(1.1)}.dark-mode .btn-light-dark{background:#333;color:#fff;border-color:#444}</style></div><script src=/js/main.min.90902a026ed2aee7ed45d85797f4c790b240ba148ac6f8a6f194cb1981ffecf5.js integrity="sha256-kJAqAm7SruftRdhXl/THkLJAuhSKxvim8ZTLGYH/7PU=" crossorigin=anonymous></script><script src=/js/prism.js></script><script src=/js/tabpane-persist.js></script></body></html> |