echoes-xyz / mongoose-geojson-schema

Schema definitions for GeoJSON types for use with Mongoose JS
MIT License
79 stars 25 forks source link

The cast function doesn't take JSON into consideration #21

Closed ryankauk closed 7 years ago

ryankauk commented 7 years ago

I am using mongoose 4.11.6 express 4.15.4 node 8.2.1

Everything seems great, however when I make a post request which is delivering JSON it comes up with error because it's not parsing the JSON.

I have cloned the repo and made some changes to account for this. Do you have any contributing guidelines to follow? Should I checkout a new branch and request a pull?

markstos commented 7 years ago

Could you link to your changes?

It's my understanding that the decision to parse the JSON is not is made by Express, based on the Content-Type that the request was sent with. So, sending a Content-Type header of application/json would cause the body to be parsed as JSON, but sending the body with aContent-Typeheader oftext/plain` would not cause the JSON parser to be invoked.

If that's the issue, this module is the wrong place to deal with the issue.

ryankauk commented 7 years ago

You are right I just realized my mistake. I was using form-urlencoded which was obviously turning the input with the object into a string and passing it to geojson. My apologies. I've attached the file anyways, maybe you'll still want to take some ideas.

mongoose-geojson-schema.zip