Browse Source

Make deployment to production easier...like a real system.

pull/23/head
Zed A. Shaw 1 month ago
parent
commit
04550a8194
3 changed files with 24 additions and 15 deletions
  1. +5
    -4
      knexfile.js
  2. +2
    -1
      lib/models.js
  3. +17
    -10
      services/auth.js

+ 5
- 4
knexfile.js View File

@@ -1,12 +1,13 @@
// Update with your config settings.
const secrets = require('./lib/secrets');

module.exports = {
development: {
client: 'postgresql',
connection: {
database: 'ljsthw',
user: 'ljsthw',
password: 'testing'
user: secrets.database.development.user,
password: secrets.database.development.password,
},
pool: {
min: 2,
@@ -37,8 +38,8 @@ module.exports = {
client: 'postgresql',
connection: {
database: 'ljsthw',
user: 'ljsthw',
password: 'testing'
user: secrets.database.production.user,
password: secrets.database.production.password,
},
pool: {
min: 2,

+ 2
- 1
lib/models.js View File

@@ -5,8 +5,9 @@ const knexfile = require('../knexfile');
const uuid4 = require('uuid4');
const { log } = require('../lib/logging');
const assert = require('assert');
const secrets = require('../lib/secrets');

let knex = require('knex')(knexfile.development);
let knex = require('knex')(knexfile[secrets.env]);
const bookshelf = require('bookshelf')(knex);

function fix_booleans(me, attr) {

+ 17
- 10
services/auth.js View File

@@ -4,19 +4,26 @@ const { User, Auth } = require('../lib/models');
const { log } = require('../lib/logging');
const train = require('../lib/train');
const assert = require('assert');
cosnt secrets = require('../lib/secrets');

// TODO: make a real transport when env PROD=true
let transporter = nodemailer.createTransport({
streamTransport: true
});
let transporter;

let prod_transporter = nodemailer.createTransport({
secure: false,
ignoreTLS: true,
port: 25,
host: '10.0.2.2',
name: 'learnjsthehardway.com',
});
if(secrets.env == 'development') {
transporter = nodemailer.createTransport({
streamTransport: true
});
} else if(secrets.env == 'production') {
transporter = nodemailer.createTransport({
secure: false,
ignoreTLS: true,
port: 25,
host: '10.0.2.2',
name: 'learnjsthehardway.com',
});
} else {
assert(False, "secrets.env must be development or production.");
}

const gen_reg_email = (to, authtoken) => {
return {

Loading…
Cancel
Save