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

@specprotected/spec-proxy-akamai-worker

v0.1.2

Published

Akamai EdgeWorker library to facilitate communication with the Spec Proxy product.

Downloads

8

Readme

Spec Proxy Akamai EdgeWorker Integration

This document describes a method of integrating with Spec Proxy through an Akamai EdgeWorker.

We won't cover in detail how to use an Akamai EdgeWorker and will instead direct you to follow their documentation to get a worker project setup and deployed to an Akamai Property. Once deployed, all you need do is copy our sample code into your EdgeWorker as well as communicate with the Spec team to coordinate the Spec Proxy deployment.

Akamai EdgeWorker Documentation

Implementation Example

Using our library is simple. We require only a single function call if we are the only library you are using.

// Import the Spec Proxy library functions
import {
  SpecConfiguration,
  specProxyProcess,
} from '@specprotected/spec-proxy-akamai-worker';

const specConfig: SpecConfiguration = { inlineMode: false };

// Spec Proxy requires the use of the `responseProvider` event in the Akamai
// EdgeWorker lifecycle
export async function responseProvider(request: EW.ResponseProviderRequest) {
  // Process the request as directed by the SpecConfiguration
  let response: HttpResponse = await spec.specProxyProcess(request, specConfig);
  // Return the response to the client
  return createResponse(response.body, response);
}

There's no additional configuration of our library required in order to use it. Your Akamai configuration and your Spec Proxy deployment take care of all of the inner details of routing traffic. The only additional thing you will have to configure is how to route traffic to your worker, which is done through the use of Akamai Rules as described in the Akamai documentation link above.


If you need to integrate alongside another library, we do provide the two component functions of our library which process the request and response. All you need to do to use this is call each part individually. We return to you a custom type AkamaiRequest which is required because Akamai types lack sufficient definition to allow you to modify requests multiple times.

// Import the Spec Proxy library functions
import {
  SpecConfiguration,
  specProxyProcessRequest,
  specProxyProcessResponse,
} from '@specprotected/spec-proxy-akamai-worker';

const specConfig: SpecConfiguration = { inlineMode: false };

// Spec Proxy requires the use of the `responseProvider` event in the Akamai
// EdgeWorker lifecycle
export async function responseProvider(originalRequest: EW.ResponseProviderRequest) {
  // Process the request as directed by the SpecConfiguration
  let request = await specProxyProcessRequest(originalRequest, config);

  // Manipulate the request here if you would like.

  // Make the request and process the response.
  let response = specProxyProcessResponse(
    originalRequest,
    await httpRequest(request.url, request)
  );

  // Manipulate the response here if you would like.

  // Return the response to the client
  return createResponse(response.body, response);
}