How to use DocuementReference with class-transformer? - node.js

I'm using ClassSerializerInterceptor in my NestJS application to apply instanceToPlain when I return objects on incoming requests. I also use firestore as my main database. Some of my entities contains DocumentReference which I want to directly return without applying every time #Transform on it. When I do so, I got following error in my console:
ERROR [ExceptionsHandler] Value for argument "documentPath" is not a
valid resource path. Path must be a non-empty string. Error: Value for
argument "documentPath" is not a valid resource path. Path must be a
non-empty string.
I was trying to fix this by myself and found package class-transformer-firestore which seems to be potential solution, but it use prototype and have no readme at all, so I have no idea how to use it. I tried just to install it with no success.
Maybe someone faced the same issue and have solution to this.

Please check original repo again, seems like author updated it 👌🏻

Related

While working on Robot framework , encountered an Import error message when attempting to add Resource in Setting Section?

In Robot Framework , I have segregated the details into Page objects, keywords and scripts.
After adding keywords in PO, I wanted to add details in Keywords. Here, in Settings section while I give the following details:
*** Settings ***
Library SeleniumLibrary
Resource Resources/PO/Sign-in.robot
I even tried using absolute path by referencing ../ at the beginning. Still, system is unable to recognize it and throwing an error message "Import File Not Found".
What Should I be doing? Please, let me know?
First, you show in the screenshot, the use of a variable ${Resources}, it would be normal for the IDE to not recognize that value for a path. Even so, running the test case may work as expected.
Second, if you want to use the relative path, then the correct value should be:
Resource ../PO/Sign-in.robot

How to fix 'Error: Enum value' in strapi content type?

I'm creating a new content type in Strapi, and I set a duplicate enum value in a type called Promotion. first value is 'fixed discount' second value is 'percentage discount'.
this error has frozen my local installation, and I don't know how fix this issue. Any help in directing me to the proper resource where I might find the answer to fix this? This is my first time working with database, content types or code in general, so any help would be appreciated.
I've tried looking in the strapi Github threads, but my problem doesn't seem to be answered in a way that I understand. This is a local installation on my new Mac, which is running Node and NPM, and all the Strapi plugins are activated
I'm receiving an error message that reads:
[2019-08-07T22:47:48.212Z] debug ⛔️ Server wasn't able to start properly.
[2019-08-07T22:47:48.213Z] error Error: Enum value "ENUM_PROMOTION_TYPE.discount" can only be defined once.
I would like to be able to start strapi and fix the error, or at least avoid this in the future
it seems like if you uninstall GraphQL, and run 'strapi build' it removes the dependancies and resets the database without the error.
You don't have to use spaces un an enum value.
The correct usage is to set "keys" that match displayed string in your front end application.
You don't have to set the value you will display.
So for example:
fixed as enum value has to match Fixed discount in your front end application
percentage as enum value has to match Percentage discount
We fixed it in develop branch (for the next release) to allow only ^[A-Za-z][_0-9A-Za-z]*$

CS50 Pset7 Finance

I have question for my CS50 Pset7 finance project. I don't know where to ask this question, so I seek help here. I just finished the register part, however, when I try to test the website, I registered successfully, however, when I try to log in, I got a strange error which I think is because of my way of using hash is not correct. So I got the error TypeError: invalid method '' for security.py", line 186, in _hash_internal, and I can see my hash value like $6$rounds=656000$OiBqI/lX2GqhI8be$G. I found in the API that the schema support has been removed. I'm wondering how should I use hash method other than pwd_context.hash(request.form.get("password")). Any advice will be appreciated.
Use generate_password_hash() to replace hash() will work. Don't forget to remove or update the existing entries inside your db since the old hash will cause error.

"$ ./propellor --list-fields" yields "propellor: Prelude.read: no parse"

I am trying to specify a private field using Haskell's Propellor deployment library.
As context: the field in question is a file whose content I want to encrypt and have propellor place on the destination server during deployment. However, I haven't gotten nearly that far; before even attempting to set the field, I have run into an error while attempting to simply view propellor's current private fields.
Specifically, when I run the command to view fields, $ ./propellor --list-fields, it asks for my gpg key, prints some gpg key information, and then the following:
Currently set data:
Field Context Used by
----- ------- -------
propellor: Prelude.read: no parse
There should be some fields present which were set previously, but somehow they are not displayed here and instead I get only the propellor: Prelude.read: no parse error message. I have not yet attempted to add my own field.
It seems that propellor is having an issue trying to parse something, but I do not know what that could be. I realize this is not a lot to go on but am not sure what else to do. Has anyone run into a similar error with Haskell's propellor before or know what the issue could be?
Your self-answer is correct; here I will just look at the issue in a different light.
The error you got points to the read function in Prelude. read is an example of a partial function: its type...
read :: Read a => String -> a
... says that it can convert Strings into a value of any type a with a Read instance; however, we known that this does not work for all Strings, as the parsing might fail. To put it more dramatically, the type of read is a lie.
It is generally a good idea to avoid partial functions, not only because more often than not they are bugs waiting to happen (e.g. you assume the parse will never fail due to some precondition in your business logic, and then the precondition changes), but also because they tend to give extremely uninformative error messages (as you just noticed). In the case of read, for instance, a nicer alternative is readMaybe, which returns Nothing if the parsing fails. That gives an opportunity to react to the failure. In dfferent situations you might, for instance, find it appropriate to ask the user to retry, supply a default value or, if there is no other recourse, terminate the program with an error message that explains what went wrong in terms of what you are trying to do.
Sorry this question was so vague, but there was very little to go on from the error message. The issue is now resolved and here is an explanation in case it is helpful to anyone who comes across it while facing a similar error.
The code contained an instance of a configuration data type defined not in a module, but in a text file being read in via the Read class. In short, the issue was that I had altered the data type without comprehensively updating the text-defined configuration instance to accomodate the type change.
In the long-form version of the explanation the issue is sneakier, involving merging the data type change over a change to the text-configuration which was not recognized as in conflict due to no line conflicts.
But essentially the error was failure to read in a data type instance defined in text-form.
I have plans to define the configuration data instance in a module rather than reading it in from text, which should be caught by the compiler and give a more meaningful error message should a similar error arise.

Using should.js how can I test for an empty object?

user1Stats.should.be.instanceof(Object);
(user1Stats).should.have.keys();
I get the following error:
Error: keys required
at Object.Assertion.keys
The instanceof(Object) works, but I want to make sure there is no data in it.
user1Stats.should.be.an.Object();
user1Stats.should.be.empty();
or, using .and to chain both asserts:
user1Stats.should.be.an.Object().and.be.empty();
P.S. By the way, your code also looks fine.
I check for the variable not being empty by using "should" this way:
user1Stats.should.be.empty();

Resources