Skip to content

Instantly share code, notes, and snippets.

'use strict';
const auth = require('basic-auth');
const User = require('../user');
function basicAuthentication(app) {
app.use('/api/admin/', (req, res, next) => {
const credentials = auth(req);
if (credentials) {
const {User, AuthenticationRequired) = require('unleash-server');
const passport = require('passport');
const GoogleOAuth2Strategy = require('passport-google-auth').Strategy;
passport.use(
new GoogleOAuth2Strategy(
{
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
'use strict';
function start () {
const startTime = process.hrtime();
return () => {
const elapsed = process.hrtime(startTime);
return elapsed[0] * 1e9 + elapsed[1];
};
}
/**
* Given we have a regex with one more matching groups.
* The regex should capture those groups from an 'input'
* string and replace the matched values in an 'template'
* string.
*
* Example:
* regex: /([1-9]{8})/([1-9]{8})?/
* input string: '/some-magic/path/12122211/22112211'
* template string: 'http://someurl?adId=$1&adId=$2'
@ivarconr
ivarconr / gist:3878454
Created October 12, 2012 09:52
Start embedded Jetty 8 with web-context
//jetty.version 8.1.7.v20120910
public static void main(String[] args) throws Exception {
Server server = new Server(3000);
WebAppContext context = new WebAppContext();
context.setDescriptor(context+"/WEB-INF/web.xml");
context.setResourceBase("./src/main/webapp");
context.setContextPath("/");
context.setParentLoaderPriority(true);