Skip to content

Simple Node.js service to redirect links based on the client's country and link ID.

Notifications You must be signed in to change notification settings

igoramadas/country-linkify

Repository files navigation

Country Linkify

Simple Node.js library / service to redirect links based on the client's country and link ID.

Link definitions

All links should be defined in .json files under the /links folder (or another folder, if you change the settings.links.path key). Each file represents a source, for example, a specific website or category of links.

Each key inside the JSON specs represents a link ID, and the target URLs by country. If a key gets a single string as its value, this will be the URL valid for any country.

There are also 2 standard keys, prefixed with an underscore:

  • _default: the default target URL(s) for that source.
  • _search: URL for the search page of the source, must have a {{query}} tag defined

A sample definition for "Amazon":

{
    "_default": {
        "de": "https://www.amazon.de/",
        "us": "https://www.amazon.com/",
        "uk": "https://www.amazon.co.uk/"
    },
    "_search": {
        "us": "https://www.amazon.com/s?k={{query}}"
    },
    "deals": {
        "de": "https://www.amazon.de/-/en/deals",
        "us": "https://www.amazon.com/gp/goldbox",
        "uk": "https://www.amazon.co.uk/gp/deals"
    },
    "help": "https://www.amazon.com/gp/help/customer/display.html"
}

And a second file for "AliExpress":

{
    "_default": "https://aliexpress.com",
    "_search": {
        "de": "https://de.aliexpress.com/w/{{query}}.html"
    },
    "deals": {
        "de": "https://www.aliexpress.com/sp/campaign/wow/gcp-plus/300000444/njcQZ4CkBb"
    }
}

With the samples above, a user from Germany (de) will get redirected to the following target URLs:

And the results for someone from US:

Settings

This tool is using the SetMeUp module to handle its settings, so for detailed info please check its docs.

  • settings.json - settings shared by all environments, targeting production by default
  • settings.development.json - development settings, mostly when running on your dev machine
  • settings.production.json - production-only settings, except credentials and secrets (optional)
  • settings.local.json - private local-only settings, excluded from the GIT repo

Settings are self explanatory, please open each file to check the available options.

About

Simple Node.js service to redirect links based on the client's country and link ID.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published