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

aquanow-admin-lambda

v5.39.1

Published

Backend APIs for [Aquanow Admin Site](https://github.com/AquaNow/aquanow-admin-site) #### Why webpack - Webpack as compiler and bundler, so we can control code size, quality, linting. - Webpack, Babel & Eslint work together as an abstract layer give us mo

Downloads

2

Readme

Aquanow Admin-site Lambda

Backend APIs for Aquanow Admin Site

Why webpack

  • Webpack as compiler and bundler, so we can control code size, quality, linting.
  • Webpack, Babel & Eslint work together as an abstract layer give us more control over source code and final output. Eventually result in a uniformed development practice across organization which helps developers focus on business logic.

Prerequisites

AWS

Serverless command requires valid AWS credentials and AWS profiles(default aquaNow-DEV). If you come from auqanow-admin-site, you should already have those configured. Otherwise, refer to this link for details.

Dependencies

If you are the first time working on this repo make sure node version aligned with AWS environments and install dependencies

npm ci

Development

Local function invocation

npm start

This will start up an emulated API gateway on your local environment(default http://localhost:3000). After that you can send request directly to the gateway to test your function. Please keep in mind some API call will still be sent to online environments, i.e. S3, DynamoDB etc. Thus this is not a fully isolated local environment. For more information, please refer to serverless-offline and serverless-webpack plugins.

You can also invoke individual function by using OOTB serverless command invoke local -f <Function name> --path <JSON payload path>.

Environment variables

We don't use .env file to host environment variables. All variables will be hosted in serverless.yml file, custom block.

Breakpoints & local Debugging

You can configure your IDE to attach debug process to nodejs for local breakpoints & debugging. Here is an example for VSCode:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Serverless Offline",
      "program": "${workspaceRoot}/node_modules/serverless/bin/serverless",
      "args": [
        "offline",
        "--noTimeout",
        "--noAuth",
        "--stage=DEV"
      ],
      "sourceMaps": true,
      "runtimeArgs": ["--lazy"],
      "protocol": "inspector",
      "runtimeExecutable": "node",
      "env": {
        // Here we set some environment vars that should be set locally.
        // They can and will overwrite the ones coming from your serverless.yml
      },
      "windows": {
        "program": "${workspaceRoot}\\node_modules\\serverless\\bin\\serverless"
      },
      "console": "integratedTerminal"
    },
  ]
}

Unit Testing

npm test

Do not write unit test against any online environment. Write pure function, extract business logic from handler and mock the dependencies. Testing should be done prior to any staging/prod deployment.

Integration testing

We are still working on the template of integration testing. Integration testing will be performed against online environment.

Deployment

We are using 3 different AWS environments:

  • DEV (development/QA)
  • STAGING (staging/UAT)
  • PROD (production/live)

In manual deployment to non-dev environment, please do not deploy each function separately to avoid inconsistent versions within same service.

sls deploy -f <FunctionName> -s <Stage(Uppercase)>

Troubleshooting

Configuration change not detected when deploying new version

This problem seems to be caused by manual updating config values on AWS console, so that CF is not able to detect the changes anymore. To avoid this issue, it is important to only update configs by deploy serverless.yml. If you find how to fix this issue, please update this documentation. #6956

JavaScript heap out of memory when packaging artifacts

This is due to a memory leak issue in serverless-webpack plugin when compiling artifacts with node_modules dependencies. This can be resolved by adjusting max space usage by node(default 1.7 GB)

export NODE_OPTIONS=--max-old-space-size=4096
npx serverless package

TODO

  • [x] Serverless-offline
  • [x] Properly handle environment variables
  • [x] Remove layer usage in every function
  • [x] Remove husky and precommit hook, use webpack for eslint & type check
  • [x] Better unit testing suite
  • [x] Standardize Eslint rules for Lambda repos
  • [ ] Properly log and monitor error event
  • [ ] momentjs migrate to dayjs for smaller bundle size
  • [ ] Add serverless test functionality
  • [ ] Prevent manual update configuration(CI/CD) which causes future CF changes not being detected

====== postponed =======

  • [ ] Migrate to Typescript (Team are not ready for migration yet)
  • [ ] aws-sdk upgrade to v3 to help tree-shaking (Use native aws-sdk for now)