apicco-lib
Advanced tools
Comparing version 1.0.2 to 1.0.3
44
build.js
@@ -22,19 +22,23 @@ const path = require('path'); | ||
} = {}) { | ||
function log(msg = '') { | ||
if (verbose) { | ||
console.log('[Apicco]', msg); | ||
} | ||
} | ||
const router = new Router(); | ||
router | ||
.prefix(prefix) | ||
.use(accepts); | ||
router.use(accepts); | ||
const api = {}; | ||
const resources = require('require-directory')( | ||
module, | ||
path.resolve(apiPath), | ||
{ | ||
exclude: /(\.test\.)|(index\.js)/ | ||
} | ||
); | ||
const fullApiPath = path.resolve(apiPath); | ||
for (let r in resources) { | ||
log(`API folder set to "${fullApiPath}"`); | ||
const resources = require('require-directory')(module, fullApiPath, { | ||
exclude: /(\.test\.)|(index\.js)/ | ||
}); | ||
for (const r in resources) { | ||
if (!resources.hasOwnProperty(r)) { | ||
@@ -46,3 +50,3 @@ continue; | ||
for (let a in actions) { | ||
for (const a in actions) { | ||
if (!actions.hasOwnProperty(a)) { | ||
@@ -68,3 +72,3 @@ continue; | ||
for (let param in validate) { | ||
for (const param in validate) { | ||
if (!validate.hasOwnProperty(param)) { | ||
@@ -74,6 +78,8 @@ continue; | ||
const { isJoi = true, _flags = {}} = validate[param]; | ||
const { isJoi = true, _flags = {} } = validate[param]; | ||
if (!isJoi) { | ||
throw new Error(`Invalid Joi validation for ${actionName} action: ${param}.`); | ||
throw new Error( | ||
`Invalid Joi validation for ${actionName} action: ${param}.` | ||
); | ||
} | ||
@@ -88,10 +94,8 @@ | ||
router.post(`/${action}`, compose(middlewares)); | ||
router.post(path.join(prefix, action), compose(middlewares)); | ||
if (verbose) { | ||
console.log(`Loaded: ${r}.${a} action`); | ||
} | ||
log(`Loaded "${r}.${a}" action`); | ||
} | ||
router.get('/discovery', ctx => { | ||
router.get(path.join(prefix, 'discovery'), (ctx) => { | ||
ctx.status = 200; | ||
@@ -98,0 +102,0 @@ ctx.body = api; |
{ | ||
"name": "apicco-lib", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": {}, | ||
"repository": { | ||
@@ -23,13 +22,12 @@ "type": "git", | ||
"homepage": "https://github.com/sokratisvidros/apicco#readme", | ||
"engines": { | ||
"node": "~8.11.4" | ||
}, | ||
"dependencies": { | ||
"boom": "^7.2.0", | ||
"inflection": "^1.12.0", | ||
"koa-compose": "^4.0.0", | ||
"koa-compose": "^4.1.0", | ||
"koa-joi-validate": "^0.5.1", | ||
"koa-router": "^7.4.0" | ||
}, | ||
"devDependencies": {}, | ||
"engines": { | ||
"node": "~8.11.1" | ||
} | ||
} |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
8810
1
220
86
Updatedkoa-compose@^4.1.0