Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pubsweet
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Tremblay McLellan
pubsweet
Commits
ccd63265
Commit
ccd63265
authored
7 years ago
by
Mihail Dunaev
Browse files
Options
Downloads
Patches
Plain Diff
feat(ink-backend): improve error messages for missing config
re #351
parent
47734cee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/components/packages/Ink-server/InkBackend.js
+49
-0
49 additions, 0 deletions
packages/components/packages/Ink-server/InkBackend.js
with
49 additions
and
0 deletions
packages/components/packages/Ink-server/InkBackend.js
+
49
−
0
View file @
ccd63265
...
@@ -6,11 +6,60 @@ const config = require('config')
...
@@ -6,11 +6,60 @@ const config = require('config')
const
rp
=
require
(
'
request-promise-native
'
)
const
rp
=
require
(
'
request-promise-native
'
)
const
temp
=
require
(
'
temp
'
)
const
temp
=
require
(
'
temp
'
)
const
Pusher
=
require
(
'
pusher-js
'
)
const
Pusher
=
require
(
'
pusher-js
'
)
const
Joi
=
require
(
'
joi
'
)
// rp.debug = true
// rp.debug = true
const
inkConfig
=
config
.
get
(
'
pubsweet-component-ink-backend
'
)
const
inkConfig
=
config
.
get
(
'
pubsweet-component-ink-backend
'
)
function
checkInkConfig
(
inkConfig
)
{
/**
* Sanity checks on inkConfig
*
* config must have pubsweet-component-ink-backend with
* { inkEndpoint, email, password, recipes, pusher }
*
* config.get will throw if there is no pubsweet-component-ink-backend
* so no need to worry about that
*
* More at
* https://gitlab.coko.foundation/pubsweet/pubsweet/tree/master/packages/components/packages/Ink-server
*/
const
inkSchema
=
{
inkEndpoint
:
Joi
.
string
().
required
(),
email
:
Joi
.
string
().
required
(),
password
:
Joi
.
string
().
required
(),
recipes
:
Joi
.
object
()
.
required
()
.
min
(
1
),
pusher
:
Joi
.
object
()
.
keys
({
appKey
:
Joi
.
string
().
required
(),
wsHost
:
Joi
.
string
().
required
(),
wsPort
:
Joi
.
number
().
required
(),
httpHost
:
Joi
.
string
(),
httpPort
:
Joi
.
number
(),
})
.
required
(),
maxRetries
:
Joi
.
number
(),
}
const
{
error
}
=
Joi
.
validate
(
inkConfig
,
inkSchema
)
if
(
error
===
null
)
return
// error here
const
cokoGitlabPage
=
'
https://gitlab.coko.foundation
'
const
inkPath
=
'
/pubsweet/pubsweet/tree/master/packages
'
+
'
/components/packages/Ink-server
'
throw
new
Error
(
`
${
'
Bad ink config in config.pubsweet-component-ink-backend
'
+
'
. More info on how to set ink config at
'
}${
cokoGitlabPage
}${
inkPath
}
. Full error message log:
${
error
}
`
,
)
}
checkInkConfig
(
inkConfig
)
// Generate the absolute URL
// Generate the absolute URL
const
inkUrl
=
path
=>
`
${
inkConfig
.
inkEndpoint
}
api/
${
path
}
`
const
inkUrl
=
path
=>
`
${
inkConfig
.
inkEndpoint
}
api/
${
path
}
`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment