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

atomic-url

v2.2.2

Published

A URL shortener POC built using Cloudflare Worker.

Downloads

8

Readme

flowchart TD
  api([API Clients])
  browser([Browser])
  worker(<a href='https://developers.cloudflare.com/workers/'>Worker</a>):::cf
  kv[(<a href='https://developers.cloudflare.com/workers/runtime-apis/kv/'>KV</a>)]:::cf
  cache[(<a href='https://developers.cloudflare.com/workers/runtime-apis/cache/'>Cache</a>)]:::cf

  classDef cf stroke:#FFC500,stroke-width:2px

  subgraph Cloudflare
    worker
    kv
    cache
  end

  kv <--> worker
  cache <--> worker
  worker <--> api
  worker <--> browser

Designing a URL shortener such as TinyURL and Bitly is one of the most common System Design interview questions in software engineering.

While meddling around with Cloudflare Worker, it gave me an idea to build an actual URL shortener that can be used by anyone.

This is a proof of concept (POC) of how one builds an actual URL shortener service using serverless computing.

Read more...

Table of Contents

Requirements

Setup

Check out Steps 1 to 3 of this Get Started Guide to setup a Cloudflare account.

Read more about configuring wrangler.toml.

Installation

This project is initialized using the itty-router worker template.

npm ci

Creating KV

Since we're using KV as our storage, we need to first create it.

wrangler kv:namespace create "URL_DB"
wrangler kv:namespace create "URL_DB" --preview

For creating these KV namespaces, remember to update your wrangler.toml file to include the namespace bindings accordingly.

Optional: CI/CD

  1. This project uses Wrangler actions to automatically publish worker. To do so, add CF_API_TOKEN into your GitHub repository secrets. You can create your API token using the Edit Cloudflare Workers template.

  2. This project also uses semantic-release to automatically publish to NPM. To enable this, you will need to create a NPM_TOKEN via npm create token and add it to your GitHub repository secrets.

Usage

To try out the project locally, simply run wrangler dev.

Deployment

NOTE The deployment of this project is done using GitHub Actions CI/CD. For more details, check out ci.yml and this article.

  1. Before publishing your code you need to edit wrangler.toml file and add your Cloudflare account_id - more information about configuring and publishing your code can be found in the documentation.

  2. Create 2 KV and update your wrangler.toml file to include the namespace bindings accordingly.

  3. To publish any new changes to your Cloudflare Worker, run wrangler publish -e <env> where <env> could staging or production.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Steps

  1. Fork this
  2. Create your feature branch (git checkout -b jimmy/fooBar)
  3. Code
  4. Commit your changes (git commit -am 'feat: add some fooBar', make sure that your commits are semantic)
  5. Push to the branch (git push origin jimmy/fooBar)
  6. Create a new Pull Request