I am using observablehq for playing around with the graphql js library.
However, I fail at importing it and observable complains about this module.
Any hint? Do we need to modify the library to make it observable friendly?
Observable has a Module require debugger for these situations; given a module name, it can often find a way to make it work. E.g., for GraphQL, it suggests using Skypack, which works for me in a notebook:
graphql = import('https://cdn.skypack.dev/graphql#15.4.0')
Related
Within my Cypress tests I would like to use the endpoints that I generate from our swagger documentation. However, these endpoints use a custom Axios client, that uses Redux and a ton of other dependencies. I can mock this client, but only by using:
import * as CustomAxios from "libs/custom";
cy.stub(CustomAxios, "customAxios");
However, within this file "custom.ts", I have the following code:
export const customAxios = createCustomAxiosClient()
It seems I cannot mock this file, without importing the file, and calling this method (which creates errors). Does anyone have an idea how I can mock this customAxios client without having the createCustomAxiosClient() method being called (which I cannot remove).
I tried reading the documentation and other questions, but I could not find any answers to my specific case.
I'm using PM2 to server my Koa backend. However when I use imports it serves no website / crashes. What's the work around for this? I see Koa snippets with imports all over. Node v7.6 stable.
This isn't really a Koa-specific related issue. The ES6 import/export module syntax hasn't been implemented yet in browsers or node. For now, you can just use const x = require('y'). If you want to use the import/export syntax, you will need to use something like babel which converts your next-gen JS code into code that can run.
I'm using the Check package to validate parameters passed to Meteor methods. And I'm using Audit argument checks to enforce this.
However, I've added another package, Meteor Tags and when I try to use methods from the Tags package, I get a server error "Exception while invoking method '/patterns/addTag' Error: Did not check() all arguments during call to '/patterns/addTag'".
I think I understand why this error happens - the method in the Tags package doesn't check its inputs, so Audit Argument Checks generates an error. But I can't find any way around this, apart from 1) don't enforce checking, or 2) hack the Tags package methods so they use check. Neither of these seems like a great option - checking server parameters is a good idea, and hacking a package is not very maintainable.
Does anybody know if there is any smart way to use 'Audit argument checks' with packages that provide new server methods? I have looked at the Check documents, and searched online, but I haven't found an answer.
I hope this question makes sense.
Using audit-argument-checks is like saying: "I want to be serious about the security of the methods in my app." It's global to all methods in your app's codebase, including the methods from your installed packages.
There is no way to specify which parts of the app get checked, as that would be the equivalent of saying: "I want to be serious about the security of the methods I've written, but I don't care about the security holes created by some pacakges" (which doesn't make a lot of sense).
Note to package authors
Check your method arguments. It's not hard, and it prevents this situation from happening. Frankly, a package without this basic security really shouldn't be installed in the first place.
What you should do
Unless you have a throwaway app, I wouldn't recommend removing audit-argument-checks. Instead I'd do the following (assuming the package really has something of value):
Open an issue on github and let the maintainer know what's up.
Fork the code, and add the required checks. Keep this version as a local package.
Submit a pull request for the changes.
If all goes well, your PR will be accepted and everyone can benefit from the change. In the worst case, you'll still have a local copy that you can use in your app.
is there a way to get the prefix name of a managed package in apex?
I have a SOSL query but the app is in a developer org and in a managed package, if I have a way to get the package name, it would be great, because I don't have to hard code it.
Thanks.
The only way to do this, AFAIK, is to use the Metadata API. You can call describeMetadata() and then evaluate the organizationNamespace (String) value returned in describeMetadataResult.
From within Apex you could do a less elegant try/catch approach with dynamic SOQL/DML, at least to determine if something you suspect is there is actually there. Though this won't tell you what namespace prefix actually IS there like the Metadata API will.
Lacey is correct that you don't need the prefix, though name ambiguity can become a problem. So for example, if you have a custom object Expense__c and have installed an accounting package which includes ACCT__Expense__c, you definitely want to explicitly include the ACCT__ prefix if intending to access the managed package object as opposed to your own.
The UserInfo.isCurrentUserLicensed('nsPrefix') will throw a TypeException if the namespace passed in is not a valid namespace of an installed package (or managed package you're developing). I think this is the closest you're going to get without the metadata API.
just wondering what the best approach is for using eventemitter throughout multiple exports without the modules becoming too coupled with each other.
for instance i have module foo which deals with requests, now to break up the code I have a separate module (bar) which performs an action when a specific request comes in. I want to use an eventemitter for this.
any help is appreciated.
thanks.
Well if you want to use it across different modules you either send it as a function param everywhere or set it as a global variable (not recommended).