Forcifier Node.js Package for Force.com

I just published a port of my Forcifier Ruby gem to Node.js. You can find the package on npm and the source on github.

So why should you use forcifier for your Node.js application? Well, if you are using the awesome nforce package, forcifier can make your life much easier.

Forcifier provides utility functions for dealing with Force.com fields to make them pretty and easier to work with. Since Force.com is case insensitive, REST calls may return JSON with keys such as Country_code_AND_City__c. The forcifier package will convert JSON keys and list of fields into something like country_code_and_city which makes life much easier when writing applications in Node.js.

For example, it "deforces" JSON keys from Force.com so that all keys will be lowercase and will have __c removed. For example, the following JSON returned by nforce will look like:

{
 "totalSize": 2,
 "done": true,
 "records": [
  {
 "attributes": {
  "type": "Account",
  "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
 },
 "Id": "001K000000f9XMDIA2",
 "Name": "ACME Corp Ltd.",
 "Logo__c": "logo-big.jpg"
  },
  {
 "attributes": {
  "type": "Account",
  "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
 },
 "Id": "001K000000f8R8aIAE",
 "Name": "XYZ Corp",
 "Logo__c": "logo.png"
  }
 ]
}

Calling forcifier.deforceJson() on the payload above will remove the trailing __c from all keys and change them to lowercase. The resulting JSON will look like:

{
 "totalsize": 2,
 "done": true,
 "records": {
  "0": {
 "attributes": {
  "type": "Account",
  "url": "/services/data/v27.0/sobjects/Account/001K000000f9XMDIA2"
 },
 "id": "001K000000f9XMDIA2",
 "name": "ACME Corp Ltd.",
 "logo": "logo-big.jpg"
  },
  "1": {
 "attributes": {
  "type": "Account",
  "url": "/services/data/v27.0/sobjects/Account/001K000000f8R8aIAE"
 },
 "id": "001K000000f8R8aIAE",
 "name": "XYZ Corp",
 "logo": "logo.png"
  }
 }
}

There are also methods for adding __c to keys in JSON plus the same type of functionality for dealing with list of fields. Check it out and see if it makes your next Node.js application with Force.com a more enjoyable experience.