koa-location-filter

1.0.0 • Public • Published

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);
});

Package Sidebar

Install

npm i koa-location-filter

Weekly Downloads

1

Version

1.0.0

License

ISC

Last publish

Collaborators

  • aerodromio