{"size": 1193, "ext": "js", "max_stars_repo_path": "server.js", "max_stars_repo_name": "PrimalOrB/tech_blog", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server.js", "max_issues_repo_name": "PrimalOrB/tech_blog", "max_issues_repo_issues_event_min_datetime": "2021-05-23T18:04:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-04T00:30:20.000Z", "max_forks_repo_path": "server.js", "max_forks_repo_name": "PrimalOrB/tech_blog", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 24, "max_forks_count": null, "avg_line_length": 31.3947368421, "max_line_length": 75, "alphanum_fraction": 0.642078793}
const express = require( 'express' );
const routes = require( './controllers/' );
const sequelize = require( './config/connection' );
const path = require( 'path' );
const exphbs = require( 'express-handlebars' );
const session = require( 'express-session' );
const SequelizeStore = require('connect-session-sequelize')(session.Store);
const helpers = require( './utils/helpers' );
const hbs = exphbs.create( { helpers } );
require( 'dotenv' ).config();

const sess = {
    secret: process.env.SECRET,
    cookie: { 
        maxAge: (1000 * 60) * 2 },  // 2 min idle time
    rolling: true, // rolling cookie for idle detection
    resave: false,
    saveUninitialized: true,
    store: new SequelizeStore( {
        db: sequelize
    } )
};

const app = express();
const PORT = process.env.PORT || 3001;

app.use( express.json() );
app.use( express.urlencoded( { extended: true } ) );
app.use( express.static( path.join( __dirname, 'public' ) ) );
app.use( session( sess ) );
app.engine( 'handlebars', hbs.engine );
app.set( 'view engine', 'handlebars' );

app.use( routes );

sequelize.sync( { force: false } ).then( () => {
    app.listen( PORT, () => console.log( 'Now listening' ) );
} );