This is a paragraph, which is text surrounded by whitespace. Paragraphs can be on one
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
'BAL#000': 'ADD_OVERFLOW', | |
'BAL#001': 'SUB_OVERFLOW', | |
'BAL#002': 'SUB_UNDERFLOW', | |
'BAL#003': 'MUL_OVERFLOW', | |
'BAL#004': 'ZERO_DIVISION', | |
'BAL#005': 'DIV_INTERNAL', | |
'BAL#006': 'X_OUT_OF_BOUNDS', | |
'BAL#007': 'Y_OUT_OF_BOUNDS', | |
'BAL#008': 'PRODUCT_OUT_OF_BOUNDS', | |
'BAL#009': 'INVALID_EXPONENT', |
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
import pipeline, { Middleware } from './pipeline'; | |
const step1: Middleware<any, any> = (req, res, next) => { | |
if (req.body) { | |
console.log(`STEP 1: \n req: ${JSON.stringify(req)}\n res: ${JSON.stringify(res)}`); | |
next(); | |
} | |
} | |
const step2: Middleware<any, any> = async (req, res, 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
var simplerXHR = function( method, url) { | |
var _xhr = new XMLHttpRequest(); | |
_xhr.open( method, url ); | |
_xhr.setup = function(cb){ // hacky? maybe | |
cb(_xhr); | |
return _xhr; | |
}; | |
_xhr.done = function(cb){ // hacky? maybe | |
_xhr.onreadystatechange = function() { | |
if ( _xhr.readyState === 4 ) { |
###Creating a REST API using Node.js, Express, and MongoDB
####Installing Node.js
Go to http://nodejs.org, and click the Install button. Run the installer that you just downloaded. When the installer completes, a message indicates that Node was installed at /usr/local/bin/node and npm was installed at /usr/local/bin/npm. At this point node.js is ready to use. Let’s implement the webserver application from the nodejs.org home page. We will use it as a starting point for our project: a RESTful API to access data (retrieve, create, update, delete) in a wine cellar database.
Create a folder named nodecellar anywhere on your file system. In the wincellar folder, create a file named server.js.