This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function start () { | |
const startTime = process.hrtime(); | |
return () => { | |
const elapsed = process.hrtime(startTime); | |
return elapsed[0] * 1e9 + elapsed[1]; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
NewerOlder