JavaScript
- 4 ответа
- 0 вопросов
3
Вклад в тег
const express = require('express');
const app = express();
const iplocate = require('iplocate');
app.use(iplocate);
// middleware for filtering by country
app.use(function (req, res, next) {
// some error
if ( req.locationError ) {
// handle error
}
if ( req.location.country_code !== 'RU' ){
return res.send("request available only from russia")
}
next();
});
app
.get('/', (req, res) => {
res.send('success');
})
app.listen(3000, function () {
console.log('app listening on port 3000!');
});