Exemple #1
0
// the app in production (Heroku, effectively)
if (env === 'production' && useAuth === 'true'){
    app.use(utils.basicAuth(username, password));
}


// routes_childminding.bind(app)
// routes_driving.bind(app)

// Application settings
app.set('view engine', 'html');
app.set('views', [__dirname + '/app/views', __dirname + '/lib/']);

nunjucks.setup({
  autoescape: true,
  watch: true,
  noCache: true
}, app);

// require core and custom filters, merges to one object
// and then add the methods to nunjucks env obj
nunjucks.ready(function(nj) {
  var coreFilters = require(__dirname + '/lib/core_filters.js')(nj),
    customFilters = require(__dirname + '/app/filters.js')(nj),
    filters = Object.assign(coreFilters, customFilters);
  Object.keys(filters).forEach(function(filterName) {
    nj.addFilter(filterName, filters[filterName]);
  });
});

// Middleware to serve static assets
Exemple #2
0
var express = require('express');
var nunjucks = require('express-nunjucks');
var app = express();

app.set('view engine', 'njk');
app.set('views', __dirname + '/views');

nunjucks.setup({}, app);

var bString = 'babel, baby, babyhood, bachelor, back, backbend, backbone, backdrop, background, backing, backlash, backlog, backpack, backside, backstitch, backyard, bacon, bacteria, bad, badge, badinage, badmen, badminton, bag, baggage, bagpipe, bail, baileefe, bailiff, bailing, bait, baker, bakery, baking, balance, balancing, balcony, bale, ball, ballad, ballast, ballerina, ballet, balletomane, balloon, ballot, ballplayer, ballroom, ballyhoo, ballyhooey, balustrade, ban, banana, band, bandage, bandit, bandstand, bandwagon, bandwidth, bang, banging, banishment, banister, banjo, bank, banker, bankruptcy, banner, banning, banquet, banshee, banter, baptism, baptistery, bar, barbarian, barbecue, barbell, barber, barbital, barbiturate, bard, bargain, bargaining, barge, baritone, barium, bark, barkeep, barking, barley, barn, barnsful, barnstormer, barnyard, baron, barony, baroreceptor, barrack, barrage, barrel, barricade, barrier, bartender, base, baseball, baseballight, baseline, baseman, basement, basin, basket, basketball, bassinet, bastard, bastion, bat, batch, bateau, bath, bathrobe, bathroom, bathtub, baton, battalion, batten, batter, batterie, battery, battle, battlefield, battlefront, battleground, bauble, bawh, bay, baying, bayleefe, bayly, bayonet, bazaar,beach, beachhead, beacon, bead, beadle, beadsman, beaker, beam, bean, bear, beard, bearer, bearing, beast, beat, beatification, beating, beatnik, beau, beauty, beaver, beavertail, bebop, beckoning, becoming, bed, bedazzlement, bedding, bedground, bedlam, bedpost, bedroom, bedside, bedspread, bedstraw, bedtime, bee, beebread, beech, beef, beefsteak, beehive, beep, beer, beggar, beggary, begging, beginner, beginning, behalf, behavior, behaviour, behind, being, belaboring, belch, belching, belfry, belief, believer, bell, bellboy, bellicosity, belligerence, bellow, belly, bellyfull, belonging, belt, belting, bench, bend, bending, benediction, benefactor, beneficence, beneficiary, benefit, benevolence, bent, benzene, bequest, bereavement, beriberi, berry, berth, beryllium, bestowal, bestseller, bet, betrayal, betrayer, betrothal, betterment, betting, beveling, beverage, bevy, bewilderment,bib, bibliography, bicarbonate, bicep, bich, bickering, bicycle, bid, bidder, bidding, biennium, bigotry, bile, bilge, bill, billboard, billet, billiard, billing, bin, bind, binder, binding, bindle, binge, biographer, biography, biologist, biology, biophysicist, biopsy, biplane, birch, bird, birdbath, birdie, birefringence, birth, birthcontrol, birthday, birthplace, birthright, biscuit, bishop, bishopry, bison, bisque, bit, bitch, bite, biter, bivouac, biz,black, blackberry, blackboard, blackening, blacking, blackjack, blackmail, blackmailer, blackout, blacksmith, blade, blame, blank, blanket, blasphemy, blast, blastdown, blatancy, blaze, blazer, bleat, bleeding, blemish, blend, blessing, blight, blind, blister, blitz, blizzard, bloat, blob, bloc, block, blockade, blockhouse, bloke, blonde, blood, bloodlust, bloodroot, bloodshed, bloodstream, bloom, blooming, blossom, blot, blouse, blow, blower, blowfish, blowing, blowup, blubber, bludgeon, blue, blueberry, bluebook, bluebush, bluefish, blueprint, bluestocking, bluff, bluing, blunder, blur, bluster,boa, boar, board, boarder, boarding, boast, boat, boatel, boating, boatload, boatman, boatmen, boatsmen, boatswain, bobby, bod, bodice, body, bodybuilder, bodybuilding, bodyguard, bodyweight, bogey, bogeymen, bogy, boil, boiler, bolo, bologna, bolster, bolt, bomb, bombardment, bomber, bombing, bonanza, bond, bondage, bondsman, bone, bonfire, bongo, bonnet, booboo, booby, boogie, book, bookcase, booker, booking, bookkeeping, booklet, bookseller, bookshelf, boom, boomerang, boomtown, boon, boost, booster, boot, booth, bootlegger, booty, booze, bop, borax, border, borderline, bore, boredom, borer, boring, borough, borrower, borrowing, bosom, bossman, botany, bottle, bottleneck, bottom, boucle, bough, boulder, boulevard, bounce, bouncing, bound, boundary, bounty, bouquet, bourbon, bourgeoisie, bout, bovine, bow, bower, bowing, bowl, bowstring, box, boxcar, boxer, boy, boycott, boyhood,brace, bracelet, brachii, bracing, bracket, brad, brag, braggadocio, brain, brainwashing, brake, bran, branch, brand, brandy, brassiere, bravado, bravery, bravura, brawl, brawle, brazier, brazil, breach, bread, breadth, break, breakage, breakaway, breakdown, breaker, breakfast, breaking, breakoff, breakthrough, breakup, breakwater, breast, breath, breather, breathing, breed, breeze, brethren, brevity, brew, brewery, brick, bricklaying, bridal, bride, bridegroom, bridge, bridgehead, bridgework, bridle, brief, briefcase, briefing, brig, brigade, brigadier, brilliance, brim, brindle, bringing, brink, brinkmanship, bristle, broadcast, broadcasting, broadening, broadside, brocade, broccoli, brochure, brockle, broil, broiler, broker, brokerage, bromphenol, bronc, bronchi, bronchiole, bronze, brood, brook, broom, broth, brothel, brother, brotherhood, brow, brown, bruise, brunt, brush, brushcut, brushfire, brushing, brushwork, brutality, brute,bubble, buck, buckboard, bucket, buckle, buckshot, buckskin, buckwheat, bud, buddy, budget, budgeting, buff, buffalo, buffer, buffet, buffoon, bug, buggy, bugle, bugler, build, builder, building, buildup, bulb, bulge, bulk, bulkhead, bull, bullet, bulletin, bullhide, bullshit, bully, bulwark, bum, bumblebee, bumming, bump, bumper, bun, bunch, buncha, bundle, bungalow, bunk, bunker, bunkmate, bunt, bunter, buoyancy, burden, bureau, bureaucracy, bureaucrat, bureaucratization, burglar, burglary, burial, burl, burlesque, burley, burn, burning, burr, burrow, burst, busboy, bush, bushel, businessman, businessmen, bust, bustle, butane, butcher, butchery, butler, butt, butter, butterfat, butterfly, butternut, button, butyrate, buy, buyer, buying, buzz,byinge, byline, byproduct, bystander, byword';
var sString = 'saami, saber, sable, sabotage, sabre, sac, sack, sacker, sacrament, sacrifice, sacrilege, saddle, sadism, sadist, safari, safe, safeguard, safety, saffron, saga, sage, sagebrush, sago, sail, sailboat, sailing, sailor, saint, sainthood, sake, salad, salamander, salami, salary, sale, salesgirl, saleslady, salesman, salesmanship, salesmen, saline, saliva, sallying, salmon, salon, saloon, saloonkeeper, salt, saltbush, salutation, salute, salvage, salvation, salve, salvo, sambur, samovar, sample, sampling, sanatorium, sanction, sanctity, sanctuary, sand, sandalwood, sander, sandpaper, sandwich, sangaree, sanhedrin, sanipractor, sanitarium, sanitation, sanity, sap, sapling, sarcasm, sari, sash, sashimi, sassing, satellite, satiety, satin, satire, satirist, satisfaction, saturation, sauce, saucepan, sauerkraut, sausage, saver, saving, savior, savor, saw, sawdust, sawing, sawmill, sawtimber, sax, saxophone, saxophonist, say, saying,scabbard, scaffold, scaffolding, scale, scalp, scan, scandal, scanning, scapegoat, scar, scarcity, scare, scarf, scatter, scattergun, scavenger, scenario, scene, scenery, scent, scepticism, schedule, scheduling, schema, schemata, scheme, scherzo, schism, schizophrenic, scholar, scholarship, school, schoolboy, schoolchildren, schoolgirl, schoolhouse, schooling, schoolmaster, schoolmate, schoolroom, schoolwork, schooner, sciatica, science, scientist, scimitar, scion, scissoring, scoffing, scoop, scop, scope, scorcher, score, scoreboard, scorecard, scoring, scorn, scoundrel, scourge, scouring, scout, scramble, scrap, scrapbook, scrape, scratch, scream, screaming, screech, screen, screening, screenland, screenplay, screw, screwball, scribe, scrim, scrimmage, script, scripture, scrivener, scrub, scrubbing, scrupulosity, scrutiny, scuffle, sculptor, sculpture, scurvy,sea, seacoast, seafood, seahorse, seal, sealing, seam, seaman, seamanship, seamen, seaquake, search, searching, searchlight, seashore, seaside, season, seasoning, seat, seato, seaweed, secant, secession, secessionist, seclusion, second, secondhand, secrecy, secret, secretary, secretion, sect, section, sector, secular, secularism, securing, security, sedan, sedative, sediment, sedimentation, sedition, seducer, seduction, seed, seedbed, seedcoat, seeker, seepage, seersucker, segment, segregation, segregationist, seismograph, seizure, selection, selectivity, self, sell, seller, selling, sellout, semblance, semester, seminar, seminary, semitrance, senate, senator, sending, senior, seniority, senora, sensation, sensationalism, sense, sensibility, sensing, sensitivity, sensor, sensuality, sentence, sentiment, sentimentality, sentinel, sentry, separation, sepia, septa, septation, septum, sequel, sequence, sequestration, sera, seraphim, serenade, serenity, serge, sergeant, serial, serloin, sermon, serpent, serum, servant, service, servicemen, servicing, serving, servo, sesame, session, set, setback, setsw, setting, settlement, settler, setup, severalty, severing, severity, sewage, sewer,shack, shade, shading, shadow, shadowing, shaft, shag, shake, shaker, shaking, sham, shame, shampoo, shamrock, shank, shanty, shape, shaping, share, sharecrop, shareholder, sharing, sharpening, shawl, shea, sheaf, shear, sheath, sheathing, shed, sheen, sheep, sheepe, sheepskin, sheet, sheeting, sheik, shelf, shell, shelter, shepherd, sheriff, sherry, shewe, shibboleth, shield, shielding, shift, shill, shimmer, shin, shinbone, shine, ship, shipboard, shipbuilding, shipmate, shipment, shipper, shipping, shipwreck, shirt, shirtfront, shirtsleeve, shish, shit, shiver, shock, shocker, shockwave, shoe, shoelace, shoestring, shoji, shoot, shooter, shooting, shop, shopper, shopping, shore, shoreline, shortage, shortcut, shorthand, shortstop, shot, shotgun, shoulder, shout, shouting, shovel, show, showcase, showdown, shower, showerhead, showing, showman, showmanship, showmen, showpiece, showroom, shrapnel, shred, shredder, shriek, shrieking, shrimp, shrine, shrinkage, shrub, shrubbery, shrug, shuffle, shunt, shutdown, shutter,sickroom, side, sideboard, sidelight, sideline, sidemen, sideshow, sidewalk, sidewinder, siding, siege, sienna, siesta, sieve, sifting, sigh, sight, sighting, sign, signal, signaling, signature, signboard, significance, signing, signpost, sih, silence, silhouette, silica, silicon, silicone, silk, silke, sill, silo, silver, similarity, simile, similitude, simpleton, simplicitude, simplicity, simulation, sin, sincerity, sine, singer, singing, single, singularity, sink, sinkhole, sinking, sinner, sip, sir, siren, sister, site, sitter, sitting, situation, size,skeet, skeleton, skepticism, sketch, sketchbook, skewer, ski, skid, skiff, skiing, skill, skillet, skimming, skin, skipper, skirmish, skirmishing, skirt, skit, skull, skullcap, sky, skylight, skyline, skyscraper, skywave,slab, slack, sladang, slanderer, slang, slant, slapstick, slat, slate, slaughter, slave, slavery, slaying, sledding, sleep, sleeping, sleepwalker, sleet, sleeve, sleuthing, slice, slick, slicker, slide, slight, sling, slingshot, slip, slippage, slipper, slipstream, slit, slitter, slob, sloe, slogan, sloop, slop, slope, slot, slouch, slowing, sludge, slug, slugger, sluice, sluicehouse, slum, slumber, slump, small, smallpox, smalltime, smash, smear, smell, smile, smirk, smithy, smog, smoke, smokehouse, smokescreen, smoothbore, snack, snail, snake, snakestrike, snap, snapback, snapper, snapping, snare, sneak, sneaker, sneer, snick, sniper, sniping, snobbery, snoring, snorkle, snort, snout, snow, snowball, snowfall, snowstorm, snuffer,soaking, soap, sobriety, sobriquet, soccer, sociability, social, socialism, socialist, sociality, socialization, society, sociologist, sociology, sock, socket, sod, soda, sodium, sofa, softener, softening, softwood, soil, sojourn, sojourner, solace, solder, soldier, soldiery, sole, solemnity, solenoid, solicitor, solicitude, solid, solidarity, solidity, solipsism, solitary, solitude, solo, soloist, solstice, solution, solvency, solvent, soma, someplace, somersault, somewhere, sommelier, somnolence, son, sonar, sonata, song, songbook, sonnet, sonny, sonofabitch, sonogram, sonority, soot, sop, sophisticate, sophistication, sophomore, soprano, sorghum, sorority, sorption, sorrel, sorrow, sort, sortie, soubriquet, souffle, soul, sound, soup, source, sourdough, soutane, southpaw, souvenir, sovereign, sovereignty, soviet, sowbelly, sowing, soy, soybean,spa, space, spacecraft, spacer, spaceship, spacesuit, spacing, spade, spaghetti, span, spangle, spark, sparkle, spasm, spat, spate, spatiality, spatter, speaker, speaking, spear, special, specialist, specialization, specialty, specification, specificity, specimen, specimentalia, speck, spectacle, spectator, specter, spectra, spectre, spectrometer, spectrophotometer, spectroscopy, spectrum, speculation, speculator, speech, speed, speedboat, speedometer, spell, spelling, spending, sphere, spice, spider, spike, spin, spinach, spindle, spine, spinnability, spinneret, spiral, spire, spirit, spirituality, spit, spite, spittle, splash, spleen, splendor, splenomegaly, splice, splicing, splinter, split, splurge, spoilage, spoke, spokesman, spokesmen, sponge, sponging, sponsor, sponsorship, spontaneity, spoof, spoon, spoonful, sport, sportsman, sportsmanship, sportsmen, sportswriter, spot, spotlight, spouse, spout, sprawl, spray, spraying, spread, spreader, spreading, spree, sprig, spring, springboard, springtime, sprinkle, sprinkling, sprouting, spruce, sprue, spume, spur, spurt, sputnik, spy,squabbling, squad, squadron, squadroom, squall, square, squash, squat, squaw, squeak, squeaking, squeal, squeeze, squire, squirrel, squirt,stab, stability, stabilization, stable, stableman, staccato, stack, stadium, staff, stag, stage, stagecoach, stager, stagnation, stain, staining, stair, staircase, stairway, stake, stalemate, stall, stallion, stamina, stamp, stampede, stamping, stance, stand, standard, standby, standing, standpoint, standstill, staple, stapling, star, starch, stardom, stare, starlet, starlight, starre, start, starter, starting, starvation, state, statement, stateroom, statesman, statesmanship, statesmen, static, station, stationery, stationmaster, stator, statuary, statue, statuette, stature, statute, stay, stead, steak, stealer, stealing, stealth, steam, steamboat, steamer, steamship, steed, steel, steelmaker, steep, steeple, steer, stein, stem, stench, stenography, step, stepchild, stepmother, steprelationship, stepson, stereo, stereotype, sterility, sterilization, stern, sternum, steroid, stethoscope, stevedore, stew, steward, stewardship, stick, stickler, stickman, stickpin, stiff, stiffening, stigma, stigmata, stiletto, still, stimulant, stimulation, stimuli, sting, stink, stint, stipulation, stirring, stirrup, stitch, stock, stockade, stockbroker, stockholder, stockpiling, stockroom, stoicism, stoker, stomach, stomack, stone, stoneware, stool, stoop, stop, stopover, stoppage, stopper, storage, store, storefront, storehouse, storeroom, storm, story, storyline, storyteller, stove, straightaway, strain, strait, stramonium, strand, stranger, strangulation, strap, strata, stratagem, strategy, stratification, stratosphere, stratum, straw, stray, streak, stream, streamer, streamliner, streamside, street, streetcar, streetlight, strength, strengthening, stretch, stretcher, stretching, stride, strife, strike, striking, string, strip, stripe, striptease, striving, stroke, stroking, stroll, stronghold, strophe, structure, struggle, strut, strychnine, stub, stubble, stucco, stud, student, studio, study, stuff, stump, stumpage, stupidity, stupor, sturgeon, style, stylemark, styling, stylist, stylization, styrene,suability, suavity, sub, subaltern, subcommittee, subcontinent, subdivision, subhumanity, subject, subjectivist, subjectivity, subjugation, sublease, sublimate, sublime, submarine, submission, submitting, submucosa, subordinate, subordinator, subparagraph, subrogation, subroutine, subscription, subsection, subservience, subsidiary, subsidy, subsistence, subsoil, subspace, substance, substantiation, substitute, substitution, substrate, substratum, substructure, subsystem, subtlety, subtraction, subtype, suburb, suburbanite, suburbia, subversion, subway, succession, successor, successorship, succor, suction, sudden, suey, sufferer, suffering, sufficiency, suffix, suffocating, suffocation, suffrage, sugar, suggestibility, suggestion, suicide, suit, suitability, suitcase, suite, suitor, sulfaquinoxaline, sulfide, sulfur, sulphur, sum, sumac, summarization, summary, summation, summer, summertime, summit, summitry, sun, sunbonnet, sunburn, sundown, sunlight, sunrise, sunset, sunshield, sunshine, sunspot, suntan, superego, superficiality, superintendent, superior, superiority, supermachine, supermarket, supernatant, supernatural, supernaturalism, superposition, superstition, superstructure, supervision, supervisor, supper, supplement, supplier, supply, support, supporter, suppression, supranationalism, supremacy, surcease, surf, surface, surfactant, surge, surgeon, surgery, surname, surprise, surrealism, surrender, surtout, surveillance, survey, surveyor, survivability, survival, survivalist, survivor, susceptibility, suspect, suspense, suspension, suspensor, suspicion, sustenance, suzerain, suzerainty,swallow, swami, swamp, swan, swao, swarm, swastika, swath, sway, swearing, swearinge, sweat, sweatband, sweater, sweatshirt, sweep, sweetheart, swell, swelling, swerve, swig, swim, swimsuit, swine, swing, swipe, swirl, switch, switchblade, switchboard, switchgear, switching, swivel, swoop, sword, sworde,syllabicity, syllable, symbol, symbolism, symmetry, sympathy, symphony, symposium, symptom, synagogue, synchronism, synchrony, syndicate, syndication, syndrome, synergism, synonym, synonymy, syntax, synthesizine, syringa, syringe, syrup, system, systematization, systemization';
var bNouns = bString.replace(/ /g, '').split(',');
var sNouns = sString.replace(/ /g, '').split(',');

function random(min,max) {
	return Math.floor(Math.random() * (max - min)) + min;
}

app.use('/', function(req,res){
	var bNoun = bNouns[random(0,bNouns.length-1)];
	var sNoun = sNouns[random(0,sNouns.length-1)];

	var nickname = `${bNoun} ${sNoun}`;
	// res.json({
	// 	'message': 'I am the random nickname generator for Bystrik',
	// 	'nickname': nickname
	// });
	res.render('index', { nickname: nickname });
});

app.listen(4000, function(err){
const bodyParser = require('body-parser');
const constants = require('../lib/constants');
const Gateway = require('../index').Gateway;

app.use(bodyParser.urlencoded({ extended: false }));
app.set('view engine', 'html');
app.set('views', __dirname + '/templates');

nunjucks.setup({
  // (default: true) controls if output with dangerous characters are escaped automatically.
  autoescape: true,
  // (default: false) throw errors when outputting a null/undefined value.
  throwOnUndefined: false,
  // (default: false) automatically remove trailing newlines from a block/tag.
  trimBlocks: false,
  // (default: false) automatically remove leading whitespace from a block/tag.
  lstripBlocks: false,
  // (default: false) if true, the system will automatically update templates when they are changed on the filesystem.
  watch: true,
  // (default: false) if true, the system will avoid using a cache and templates will be recompiled every single time.
  noCache: true,
  // (default: see nunjucks syntax) defines the syntax for nunjucks tags.
  tags: {}
}, app);

const euplatescGateway = new Gateway({
  secretKey: '', // from admin panel,
  merchantId: '' // from admin panel
});

app.get('/', (req, res) => {
  euplatescGateway.prepareAuthorizationRequestData({
let nunjucksConfig = {
	autoescape: true
};

if (config.env !== 'production') {
	nunjucksConfig.noCache = true;
}

app.set('view engine', 'html');
app.set('views', [
	`${__dirname}/app/views`,
	`${__dirname}/node_modules/govuk_template_jinja/views`,
	`${__dirname}/node_modules/govstrap/nunjucks`
]);

nunjucks.setup(nunjucksConfig, app);

// Add extra filters to nunjucks
nunjucks.ready((nj) => {
	Object.keys(filters).forEach((filterName) => {
		nj.addFilter(filterName, filters[filterName]);
	});
});

// Insert usefull variables into response for all controllers
app.use(require(`${__dirname}/app/middleware/locals`));
app.use('/images', express.static(`${__dirname}/node_modules/govuk_frontend_toolkit/images`));
app.use('/images', express.static(`${__dirname}/node_modules/govstrap/images`));
app.use('/javascripts', express.static(`${__dirname}/node_modules/govstrap/public/javascripts`));
app.use('/fonts', express.static(`${__dirname}/node_modules/govuk_template_mustache/assets/stylesheets`));
app.use(express.static(`${__dirname}/app/public`));