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
function defaultStrFns(someStr) { | |
let arr; | |
function splitIntoArray() { | |
arr = someStr.split(''); | |
return arr; | |
} | |
function concatFromArray() { | |
return arr.join(''); | |
} |
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
function DefaultStrFns(someStr) { | |
let arr; | |
this.splitIntoArray = function() { | |
arr = someStr.split(''); | |
return arr; | |
} | |
this.concatFromArray = function() { | |
return arr.join(''); | |
} |
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 express = require('express'); | |
const app = express(); | |
const beforeMiddleware = function(req, res, next) { | |
console.log('Before middleware triggered'); | |
next(); | |
} | |
const responseHandler = function(req, res, next) { | |
console.log('Response Action implementation triggered with response instead of send'); |
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 express = require('express'); | |
const app = express(); | |
const beforeMiddleware = function(req, res, next) { | |
console.log('Before middleware triggered'); | |
next(); | |
} | |
const responseHandler = function(req, res, next) { | |
console.log('Response Action implementation triggered with response instead of send'); |
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 express = require('express'); | |
const app = express(); | |
const beforeMiddleware = function(req, res, next) { | |
console.log('Before middleware triggered'); | |
next(); | |
} | |
const responseHandler = function(req, res, next) { | |
console.log('Response Action implementation triggered with response instead of send'); |
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 express = require('express'); | |
const app = express(); | |
const beforeAfterInjection = function(req, res, next) { | |
res.response = function (obj) { | |
req.res = obj; | |
} | |
next(); | |
} |
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
html | |
head | |
title= title | |
body | |
h1= status |
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
/* OTHER CODES */ | |
// Set TEMPLATING Engine views folder | |
app.set('views', './views'); | |
// Setting Pug as Templating engine | |
app.set('view engine', 'pug'); | |
// Sends response from the template views/index | |
// Data of object {status:'running'} is provided/injected to the template and ... |
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
// Sends response as JSON | |
app.get("/", function(req, res) { | |
res.status(200) | |
.send({status:'running'}); | |
}); | |
// Sends response as XML using any XML2JS convertor | |
const xml2js = require('xml2js'); | |
app.get("/", function(req, res) { | |
res.status(200) |
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 path = require('path'); | |
/* ALL OTHER CODE */ | |
// Serves index.html from the public folder when ... | |
// ... the client requests http://127.0.0.1:9001/ | |
app.get("/", function(req, res) { | |
res.status(200) | |
.sendFile(path.join(__dirname, 'public', 'index.html')); | |
}); |