Add environment example, update .gitignore, and switch license to AGPL v3. Introduce error handling classes, ESLint config, and main modules for database, logging, certificate management, and utility functions. Add authentication routes, schemas, and service layer for a modular REST API. Update README and set up repository structure for further development.
29 lines
705 B
JavaScript
29 lines
705 B
JavaScript
const path = require("node:path")
|
|
const Logger = require("./logger")
|
|
const logger = Logger.createLogger(path.join(__dirname, ".."))
|
|
|
|
async function getRegistrationCountryFromIp(ipAddress) {
|
|
const apiUrl = `https://ip-api.com/json/${ipAddress}?fields=countryCode`
|
|
|
|
try {
|
|
const response = await fetch(apiUrl)
|
|
if (!response.ok) {
|
|
return "FR"
|
|
}
|
|
|
|
const data = await response.json()
|
|
if (data && data.countryCode) {
|
|
const countryCode = data.countryCode
|
|
return countryCode
|
|
} else {
|
|
return "FR"
|
|
}
|
|
|
|
} catch (error) {
|
|
return "??"
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
getRegistrationCountryFromIp
|
|
} |