Skip to content

Commit

Permalink
Readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
s-KaiNet committed Oct 5, 2016
1 parent 7850fc2 commit ecc536b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
[![Coverage Status](https://coveralls.io/repos/github/s-KaiNet/sp-request/badge.svg?branch=master)](https://coveralls.io/github/s-KaiNet/sp-request?branch=master)
[![npm version](https://badge.fury.io/js/sp-request.svg)](https://badge.fury.io/js/sp-request)

`sp-request` based on [request](https://github.com/request/request) module and its promise implementation [request-promise](https://github.com/request/request-promise). You can send REST queries to SharePoint (works with both on-prem and online) using well-known `request` syntax with the same params that `request` supports, and `sp-request` takes care about authenticating you inside SharePoint. With help of `request-promise` and `bluebird`, responses implemented using modern promise-style approach.
`sp-request` based on [request-promise](https://github.com/request/request-promise) (promise-aware implementation of [request](https://github.com/request/request)) and [node-sp-auth](https://github.com/s-KaiNet/node-sp-auth) modules. `node-sp-auth` implements different authentication options for unattended SharePoint authentication from nodejs. You can send REST queries to SharePoint (works with both on-prem and online) using well-known `request` syntax with the same params that `request` supports, and `sp-request` (with help of `node-sp-auth`) takes care about authenticating you inside SharePoint. Responses implemented using modern promise-style approach.

Versions supported:
* SharePoint 2013, 2016
* SharePoint Online

---

Expand All @@ -20,7 +24,7 @@ typings install npm:sp-request --save
```
#### Create sprequest function:
```javascript
var spr = require('sp-request').create({username: 'user', password: 'pass'});
var spr = require('sp-request').create(credentialOptions);
```
###### Get list by title:
```javascript
Expand Down Expand Up @@ -63,22 +67,19 @@ spr.requestDigest('http://sp2013dev/sites/dev')
... as simple as that! A bit more samples you can find under [integration tests](https://github.com/s-KaiNet/sp-request/blob/master/test/integration/integration.spec.ts)

## API:
### [main sp-request export].create(credentials, environment):
- **_credentials_:** required, object containing user credentials:
- _username_ - required string
- _password_ - required string
- **_environment_**: optional, used when you want to send requests to on-premise SharePoint (when using `environment` option either `domain` or `workstation` option should be provided, when nothing is provided as `environment` for on-premise, local user will be used (not domain), it's better to always provide `environment` option explicitly):
- _domain_ - optional string
- _workstation_ - optional string

Call to `require('sp-request').create({username: 'user', password: 'pass'})` returns sprequest function with predefined username and password. You can use this function later to send REST queries (like in samples above) without specifying credentials again.
### [main sp-request export].create(credentialOptions):
- **_credentialOptions_:** required, object containing credentials.
Since version 2.x `sp-request` relies on `node-sp-auth` module for authentication. You can find description for `credentialOptions` under [node-sp-auth](https://github.com/s-KaiNet/node-sp-auth#params).

Call to `require('sp-request').create(credentialOption)` returns sprequest function with predefined authentication. You can use this function later to send REST queries (like in samples above) without specifying credentials again.
### sprequest(options):
- **_options_**: required, settings object for `request` module. For all available values refer to the original [request docs](https://github.com/request/request#requestoptions-callback)

By default `sp-request` sets following params for `request`:
```
{
json: true,
strictSSL: false, /* bypassing SSL validation errors */
headers: {
'Accept': 'application/json;odata=verbose',
'Content-Type': 'application/json;odata=verbose'
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
export * from './core/SPRequest';
export * from './core/ISPRequest';
export {
IAuthOptions,
IOnlineAddinCredentials,
IOnPremiseAddinCredentials,
IOnpremiseUserCredentials,
IUserCredentials,
IBasicOAuthOption
} from 'node-sp-auth';

0 comments on commit ecc536b

Please sign in to comment.