JSPM

ltijs-postgresql

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q28386F
  • License Apache-2.0

Plugin for ltijs to use postgresql instead of mongodb

Package Exports

  • ltijs-postgresql

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ltijs-postgresql) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme



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