Deployment

Custom

In production you should provide certain properties:

  • Config.graphiql: desactivate the development IDE by setting this property to false.

  • Config.nodemailerConfig: provide a nodemailer configuration to send real emails to your users.

  • Config.mailFrom: Define the sender address displayed in emails sent to users.

  • Config.host: Public URL of the service. It will be used in emails sent to users to define for instance valid confirmation link.

  • Config.dbAddress: Define the connection to a MongoDB database.

  • Config.privateKeyFilePath: Provide the file path to the Private Key that will be used.

  • Config.publicKeyFilePath: Provide the file path to the Public Key that will be used.

Note

You can use a pair of Private and Public keys previously generated by Krypton Authentication. If you are running multiple instances behind a load balancer be sure to provide the same pair of keys to each instance.

Example:

const kryptonAuth = require('@krypton-org/krypton-auth');
const express = require('express');
const EventEmitter = require('events');
const nodemailer = require('nodemailer');

const app = express();
const eventEmitter = new EventEmitter();

eventEmitter.on('email-error', (email) => {
    //Log email to be able to resend it again.
});
eventEmitter.on('error', (err) => {
    //Log error
});

const options = {
    graphiql: false,
    host: "https://my-service-public-adress.com",
    mailFrom: '"Foo Bar" <foo@bar.com>',
    nodemailerConfig: {
        host: "smtp.example.email",
        port: 465,
        secure: true,
        auth: {
        user: "FooBar",
        pass: "F@@8aR"
        }
    },
    dbAddress: "mongodb://login:password@something.mlab.com:19150/dbName",
    eventEmitter,
    privateKeyFilePath: './private-key.txt',
    publicKeyFilePath: './public-key.txt'
};

app.use('/auth', kryptonAuth(options));
app.listen(process.env.PORT || 80);

Heroku

https://www.herokucdn.com/deploy/button.svg