LTIJS postgreSQL plugin.
This package allows LTIJS to work with the postgreSQL database.
$ npm install ltijs-postgres
Install PostgreSQL
Instantiate and use plugin
// Require Provider
const LTI = require('ltijs').Provider
const Database = require('ltijs-postgres')
// Instantiate and configure plugin
const db = new Database({
database: 'databaseName', // Database name. Ex: lti_database
user: 'databaseUser', // Database username. Ex: user
pass: 'databasePass', // Database password. Ex: password
host: 'databaseHost' // Database host. Ex: localhost
})
// Configure provider and the Database
const lti = new LTI('EXAMPLEKEY',
{ plugin: db }, // You set the plugin option as the instance of the Postgres Database Class
{ appUrl: '/', loginUrl: '/login', logger: true })
let setup = async () => {
// Deploy and open connection to the database
await lti.deploy()
// Register platform
let plat = await lti.registerPlatform({
url: 'https://platform.url',
name: 'Platform Name',
clientId: 'TOOLCLIENTID',
authenticationEndpoint: 'https://platform.url/auth',
accesstokenEndpoint: 'https://platform.url/token',
authConfig: { method: 'JWK_SET', key: 'https://platform.url/keyset' }
})
// Set connection callback
lti.onConnect((connection, request, response) => {
// Call redirect function
lti.redirect(response, '/main')
})
// Set main route
lti.app.get('/main', (req, res) => {
// Id token
console.log(res.locals.token)
res.send('It\'s alive!')
})
}
setup()
If you find a bug or think that something is hard to understand feel free to open an issue or contact me on twitter @cvmcosta, pull requests are also welcome :)
And if you feel like it, you can donate any amount of money through paypal, it helps a lot.