GT2/GT2-iOS/node_modules/rest-facade/package.json

109 lines
11 KiB
JSON

{
"_args": [
[
{
"raw": "rest-facade@^1.10.0",
"scope": null,
"escapedName": "rest-facade",
"name": "rest-facade",
"rawSpec": "^1.10.0",
"spec": ">=1.10.0 <2.0.0",
"type": "range"
},
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/auth0"
]
],
"_from": "rest-facade@>=1.10.0 <2.0.0",
"_id": "rest-facade@1.10.1",
"_inCache": true,
"_location": "/rest-facade",
"_nodeVersion": "8.4.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/rest-facade-1.10.1.tgz_1509764117424_0.3721047551371157"
},
"_npmUser": {
"name": "ngonzalvez",
"email": "n.gonzalvez@outlook.com"
},
"_npmVersion": "5.3.0",
"_phantomChildren": {},
"_requested": {
"raw": "rest-facade@^1.10.0",
"scope": null,
"escapedName": "rest-facade",
"name": "rest-facade",
"rawSpec": "^1.10.0",
"spec": ">=1.10.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/auth0"
],
"_resolved": "https://registry.npmjs.org/rest-facade/-/rest-facade-1.10.1.tgz",
"_shasum": "a9b030ff50df28c9ea1a2719f94e369c47167d20",
"_shrinkwrap": null,
"_spec": "rest-facade@^1.10.0",
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/auth0",
"author": {
"name": "Nicolás Gonzálvez"
},
"bugs": {
"url": "https://github.com/ngonzalvez/rest-facade/issues"
},
"dependencies": {
"bluebird": "^2.10.2",
"change-case": "^2.3.0",
"deepmerge": "^1.5.1",
"superagent": "^3.8.0",
"superagent-proxy": "^1.0.2"
},
"description": "Simple abstraction for consuming REST API endpoints",
"devDependencies": {
"chai": "^3.4.0",
"coveralls": "^2.11.4",
"mocha": "^2.3.3",
"mocha-lcov-reporter": "^1.0.0",
"nock": "^2.15.0",
"sinon": "^1.17.2"
},
"directories": {
"doc": "docs",
"test": "tests"
},
"dist": {
"integrity": "sha512-MYHUAxNQYkD/ejvQX1CY8pvPseKX5G4dWDRNv1OFNBxn4b063rvDyqpWkjdtP8QouhtAcf91HIUrBdPq08puiA==",
"shasum": "a9b030ff50df28c9ea1a2719f94e369c47167d20",
"tarball": "https://registry.npmjs.org/rest-facade/-/rest-facade-1.10.1.tgz"
},
"gitHead": "d92ee3a2af9e128379e64ec60e3ea96c5c1a90da",
"homepage": "https://github.com/ngonzalvez/rest-facade#readme",
"keywords": [
"facade",
"rest",
"api"
],
"license": "MIT",
"main": "src/index.js",
"maintainers": [
{
"name": "ngonzalvez",
"email": "n.gonzalvez@outlook.com"
}
],
"name": "rest-facade",
"optionalDependencies": {},
"readme": "# rest-facade [![Build Status](https://travis-ci.org/ngonzalvez/rest-facade.svg?branch=master)](https://travis-ci.org/ngonzalvez/rest-facade)\n\nNode.js module that abstracts the process of consuming a REST endpoint.\n\n\n## Installation\n\n npm install rest-facade\n\n\n## Usage\n\n### Create a new endpoint client\n\nWhen creating a new client, a URL must be given as first arguments. If the URL have dynamic params, those variable params must be marked with the colon notation, as shown below.\n\n~~~js\nvar rest = require('rest-facade');\nvar options = {\n headers: {\n Authorization: 'Bearer token'\n },\n errorFormatter: {\n name: 'error.title',\n message: 'error.text',\n }\n};\n\nvar Users = new rest.Client('http://domain.com/users/:id', options);\n\n// The URL can have several dynamic params.\nvar UserVideos = new rest.Client('http://domain.com/users/:userId/videos/:slug');\n~~~\n\n\n### Get all instances from the API\nThe `getAll()` method can take an optional object as first parameters specifying the URL params. Considering the UserVideos model from last example:\n\n~~~js\n// Retrieve all videos from the user with ID 4.\n// This will resolve to a \"GET http://domain.com/users/4/videos\" request.\nUserVideos\n .getAll({ userId: 4 })\n .then(function (videos) {\n console.log(videos.length, 'videos retrieved');\n });\n~~~\n\n\n### Get one instance from the API.\n~~~js\n// Retrieve the user with ID 4.\nUsers\n .get({ id: 4 })\n .then(function (user) {\n console.log(user);\n });\n~~~\n\n\n### Create a new instance and save it to the API\nThe create method can be called using several signatures.\n\n- `create(data)` returns a Promise.\n- `create(urlParams, data)` returns a Promise.\n- `create(data, callback)` doesn't return a promise.\n- `create(urlParams, data, callback)` doesn't return a promise.\n\n~~~js\nUsers\n .create({ firstName: 'John', lastName: 'Doe' });\n .then(function (user) {\n console.log('User created');\n });\n\nUserVideos\n .create({ userId: 4 }, { title: 'Learning Javascript', slug: 'learn-javascript' })\n .then(function (video) {\n console.log('User video created');\n }):\n~~~\n\n\n### Delete an instance from the API by ID\nAs it was the case with the `create()` method, `delete()` can also be called with different signatures.\n\n- `delete(urlParams)` returns a Promise.\n- `delete(callback)` returns a Promise.\n- `delete(urlParams, callback)` doesn't return a Promise.\n\n~~~js\nUsers\n .delete({ id: userId })\n .then(function () {\n console.log('User deleted');\n });\n\n// This will resolve to: DELETE http://domain.com/users/videos/learn-javascript\nUserVideos\n .delete({ slug: 'learn-javascript' })\n .then(function () {\n // ...\n });\n~~~\n\n\n### Update an instance.\n\nThere are 2 ways to update data, if you are using correctly the HTTP methods, 1 is PUT and the other one is PATCH, rest-facade supports both of them:`Client.update` and `Client.patch`.\n\nAs with the previous methods, an object with the URL parameters must be provided as first argument. The second argument must be an object with the new data.\n\n#### PUT request\n~~~js\nUsers\n .update({ id: userId }, data)\n .then(function () {\n console.log('User updated');\n });\n~~~\n\nor\n\n~~~js\nUsers\n .put({ id: userId }, data)\n .then(function () {\n console.log('User updated');\n });\n~~~\n\n#### PATCH request\n\n~~~js\nUsers\n .patch({ id: userId }, data)\n .then(function () {\n console.log('User updated');\n });\n~~~\n\nBoth functions work exactly the same, the only difference is the method used to perform the request.\n\n### Plain HTTP requests\nIn case you don't want to use the all the fancy abstractions (`create`, `update`, `delete`, `getAll`) you can also send plain HTTP requests using the HTTP method function.\n\n\n~~~js\n// GET request.\nUsers.get(qsParams[, cb]);\n\n// POST request.\nUsers.post(qsParams, data[, cb]);\n\n// PUT request.\nUsers.put(qsParams, data[, cb]);\n\n// PATCH request.\nUsers.patch(qsParams, data[, cb]);\n\n// DELETE request.\nUsers.delete(qsParams[, data, cb]);\n~~~\n\n\n### Callbacks\n\nAll methods support callbacks. However, if a callback function is given no promise will be returned. Callbacks must always be provided after all other function arguments. E.g.:\n\n~~~js\nUsers.getAll(function (err, users) {\n console.log(users.length, 'users found');\n});\n~~~\n\n\n### Response headers\n\n~~~js\nUsers.getAll(function (err, body, headers) {\n // ...\n});\n\n\nUsers\n .getAll()\n .then(function (body, headers) {\n // ...\n })\n .catch(function (err) {\n // ...\n });\n~~~\n\n### Query String\n\nAll methods accept an object with URL params as first argument. The properties in this object will be used to format the URL as shown above. However, the properties defined in this object, but not in the endpoint URL, will be added as query string params.\n\n> N.B. any properties in a given `options` object whose values are Functions will be ignored with regard to generating the query string.\n\n~~~js\nvar Users = new rest.Client('http://domain.com/users/:id');\n\nUsers.get({ id: 1 }); // Resolves to http://domain.com/users/1\nUsers.getAll({ page: 1, pageSize: 10 }); // Resolves to http://domain.com/users?page=1&pageSize=10\n~~~\n\nThere may be some cases when you are working with an API that follows a different naming convention, and it is not really clean to have mixed naming conventions in our code.\n\n~~~js\n// Not good.\nUsers.getAll({ page: 1, 'page_size': 10 });\n~~~\n\nYou can solve this problem by specifing a naming convention when creating the Rest Client. The naming convention can be any of `snakeCase`, `camelCase`, `pascalCase`, `paramCase`, or any other implemented by the [change-case](https://github.com/blakeembrey/change-case) library.\n\n~~~js\nvar Users = rest.Client('http://domain.com/users/:id', { query: { convertCase: 'snakeCase' }});\n\nUsers.getAll({ page: 1, pageSize: 10 }); // Will resolve to http://domain.com/users?page=1&page_size=10\n~~~\n\n#### Arrays\nBy default, arrays in the querystring will be formmated this way: `?a=1&a=2&a=2`. However, you can change it to comma separated values `?a=1,2,3` by setting the `query.repeatParams` option to `false`.\n\n~~~js\nvar client = new rest.Client(url, { query: { repeatParams: false }});\n~~~\n\n\n### Body Case Conversion\nRest-facade provides options for converting the body of the request/response. So, let's say you are consuming an API implemented in Python (using snake_case) and you want it converted to camelCase. You would specify the following options:\n\n~~~js\nvar client = new rest.Client(url, {\n request: {\n body: {\n convertCase: 'snakeCase'\n }\n },\n response: {\n body: {\n convertCase: 'camelCase'\n }\n }\n});\n~~~\n\nOnce that's done, you can send any request and the body of it will be converted to snake_case. E.g.\n\n~~~js\nclient.create({ firstName: 'John', lastName: 'Doe' });\n\n// The server will receive\n// { first_name: 'John', last_name: 'Doe' }\n~~~\n\nThe same way, all the responses from the server will converted to the specified case (camelCase in this example).\n\n### Per-Request Customization\nSometimes you need to do some customization to each individual request that is sent to the consumed API,\na likely candidate is for adding request-specific headers.\n\nThis can be done in two ways:\n\n- defining a function in global options under `options.request.customizer`\n- passing in a options object to a method call that contains a \"special\" `_requestCustomizer` property (which should be a function as well!)\n\nYou can define both, in which case both will be applied (in the order listed above).\n\nIn each case the function is passed the `req` and `params` representing the API call in question.\n\n### Proxy support\n\nIf a proxy URI is provided, **all** requests will be sent through that proxy.\n\n```js\n// Rest client that sends all requests through a proxy server.\nvar client = new rest.Client(url, {\n proxy: 'https://myproxy.com:1234'\n});\n```\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/ngonzalvez/rest-facade.git"
},
"scripts": {
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec $(find ./tests -name *.tests.js) && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"test": "mocha $(find ./tests -name *.tests.js) --opts mocha.opts",
"test-watch": "mocha $(find ./tests -name *.tests.js) --opts mocha.opts --watch"
},
"version": "1.10.1"
}