Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import convict from "convict";
import Joi from "joi";
// Add custom format for the mongo uri scheme.
convict.addFormat({
name: "mongo-uri",
validate: (url: string) => {
Joi.assert(
url,
Joi.string().uri({
scheme: ["mongodb"],
})
);
},
});
// Add custom format for the redis uri scheme.
convict.addFormat({
name: "redis-uri",
validate: (url: string) => {
Joi.assert(
// Add custom format for the redis uri scheme.
convict.addFormat({
name: "redis-uri",
validate: (url: string) => {
Joi.assert(
url,
Joi.string().uri({
scheme: ["redis"],
})
);
},
});
// Add a custom format for the optional-url that includes a trailing slash.
convict.addFormat({
name: "optional-url",
validate: (url: string) => {
if (url) {
Joi.assert(url, Joi.string().uri());
}
},
// Ensure that there is an ending slash.
coerce: (url: string) => (url ? ensureEndSlash(url) : url),
});
// Add a custom format that is a duration parsed with `ms` to used instead of
// the default format which will use `moment`.
convict.addFormat({
name: "ms",
validate: (val: number) => {
Joi.assert(val, Joi.number().min(0));
convictFormats.forEach((format) => {
convict.addFormat(format);
});
convictFormats.forEach((format) => {
convict.addFormat(format);
});
config.schema_formats.forEach((format) => {
convict.addFormat(format);
});
}
convictFormats.forEach(function(obj) {
convict.addFormat(obj)
});
import signale from 'signale';
import convict from 'convict';
import rc from 'rc';
import { MODE_PLAYER } from './modes.js';
const processEnv = process.env;
const isPlayerMode = processEnv['WEB_MYNA_MODE'] === MODE_PLAYER || !processEnv['WEB_MYNA_MODE'];
const globalConfiguration = rc('webmyna', { apis: [], recordingsPath: null });
convict.addFormat({
name: 'apis',
validate: (apis, schema) => {
if (!Array.isArray(apis)) {
throw new Error('must be of type Array');
}
apis.map((api, index) => {
const tokenName = api.name ? `${api.name.toUpperCase().replace(/-/g, '_')}_TOKEN` : null;
signale.debug(tokenName);
if (tokenName || isPlayerMode) {
const apiToken = processEnv[tokenName];
apis[index].token = isPlayerMode ? 'webMynaPlayerToken' : apiToken;
}
});
for (const api of apis) {