Skip to content

Latest commit

 

History

History
133 lines (84 loc) · 3.67 KB

README.md

File metadata and controls

133 lines (84 loc) · 3.67 KB


LTIJS postgreSQL plugin.

travisci codecov Node Version NPM package NPM downloads dependencies Status devDependencies Status JavaScript Style Guide APACHE2 License Donate

Table of Contents


Introduction

This package allows LTIJS to work with the postgreSQL database.


Installation

$ npm install ltijs-postgres

Usage

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()

Contributing

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.

Donate


License

APACHE2 License