Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.
/ ltijs-postgres Public archive

Plugin for Ltijs to allow using PostgreSQL instead of the default Mongodb

License

Notifications You must be signed in to change notification settings

Cvmcosta/ltijs-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



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

About

Plugin for Ltijs to allow using PostgreSQL instead of the default Mongodb

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •