Fixed country code type issue
https://ci.odit.services/lfk/backend/252/1/2 ref #102
This commit is contained in:
parent
d1a0bed00e
commit
a77e2eb3ad
@ -1,4 +1,5 @@
|
|||||||
import { config as configDotenv } from 'dotenv';
|
import { config as configDotenv } from 'dotenv';
|
||||||
|
import { CountryCode } from 'libphonenumber-js';
|
||||||
import ValidatorJS from 'validator';
|
import ValidatorJS from 'validator';
|
||||||
|
|
||||||
configDotenv();
|
configDotenv();
|
||||||
@ -6,7 +7,7 @@ export const config = {
|
|||||||
internal_port: parseInt(process.env.APP_PORT) || 4010,
|
internal_port: parseInt(process.env.APP_PORT) || 4010,
|
||||||
development: process.env.NODE_ENV === "production",
|
development: process.env.NODE_ENV === "production",
|
||||||
jwt_secret: process.env.JWT_SECRET || "secretjwtsecret",
|
jwt_secret: process.env.JWT_SECRET || "secretjwtsecret",
|
||||||
phone_validation_countrycode: process.env.PHONE_COUNTRYCODE || "ZZ",
|
phone_validation_countrycode: getPhoneCodeLocale(),
|
||||||
postalcode_validation_countrycode: getPostalCodeLocale(),
|
postalcode_validation_countrycode: getPostalCodeLocale(),
|
||||||
version: process.env.VERSION || require('../package.json').version
|
version: process.env.VERSION || require('../package.json').version
|
||||||
}
|
}
|
||||||
@ -14,15 +15,12 @@ let errors = 0
|
|||||||
if (typeof config.internal_port !== "number") {
|
if (typeof config.internal_port !== "number") {
|
||||||
errors++
|
errors++
|
||||||
}
|
}
|
||||||
if (typeof config.phone_validation_countrycode !== "string") {
|
|
||||||
errors++
|
|
||||||
}
|
|
||||||
if (config.phone_validation_countrycode.length !== 2) {
|
|
||||||
errors++
|
|
||||||
}
|
|
||||||
if (typeof config.development !== "boolean") {
|
if (typeof config.development !== "boolean") {
|
||||||
errors++
|
errors++
|
||||||
}
|
}
|
||||||
|
function getPhoneCodeLocale(): CountryCode {
|
||||||
|
return (process.env.PHONE_COUNTRYCODE as CountryCode);
|
||||||
|
}
|
||||||
function getPostalCodeLocale(): any {
|
function getPostalCodeLocale(): any {
|
||||||
try {
|
try {
|
||||||
const stringArray: String[] = ValidatorJS.isPostalCodeLocales;
|
const stringArray: String[] = ValidatorJS.isPostalCodeLocales;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user