node-sharepoint-rest
Version:
On Premise SharePoint 2013 REST API wrapper. Requires basic auth to be enabled on SharePoint
54 lines (40 loc) • 1.48 kB
text/coffeescript
SuperClass = require './SuperClass'
UserProfiles = require './UserProfiles'
CustomLists = require './CustomLists'
class SharePoint extends SuperClass
UserProfiles
CustomLists
constructor: ()->
UserProfiles.call @
CustomLists.call @
if !
throw new Error("settings object is required for instance creation")
else
if !.strictSSL
.strictSSL = false
= require 'request'
= .username || undefined
= .password || undefined
= .url || undefined
if typeof is "undefined" || typeof is "undefined" || typeof is "undefined"
throw new Error("settings object requires username, password, and url for instance creation")
log: (msg)->
console.log msg
setSiteUrl: ()->
'setting site url to: ' +
return @
getContext: (app, cb)->
processRequest = (err, res, body)->
if !body || !JSON.parse(body).d
console.log "no list of title: #{app}"
else
cb(err, JSON.parse(body).d.GetContextWebInformation.FormDigestValue)
config =
headers :
Accept: "application/json;odata=verbose"
strictSSL: .strictSSL
url : "#{@url}/#{app}/_api/contextinfo"
.post(config, processRequest).auth(, , true)
return @
module.exports = SharePoint