This module provides classes which can facilitate access to the Blue Trunk API, and manage some of the complexities involved in using the API.
Documentation for the Blue Trunk API can be found here.
npm install --save blue-trunk-commons
import { LoginService } from 'blue-trunk-commons'
...
let loginService = new LoginService(/*Hostname, or blank for default*/)
loginService.login(
myUser,
(response) => {
response.then(returnedUser => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
loginService.register(
newUser,
(response) => {
response.then(newlyRegisteredUser => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
loginService.getRecoveryCode(
myEmail,
(response) => {
response.then(recovery => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
loginService.useRecoveryCode(
myEmail,
newPassword,
recoveryCode,
(response) => {
response.then(user => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
import { PostService } from 'blue-trunk-commons';
...
var postService = new PostService()
The "after" is a Date object, and this call returns all posts after this date. For example, an after value of Dec. 25 would return all posts from Dec. 24, Dec. 23 etc. until there are no more posts or until the count has been reached.
postService.getPostsAfter(
authorId,
numberOfPostsToFetch,
after,
(response) => {
response.then(user => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
The tests for this module require a functioning instance of the BlueTrunk API
running locally. Setting up and tearing down this test instance of the API is
handled automatically by test.sh
.
To use this script, run either of the following commands:
sh test.sh
--OR--
node run test