Skip to content

Commit

Permalink
hotfix: docker environment
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo spinelli committed May 21, 2020
1 parent 0213a42 commit b195a7f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 77 deletions.
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Docker: Attach to Node",
"protocol": "auto",
"port": 5858,
"restart": true,
"localRoot": "${workspaceFolder}",
"remoteRoot": "/usr/src/app",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"skipFiles": [
"<node_internals>/**/*.js",
]
},
{
"type": "node",
"request": "launch",
Expand Down
1 change: 1 addition & 0 deletions docker/fixtures/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM node:10.14.2-alpine

WORKDIR /opt/cosmosdb

RUN apk add git
RUN npm install -g ts-node typescript && \
npm install documentdb @types/documentdb io-functions-commons \
io-ts@1.8.5 fp-ts@1.12.0 italia-ts-commons
Expand Down
73 changes: 0 additions & 73 deletions docker/fixtures/index.js

This file was deleted.

17 changes: 13 additions & 4 deletions docker/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/**
* Insert fake data into CosmosDB database emulator.
*/
import { CollectionMeta, UriFactory } from "documentdb";
import {
CollectionMeta,
DocumentClient as DocumentDBClient,
UriFactory
} from "documentdb";
import { Either, left, right } from "fp-ts/lib/Either";
import {
Profile,
Expand All @@ -15,12 +19,17 @@ import {
} from "io-functions-commons/dist/src/models/service";
import * as documentDbUtils from "io-functions-commons/dist/src/utils/documentdb";
import { getRequiredStringEnv } from "io-functions-commons/dist/src/utils/env";
import { documentClient } from "../../utils/cosmosdb";

const cosmosDbKey = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_KEY");
const cosmosDbUri = getRequiredStringEnv("CUSTOMCONNSTR_COSMOSDB_URI");
const cosmosDbName = getRequiredStringEnv("COSMOSDB_NAME");

const documentDbDatabaseUrl = documentDbUtils.getDatabaseUri(cosmosDbName);

const documentClient = new DocumentDBClient(cosmosDbUri, {
masterKey: cosmosDbKey
});

function createDatabase(databaseName: string): Promise<Either<Error, void>> {
return new Promise(resolve => {
documentClient.createDatabase({ id: databaseName }, (err, _) => {
Expand Down Expand Up @@ -86,8 +95,8 @@ const profileModel = new ProfileModel(documentClient, profilesCollectionUrl);

const aProfile: Profile = Profile.decode({
acceptedTosVersion: 1,
email: "spammmmme@example.com",
fiscalCode: "SPNDNL80R11C555K",
email: "email@example.com",
fiscalCode: "AAAAAA00A00A000A",
isEmailEnabled: true,
isEmailValidated: true,
isInboxEnabled: true,
Expand Down

0 comments on commit b195a7f

Please sign in to comment.