<commit_before>'use strict'
const bcrypt = require('bcrypt');
// const salt   = bcrypt.genSaltSync(10);
const pgp    = require('pg-promise')({
  //initialization options
});
const async = require('async'); // asynchronous map function


// https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax#configuration-object

const connectionObject = {
    host: process.env.DB_HOST,
    port: process.env.PGDB_PORT,
    database: process.env.DB_NAME,
    user: process.env.DB_USER, //may need to check capitalization of name in env file?
    password: <PASSWORD>
}
// console.log(connectionObject, 'was connectionObject');
// console.log(process.env.host, 'was process.env.host');
// console.log(process.env.Host, 'was process.env.Host');
// console.log(process.env.port, 'was process.env.port');
// console.log(process.env.Port, 'was process.env.Port');
console.log(process.env, 'was process.env');

const db = pgp(connectionObject);
// console.log(db, 'was db');


// module.exports.getBook  = ( req, res, next ) => {
//
// }


function localGetBook(book_id, res, next){ //start of chain to get book/author info from my DB to send back to client/browser
  // console.log(book_id, 'was book_id before db. call in localGetBook in db/books.js');
  console.log("localGetBook fired in books.js");

  db.one("SELECT * FROM books WHERE id = $1;", [book_id])
    .then( (bookData) => {
      // console.log(bookData, 'was bookData in localGetBook .then'); //this only returns id, isbn13, title, publisher.
      // need to then query authorbookjoin to get the author_id associated with the book, then query the author db to get the author name
      // localGetAuthorOfBook(bookData)
      // let authorData = localGetAuthorOfBook(bookData); //if all the relevant data needs to get to browser i can theoretically use this as a way of doing it? as in something like, allData = {bookData, authorData}; res.rows = allData;

      //NOTE above code is for when authors was going to be an independent model.
      console.log(bookData, 'was bookData in localGetBook .then');<commit_msg>think i've set all the env vars i need. logging connectionObject to test.<commit_after>'use strict'
const bcrypt = require('bcrypt');
// const salt   = bcrypt.genSaltSync(10);
const pgp    = require('pg-promise')({
  //initialization options
});
const async = require('async'); // asynchronous map function


// https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax#configuration-object

const connectionObject = {
    host: process.env.DB_HOST,
    port: process.env.PGDB_PORT,
    database: process.env.DB_NAME,
    user: process.env.DB_USER, //may need to check capitalization of name in env file?
    password: <PASSWORD>
}
console.log(connectionObject, 'was connectionObject');
// console.log(process.env.host, 'was process.env.host');
// console.log(process.env.Host, 'was process.env.Host');
// console.log(process.env.port, 'was process.env.port');
// console.log(process.env.Port, 'was process.env.Port');
// console.log(process.env, 'was process.env');

const db = pgp(connectionObject);
// console.log(db, 'was db');


// module.exports.getBook  = ( req, res, next ) => {
//
// }


function localGetBook(book_id, res, next){ //start of chain to get book/author info from my DB to send back to client/browser
  // console.log(book_id, 'was book_id before db. call in localGetBook in db/books.js');
  console.log("localGetBook fired in books.js");

  db.one("SELECT * FROM books WHERE id = $1;", [book_id])
    .then( (bookData) => {
      // console.log(bookData, 'was bookData in localGetBook .then'); //this only returns id, isbn13, title, publisher.
      // need to then query authorbookjoin to get the author_id associated with the book, then query the author db to get the author name
      // localGetAuthorOfBook(bookData)
      // let authorData = localGetAuthorOfBook(bookData); //if all the relevant data needs to get to browser i can theoretically use this as a way of doing it? as in something like, allData = {bookData, authorData}; res.rows = allData;

      //NOTE above code is for when authors was going to be an independent model.
      console.log(bookData, 'was bookData in localGetBook .then');
{'fraction_non_alphanumeric': 0.1328422053231939, 'fraction_numerical': 0.002376425855513308, 'mean_word_length': 3.7559322033898304, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2788648', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1269, 'n_words': 415}