<commit_before>import express from 'express';
let app = express();
app.set('view engine', 'ejs');
app.use(express.static('build'));
import Promise from 'bluebird';

import whoami from 'controllers/whoami';
import * as links from 'controllers/links';
import {checkRepo} from 'controllers/checkRepo';
import webhook from 'controllers/webhook';
import webhookOld from 'controllers/webhookOld';
import {getSubscriptionInformation, updatePaidLinks} from 'controllers/payments';

import isLinkPaid from 'helpers/isLinkPaid';
import addWebhooksForLink from 'helpers/addWebhooksForLink';

// ----------------------------------------------------------------------------
// Mongo stuff
// ----------------------------------------------------------------------------
import mongoose from 'mongoose';
mongoose.connect(process.env.MONGO_URI);
mongoose.Promise = Promise;
import User from 'models/User';
import Link from 'models/Link';

// ----------------------------------------------------------------------------
// Set up session store
// ----------------------------------------------------------------------------
const MongoStore = require('connect-mongo')(session),
mongoStore = new MongoStore({mongooseConnection: mongoose.connection});

// ----------------------------------------------------------------------------
// Passport stuff
// ----------------------------------------------------------------------------
import passport from 'passport';
import session from 'express-session';
import strategy from 'auth/strategy';
import serialize from 'auth/serialize';
app.use(session({
  secret: process.env.SESSION_SECRET,
  store: mongoStore,
}));
app.use(passport.initialize());
app.use(passport.session());
passport.use(strategy(User));
serialize(User, passport);

import bodyParser from 'body-parser';
import morgan from 'morgan';
app.use(morgan('tiny'));

// Authenticate a user
app.get('/setup/login', passport.authenticate('github', {
  successRedirect: '/',
  failureRedirect: '/setup/login',
  scope: ["public_repo", "write:repo_hook", "user:email"],
}));
app.get('/setup/login/private', passport.authenticate('github', {
  successRedirect: '/setup/login',
  failureRedirect: '/setup/login',
  scope: ["repo", "write:repo_hook", "user:email"],
}));

// Second leg of the auth
app.get("/auth/github/callback", passport.authenticate("github", {
  failureRedirect: '/setup/login',
}), (req, res) => {
  res.redirect('/#/links'); // on success
});<commit_msg>code(payments): by default, authenticate with private repo access<commit_after>import express from 'express';
let app = express();
app.set('view engine', 'ejs');
app.use(express.static('build'));
import Promise from 'bluebird';

import whoami from 'controllers/whoami';
import * as links from 'controllers/links';
import {checkRepo} from 'controllers/checkRepo';
import webhook from 'controllers/webhook';
import webhookOld from 'controllers/webhookOld';
import {getSubscriptionInformation, updatePaidLinks} from 'controllers/payments';

import isLinkPaid from 'helpers/isLinkPaid';
import addWebhooksForLink from 'helpers/addWebhooksForLink';

// ----------------------------------------------------------------------------
// Mongo stuff
// ----------------------------------------------------------------------------
import mongoose from 'mongoose';
mongoose.connect(process.env.MONGO_URI);
mongoose.Promise = Promise;
import User from 'models/User';
import Link from 'models/Link';

// ----------------------------------------------------------------------------
// Set up session store
// ----------------------------------------------------------------------------
const MongoStore = require('connect-mongo')(session),
mongoStore = new MongoStore({mongooseConnection: mongoose.connection});

// ----------------------------------------------------------------------------
// Passport stuff
// ----------------------------------------------------------------------------
import passport from 'passport';
import session from 'express-session';
import strategy from 'auth/strategy';
import serialize from 'auth/serialize';
app.use(session({
  secret: process.env.SESSION_SECRET,
  store: mongoStore,
}));
app.use(passport.initialize());
app.use(passport.session());
passport.use(strategy(User));
serialize(User, passport);

import bodyParser from 'body-parser';
import morgan from 'morgan';
app.use(morgan('tiny'));

// Authenticate a user
app.get('/setup/login', passport.authenticate('github', {
  successRedirect: '/',
  failureRedirect: '/setup/login',
  scope: ["repo", "write:repo_hook", "user:email"],
}));
app.get('/setup/login/public', passport.authenticate('github', {
  successRedirect: '/',
  failureRedirect: '/setup/login',
  scope: ["public_repo", "write:repo_hook", "user:email"],
}));

// Second leg of the auth
app.get("/auth/github/callback", passport.authenticate("github", {
  failureRedirect: '/setup/login',
}), (req, res) => {
  res.redirect('/#/links'); // on success
});
{'fraction_non_alphanumeric': 0.31565147236789026, 'fraction_numerical': 0.0, 'mean_word_length': 2.295016611295681, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1247839', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1262, 'n_words': 306}