forked from kylealwyn/node-rest-api-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ajhool
committed
Mar 30, 2017
1 parent
bf93a93
commit 5c32d40
Showing
10 changed files
with
63 additions
and
70 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ignore] | ||
|
||
[include] | ||
|
||
[libs] | ||
|
||
[options] |
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
/* @flow */ | ||
|
||
class BaseController { | ||
filterParams(params, whitelist) { | ||
const filtered = {}; | ||
filterParams(params, whitelist : Array<string>) { | ||
const filtered = {} | ||
for (const key in params) { | ||
if (whitelist.indexOf(key) > -1) { | ||
filtered[key] = params[key]; | ||
filtered[key] = params[key] | ||
} | ||
} | ||
return filtered; | ||
return filtered | ||
} | ||
|
||
formatApiError(err) { | ||
if (!err) { | ||
// eslint-disable-next-line no-console | ||
return console.error('Provide an error'); | ||
return console.error('Provide an error') | ||
} | ||
|
||
const formatted = { | ||
message: err.message, | ||
}; | ||
|
||
if (err.errors) { | ||
formatted.errors = {}; | ||
const errors = err.errors; | ||
formatted.errors = {} | ||
const errors = err.errors | ||
for (const type in errors) { | ||
if (errors.hasOwnProperty(type)) { | ||
formatted.errors[type] = errors[type].message; | ||
formatted.errors[type] = errors[type].message | ||
} | ||
} | ||
} | ||
|
||
return formatted; | ||
return formatted | ||
} | ||
} | ||
|
||
export default BaseController; | ||
export default BaseController |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/kylealwyn/node-rest-api-boilerplate.git" | ||
"url": "git://github.com/ajhool/node-rest-api-boilerplate.git" | ||
}, | ||
"keywords": [ | ||
"express", | ||
|
@@ -32,9 +32,9 @@ | |
"author": "Kyle Alwyn <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/kylealwyn/node-rest-api-boilerplate/issues" | ||
"url": "https://github.com/ajhool/node-rest-api-boilerplate/issues" | ||
}, | ||
"homepage": "https://github.com/kylealwyn/node-rest-api-boilerplate", | ||
"homepage": "https://github.com/ajhool/node-rest-api-boilerplate", | ||
"dependencies": { | ||
"babel-core": "^6.18.0", | ||
"bcrypt": "^1.0.0", | ||
|