GithubHelp home page GithubHelp logo

orcaman / node-swagger-salesforce Goto Github PK

View Code? Open in Web Editor NEW
19.0 8.0 4.0 8 KB

auto generate a node/express swagger CRUD API for your Salesforce

License: MIT License

JavaScript 100.00%
salesforce salesforce-rest-api swagger nodejs express es6

node-swagger-salesforce's Introduction

node-swagger-salesforce

swagger screenshot

node-swagger-salesforce may be used to easily and automatically create a REST API containning CRUD operations covering Salesforce entities. The generator connects to your Salesforce instance (for example, your sandbox environment) using credentials supplied as env vars and proceeds to automatically generate an entire swagger project (controllers, configuration, etc.) over an express.js API server.

You can choose to auto generate controllers for all your Salesforce entities, or you can configure a white or a black list of entities.

Read more about swagger here and here.

motivation

  • Get swagger goodness over the plain old Salesforce REST API - declarative coding, documentation, API playground, etc.
  • Be able to manipulate Salesforce API results using node (express middlewares and more)
  • The vanilla Salesforce REST API is designed for client apps, not server integrations (it only offers OAuth authentication). Projects created with node-swagger-salesforce may be easily used for server integrations simply by supplying users credentials (no need to work with the OAuth endpoint).
  • The result project may be deployed to a PaaS like Heroku with just a few clicks

usage

  1. Install swagger for node
$ npm install -g swagger
  1. Get the project and install it's dependancies
$ git clone https://github.com/skyline-ai/node-swagger-salesforce.git
$ cd node-swagger-salesforce && npm install
  1. Build the project (this will run the gulpfile)
$ npm run build
  1. Set required env vars - credentials for Salesforce (mandatory) and login URL (this value is optional, the value https://test.salesforce.com should be used in order to connect to sandbox envs). see configuration section for more available config options
# for example: [email protected]
$ export SF_USER=your Salesforce username
$ export SF_PASSWORD=your Salesforce password
# if you don't know what your token is, you can **RESET** it by following this link:
# https://YOUR_SALES_FORCE_DOMAIN/_ui/system/security/ResetApiTokenConfirm?retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DPersonalInfo&setupid=ResetApiToken
$ export SF_TOKEN=your sales force security token
# optional: connect to sandbox env
$ export SF_LOGIN_URL=https://test.salesforce.com
  1. Finally, generated your swagger project and run it. The project uses es6 syntax and therefore needs to be transpiled in order for node to run it (at the time of this post the latest dev version of node still doesn't support things like es6 import). By default, the babel configuration will create an output at dist directory. The output is the generator in es5 code that node can run. This is the actual generator code that you need to run in order to create the final swagger project. By default the dist node app will create your new swagger project at the out directory under dist.
$ cd dist && node app.js
$ cd out && npm install
$ swagger project start

To edit your swagger project:

$ swagger project edit

optional: using white-lists or black-lists

If you want the generator to only create controllers for specific entities, use a white list. Configure the location of the list as the env var SF_WL_PATH:

$ export SF_WL_PATH=../lists/wl.txt

If you want the generator to dismiss specific entities and create controllers for the rest, use a black list. Configure the location of the list as the env var SF_BL_PATH:

$ export SF_BL_PATH=../lists/bl.txt

The list should be a UTF-8 text file where every line contains the name of the entity in lower case. For example, the following list is set to tell the generator to only create a controller for the account entity:

$ cat lists/wl.txt 
account

TODO

  • tests converage
  • auto generate tests for the controllers
  • work with Salesforce API to extract mandatory fields and make them mandatory in the swagger api level
  • add API key style auth by default
  • add Heroku deployment examples

node-swagger-salesforce's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.