1.0.0 • Published 9 years ago

edgescape-parser v1.0.0

Weekly downloads
11
License
MIT
Repository
github
Last release
9 years ago

edgescape-parser

Middleware for parsing the Akamai EdgeScape header

Install

$ npm install --save edgescape-parser

Usage

var express = require('express');
var edgescapeParser = require('edgescape-parser');

var app = express();

app.use(edgescapeParser());

app.get('/:country_code?', function(req, res) {

  // redirect homepage to country code
  if(_.isUndefined(req.params.country_code)) {
    var country_code = req.akamai.edgescape.country_code.toLowerCase() || 'us';
    res.redirect(302, '/' country_code);
  } else {
    // Render country specific page
  }

});

API

edgescapeParser(options)

options

header

Type: string
Default: x-akamai-edgescape

Parses the header into a JSON object containing all of the EdgeScape variables.

Attribute NameAvailabilityValue TypeDescription
country_codeglobalstringTwo-letter ISO-3166-1 country code
region_codeglobalstring/integerProvince, region or state code. Not available in all countries.
cityglobalstring
dmaUnited StatesintegerDesignated Marketing Area - the same as the Nielson definition.
pmsaUnited StatesintegerPrimary Metropolitan Statistical Area, a measure by the US government. There is no direct correlation for these measures outside the US.
msaUnited StatesintegerA number representing the Metropolitan Statistical Area.
area codeUnited Statesinteger-array‘+’ delimited array of phone area codes associated with the client IP address.
countyUnitedStates string
fipsUnited StatesintegerNumerical value for the county
latglobalfloatGlobal latitude position
longglobalfloatGlobal longitude position
timezoneglobalstring GMT + offset
zipUnited States + Canadazipcode-range-array‘+’ delimited array of zipcode ranges. ‘-’ indicates the range. Note that this field is based on the ‘city’ field, so that is the current granularity level.
continentglobalstring
throughputglobalstringSee the “Actual Connection Speed (throughput)” file under Support > User and Developer Guides > Content Targeting > Data Codes.
bwglobalintegerProvides additional granularity to the ‘throughput’ field.
asnumglobalinteger-array‘+’ delimited array of Autonomous System (AS) numbers.
networkglobal, select networksstringThe name of the network/ISP that owns the IP address, including wireless carriers. Select networks only.
network_typeglobalstringThe connection type seen in the end user’s request (e.g., dialup, cable, dsl)
proxyglobalstringThis value is set if the IP is a proxy.

License

MIT © MadGlory