Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Whether we're in a production environment
const isProduction = process.env.NODE_ENV === "production";
const getCustomTelemetryClient = wrapCustomTelemetryClient(
isProduction,
new TelemetryClient()
);
// Setup DocumentDB
const cosmosDbUri = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_URI");
const cosmosDbKey = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_KEY");
const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME");
const documentDbDatabaseUrl = documentDbUtils.getDatabaseUri(cosmosDbName);
const notificationsCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
NOTIFICATION_COLLECTION_NAME
);
const notificationStatusCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
NOTIFICATION_STATUS_COLLECTION_NAME
);
export const EMAIL_NOTIFICATION_QUEUE_NAME = "emailnotifications";
const queueConnectionString = getRequiredStringEnv("QueueStorageConnection");
// We create the db client, services and models here
// as if any error occurs during the construction of these objects
// Setup Express
const app = express();
secureExpressApp(app);
// Set up CORS (free access to the API from browser clients)
app.use(cors());
// Setup DocumentDB
const cosmosDbUri = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_URI");
const cosmosDbKey = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_KEY");
const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME");
const messageContainerName = getRequiredStringEnv("MESSAGE_CONTAINER_NAME");
const documentDbDatabaseUrl = documentDbUtils.getDatabaseUri(cosmosDbName);
const messagesCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
MESSAGE_COLLECTION_NAME
);
const messageStatusCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
MESSAGE_STATUS_COLLECTION_NAME
);
const profilesCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
PROFILE_COLLECTION_NAME
);
const servicesCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
SERVICE_COLLECTION_NAME
);
// Whether we're in a production environment
const isProduction = process.env.NODE_ENV === "production";
const getCustomTelemetryClient = wrapCustomTelemetryClient(
isProduction,
new TelemetryClient()
);
// Setup DocumentDB
const cosmosDbUri = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_URI");
const cosmosDbKey = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_KEY");
const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME");
const documentDbDatabaseUrl = documentDbUtils.getDatabaseUri(cosmosDbName);
const notificationsCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
NOTIFICATION_COLLECTION_NAME
);
const notificationStatusCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
NOTIFICATION_STATUS_COLLECTION_NAME
);
export const WEBHOOK_NOTIFICATION_QUEUE_NAME = "webhooknotifications";
const queueConnectionString = getRequiredStringEnv("QueueStorageConnection");
// We create the db client, services and models here
// as if any error occurs during the construction of these objects
import { secureExpressApp } from "io-functions-commons/dist/src/utils/express";
// Whether we're in a production environment
const isProduction = process.env.NODE_ENV === "production";
// Setup Express
const app = express();
secureExpressApp(app);
// Setup DocumentDB
const cosmosDbUri = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_URI");
const cosmosDbKey = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_KEY");
const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME");
const documentDbDatabaseUrl = documentDbUtils.getDatabaseUri(cosmosDbName);
const servicesCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
"services"
);
const documentClient = new DocumentDBClient(cosmosDbUri, {
masterKey: cosmosDbKey
});
const serviceModel = new ServiceModel(documentClient, servicesCollectionUrl);
// Setup handlers
const debugHandler = GetDebug(serviceModel);
app.get("/adm/debug", debugHandler);
import { VisibleService } from "io-functions-commons/dist/src/models/visible_service";
import { configureAzureContextTransport } from "io-functions-commons/dist/src/utils/logging";
interface IOutputBindings {
readonly visibleServicesBlob: Record;
}
// Whether we're in a production environment
const isProduction = process.env.NODE_ENV === "production";
const cosmosDbUri = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_URI");
const cosmosDbKey = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_KEY");
const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME");
const documentDbDatabaseUrl = documentDbUtils.getDatabaseUri(cosmosDbName);
const servicesCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
SERVICE_COLLECTION_NAME
);
const documentClient = new DocumentClient(cosmosDbUri, {
masterKey: cosmosDbKey
});
const serviceModel = new ServiceModel(documentClient, servicesCollectionUrl);
function reduceServicesToVisibleServices(
visibleServicesObj: StrMap,
service: RetrievedService
): StrMap {
// we use an in-memory object (map)
import { ulidGenerator } from "io-functions-commons/dist/src/utils/strings";
// Whether we're in a production environment
const isProduction = process.env.NODE_ENV === "production";
const getCustomTelemetryClient = wrapCustomTelemetryClient(
isProduction,
new TelemetryClient()
);
// Setup DocumentDB
const cosmosDbUri = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_URI");
const cosmosDbKey = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_KEY");
const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME");
const documentDbDatabaseUrl = documentDbUtils.getDatabaseUri(cosmosDbName);
const profilesCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
PROFILE_COLLECTION_NAME
);
const messagesCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
MESSAGE_COLLECTION_NAME
);
const notificationsCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
NOTIFICATION_COLLECTION_NAME
);
const messageStatusCollectionUrl = documentDbUtils.getCollectionUri(
documentDbDatabaseUrl,
MESSAGE_STATUS_COLLECTION_NAME
);