npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@told/azure-functions-server

v1.9.16

Published

Azure Functions Server

Downloads

146

Readme

Azure Functions Server

npm (scoped) Build Status Coverage Status

Cli tool and Base Code for Node Azure Functions with Typescript

Usage

npm install @told/azure-functions-server --save
// Add this to package.json > scripts:
// "afs": ".\\node_modules\\.bin\\afs -w",
npm run afs

Source Project Structure

  • src-server contains azure function entrances
    • example-function-get-blob.ts
      • An example of generating a random uuid for a user and giving them a azure storage blob with sas write access
    • example-function-resource.ts
      • An example of serving files from the deployment/resources folder
      • __dirname is relative to the azure function runtime path (not the original source file)
  • src contains common code for app models and business logic
    • app models and business logic can be tested with karma + jasmine
    • app models and business logic can be used to do client side processing (that can be verified by server-side processing if needed)
  • resources
    • contains the BOILERPLATE for a azure function
      • test.js is used for local testing which simulates an azure function call
      • index.js is the entrance for azure which calls build.js
      • build.js (generated by webpack in the cli)
      • build.source.js is the source file used for webpack to generate the deployment/FUNCTION/build.js
  • .deployment directs azure git deployment to use the "deployment" folder as root
  • (generated) deployment contains the server-side deployment code
    • a clone of lib code
    • a clone of package.json with dev-dependencies removed
    • a generated function entry point for each entry point in src-server

Webpack for Node Azure Functions

The cli tool manually calls webpack after moving everything into the deployment folder.

See src-cli/run-webpack.ts to see actual call in typescript.

At time of writing, the configuration settings are:

    entry: {
        // './EXAMPLE.webpack.js': './EXAMPLE.js',
    },
    output: {
        path: './',
        filename: '[name]'
    },
    target: 'node',
    node: {
        __filename: false,
        __dirname: false,
    }

Webpack Performance

The chart below shows an example of the difference between using webpack and removing node_modules or just using node_modules.

The tested function used the azure-storage npm package to create a random blob sas url.

Webpack was able to package the azure-storage without a problem and cold start performance increased from an unnacceptable time of 80 secs to an acceptable 3 sec cold start (25x increase).

Webpack Performance

Keep Alive Timer Trigger Function

Futher improvements can be gained by using a timer function (at around 4 mins) to keep the functions from going cold.

Although this will help for services that have sporadic requests, it does not help with services that require scaling up quickly as scaling to another instance still requires a cold start.