How to import InfoType or other types from google-cloud/dlp for typescript in nodejs - node.js

Working with Google cloud DLP and nodejs. After import DLP from "#google-cloud/dlp, how can I import InfoType, Likelihood, IInspectContentRequest and other types from the library as it contains all types.

Solution import {protos} from "#google-cloud/dlp

Related

import twilio's Authy library in nest js

we usually use below statement to use authy library in node file using js ,mostly by require statement !
const authy = require('authy')('API KEY');
I've moved my code to nest eco system and now How should i do the same using typescript ,as i also want to pass API Key to it ?
I've tried below code as well ,but still it's not working
import { authy } from 'authy'(API KEY)
suggest something !
I have faced a similar issue in my NestJS project when using twillio library.
Currently, I have resolved this by importing it this way:
import authy = require('authy');
If, this doesn't work for you (for any reason e.g. TypeScript compile error), then can you try the following import statement?
import * as Authy from 'authy';
Also, let me know which one works for you.

How to import airbnbapi?

Following this tutorial: https://github.com/zxol/airbnbapi
and would like to import SDK
var airbnb = require('airbnbapijs')
I do not see any component like airbnbapijs. Shouldn't it exist to be import into my web app?

How to patch google.cloud.storage in python

I have a class that import google cloud:
StorageUtils:
from google.cloud import storage
I have a app that uses StorageUtils:
App:
import StorageUtils
Then I have a test, that I want to test my app
Test:
from app import App
I want to test my app without using google cloud. The easiest way I found is to use sys.modules:
import sys
from unittest.mock import MagicMock
sys.modules["google.cloud.storage"] = MagicMock()
I found this solution quite a work around. Are there any other way using python mock?
In this case, if the file that contains the class StorageUtils is called storage_utils.py:
#test_storage.py
#patch("storage_utils.storage")
def test_storage(st):
storage = StorageUtils()

Secondary import when using Firebase?

Why do we need to import what seems like the same module twice when using Firebase?
import { firestore, initializeApp } from 'firebase';
import 'firebase/firestore';
Would be interesting to hear why this case may come up in general node/js es6 modules and not just here.
I usually do something like this:
import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
The first line imports the main Firebase dependency, so that you call firebase.initializeApp(...).
The second and third line then import specific Firebase product SDKs on top of that, so that you can access firebase.firestore() and firebase.auth().
This pulls in the minimal amount of JavaScript that is needed for my specific app.
Your first line pulls in the SDKs for all Firebase projects, and then imports a few objects out of there. This is quite wasteful, as you're unlikely to be using all products in an app.
I'm actually not sure what the second line does in your case.

Webstorm Import url issues with Angular 2

Looking for some guidance on WebStorm v11 and using Angular2 imports, I'm also on a Mac.
Whenever I am creating a component and I import for example Http service from Angular 2, WebStorm does its thing and automatically imports it on the page for me. However the URL for the import is a crazy string, but in all the demos I've seen it just imports to a simple string like this:
import {Http} from "angular2/core";
but mine will import like this:
import {Http} from "../../../node_modules/angular2/src/http/http";
So I will manually go and change it to the more simple one for readability and it still works fine. Any ideas or help on how I could get it to import with the simple string?

Resources