Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-location-filter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-location-filter

koa middleware filtering requests depenging on user's location

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

koa-location-filter

Middleware for Koa realizing filtering via user's location.

Install


Install with npm

$ npm install koa-location-filter --save

Usage

This module works detects the location of client by requests to following providers:

Countries list

You can to make list of countries access is denied from. The can be added into the list by code. List of countrues and their codes: geonames

Example

For each country you can specify the reponse message. Response will be with code status 404.

var Koa = require('koa');
var app = new Koa();
var filter = require('koa-location-filter');

filter(app, {
	blackList: {
		RU: 'Вам запрещён доступ',
		BG: 'Ne moze bee',
		US: 'Access is denied'
	}
});

app.use(async (ctx, next) => {
	ctx.body = 'Success';
});

var port = 8000;
app.listen(port, ()=> {
	console.log('Сервер работает на порту ' + port);
});

Keywords

FAQs

Package last updated on 17 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc