Common functionality for Blue Trunk frontends
npm install blue-trunk-commonsbash
npm install --save blue-trunk-commons
`
Usage
$3
#### Setup
`js
import { LoginService } from 'blue-trunk-commons'
...
let loginService = new LoginService(/Hostname, or blank for default/)
`
#### Login As User
`js
loginService.login(
myUser,
(response) => {
response.then(returnedUser => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
`
#### Register
`js
loginService.register(
newUser,
(response) => {
response.then(newlyRegisteredUser => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
`
#### Get Recovery Code
`js
loginService.getRecoveryCode(
myEmail,
(response) => {
response.then(recovery => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
`
#### Use Recovery Code
`js
loginService.useRecoveryCode(
myEmail,
newPassword,
recoveryCode,
(response) => {
response.then(user => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
`
$3
#### Setup
`js
import { PostService } from 'blue-trunk-commons';
...
var postService = new PostService()
`
#### Get Posts (One Page)
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.
`js
postService.getPostsAfter(
authorId,
numberOfPostsToFetch,
after,
(response) => {
response.then(user => {
...
})
},
(response) => {
reponse.then(failedResponse => {
...
})
}
)
`
Testing
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:
`shell script
sh test.sh
--OR--
node run test
``