machinabio / limbforge-service

Single-purpose microservice to generate STLs from parametric CAD designs.
Apache License 2.0
3 stars 1 forks source link

Normalize the URL QueryString inputs #8

Open kaitlynhova opened 7 years ago

kaitlynhova commented 7 years ago

We need to write a function an object with the values from a given URL QueryString.

Given this:

/preview?component={"id":"idComp1","handedness":"l","c1":"2.0001", "C2": "18" }&component={"id":"idComp2","HandEdness":":L", "c1":"12.0"}&component={"id":"idComp4","c1":"999999"}&component={"NO_ID_FIELD":"idComp4","c1":"12"}

We need to return an array of objects

[
  { id: "idcomp1", handedness: "l", c1: "2.0", c2: "18.0" },
  { id: "idcomp2", handedness: "l", c1: "12.0" },
  { id: "idcomp3", c1: "18.0" },
]

So we have to:

  1. force all text to lowercase.
  2. ignore any components that don't have an "id" parameter.
  3. Limit the parameter values to a configurable min/max.
  4. Round values to the nearest configurable increment.
  5. Make sure all of the numbers are have exactly 1 digit after the decimal place
  6. All numbers should be stored as Numbers, not Strings
matthova commented 7 years ago

For reference: https://github.com/machinabio/limbforge-service/blob/master/imports/routes/api/preview.js#L37