Skip to content

Instantly share code, notes, and snippets.

@d1egoaz d1egoaz/nodeMock.js
Last active Aug 29, 2015

What would you like to do?
simple node express example
var express = require('express');
var request = require('request');
var app = express();
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
app.get('/proxy/:token?', function (req, res) {
var j={"name":"d1egoaz"};
app.get('/proxy2/:token?', function (req, res) {
res.statusCode = 404;
return res.send('Error 404: Not found proxy2');
// test
// curl http://localhost:9042/proxy/testtoken Res: HTTP 200, {"name":"d1egoaz"}
// curl http://localhost:9042/proxy2/testtoken Res: HTTP 400, Error 404: Not found proxy2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.