Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Added CORS, fixed docs #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mockaccino",
"description": "A server that mocks webservices",
"version": "0.0.5",
"version": "0.0.6",
"license": "MIT",
"contributors": [
{
Expand All @@ -22,19 +22,20 @@
}
],
"scripts": {
"test": "mocha tests/unit/libs/*.js"
"test": "mocha tests/unit/libs/*.js"
},
"repository" : {
"type" : "git",
"url" : "https://github.com/yahoo/mockaccino.git"
"repository": {
"type": "git",
"url": "https://github.com/yahoo/mockaccino.git"
},
"dependencies": {
"cors": "^2.8.3",
"express": "~3.3.1",
"request": "~2.21.0",
"lodash": "~2.4.1",
"request": "~2.21.0",
"yargs": "~3.6.0"
},
"devDependencies": {
"mocha": "~1.12.0"
"mocha": "~1.12.0"
}
}
}
10 changes: 6 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var path = require('path'),
parent = module.parent.parent || module.parent,
embedded = !!module.parent.parent,
dirname = path.dirname(parent.filename),
cors = require('cors'),
mockUtils = require("./utils.js")(dirname);


Expand Down Expand Up @@ -48,7 +49,7 @@ function handleExtendEndpoint(req, res, cfgItem, key, method, cfg) {
* Serves the static file associated with a key
* @param {object} req The request obj
* @param {object} res The response object
* @param {object} cfgItem the Config item associated with the enpoint you're treating now
* @param {object} cfgItem the Config item associated with the endpoint you're treating now
* @param {string} key A key in the mockResponses object
*/
function serveStaticFileForKey(req, res, cfgItem, key, method) {
Expand All @@ -59,11 +60,11 @@ function serveStaticFileForKey(req, res, cfgItem, key, method) {


/**
* Serves the static file associated with a key
* Serves an object with a status code
* @param {object} req The request obj
* @param {object} res The response object
* @param {object} cfgItem the Config item associated with the enpoint you're treating now
* @param {string} key A key in the mockResponses object
* @param {number} statuscode the statuscode you want to return
* @param {object} the object to be sent
*/
function serveObject(req, res, statusCode, object) {
log("[Mockaccino] Serving object");
Expand Down Expand Up @@ -169,6 +170,7 @@ function getMockserver(cfg) {
app.use(express.bodyParser());
}
app.use(express.logger());
app.use(cors());

app.configure(function () {
log("[Mockaccino] Creating routes");
Expand Down