Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify start page #310

Merged
merged 32 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c5dbc9c
feat: obtain parameter from config, session, request
jimlambie Nov 29, 2017
372e283
chore: package lock
jimlambie Nov 29, 2017
3e1414c
refactor: remove underscorejs from ds module
jimlambie Nov 29, 2017
db275e5
Merge branch 'develop' of https://github.com/dadi/web into feature/da…
jimlambie Nov 29, 2017
5f6adc0
feat: inject parameters into chained ds endpoints
jimlambie Nov 29, 2017
795215d
refactor: remove underscore from view/public.js
jimlambie Nov 29, 2017
0d1df82
refactor: remove underscore usage
jimlambie Nov 29, 2017
b9416e3
refactor: favour const over let
jimlambie Nov 29, 2017
fa0195a
style: fix JSON indents
jimlambie Nov 29, 2017
b6e8f36
refactor: remove underscore usage
jimlambie Nov 29, 2017
f99e12f
refactor: remove underscorejs usage
jimlambie Nov 29, 2017
824c909
refactor: remove underscorejs usage
jimlambie Nov 30, 2017
f719c43
refactor: remove underscore usage
eduardoboucas Nov 30, 2017
dd70e56
refactor: remove underscorejs usage
jimlambie Nov 30, 2017
a05eb8d
refactor: remove underscorejs usage
jimlambie Nov 30, 2017
e5484e0
fix: return first component in array
jimlambie Nov 30, 2017
9aa39e1
fix: disable coverage check
jimlambie Nov 30, 2017
bfd1672
refactor: remove underscore usage
eduardoboucas Nov 30, 2017
7c95d03
Merge branch 'feature/datasource-parameter-extension' of github.com:d…
eduardoboucas Nov 30, 2017
f1863ad
Merge branch 'feature/datasource-parameter-extension' of https://gith…
jimlambie Nov 30, 2017
a730262
style: standardjs
jimlambie Nov 30, 2017
ee2e03a
chore: update package, remove underscore dependency 🎉
jimlambie Nov 30, 2017
c2095c0
feat: allow modification of ds endpoint from a special event
jimlambie Nov 30, 2017
307943e
feat: remove underscore from test files #198
Dec 1, 2017
e357f73
feat: new default page
Dec 6, 2017
c06de2d
Merge branch 'develop' of https://github.com/dadi/web into feature/es…
Dec 6, 2017
1682604
fix: tests
Dec 7, 2017
2c3676e
fix: tests
Dec 7, 2017
180a10d
fix: tests
Dec 7, 2017
b49168a
fix: tests
Dec 7, 2017
f3a58eb
fix: tests
Dec 7, 2017
1570abe
fix: coverage badge
Dec 7, 2017
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
48 changes: 25 additions & 23 deletions dadi/lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ module.exports.isApiAvailable = function (done) {
}

request.on('error', function (e) {
e.message = `Error connecting to API: ${e.message}. Check the 'api' settings in config file 'config/config.${config.get(
e.message = `Error connecting to API: ${
e.message
}. Check the 'api' settings in config file 'config/config.${config.get(
'env'
)}.json`
e.remoteIp = options.hostname
Expand All @@ -106,9 +108,9 @@ module.exports.isApiAvailable = function (done) {
* @param {res} res - the HTTP response
*/
module.exports.validateRequestCredentials = function (req, res) {
var authConfig = config.get('auth')
var clientId = req.body.clientId
var secret = req.body.secret
const authConfig = config.get('auth')
const clientId = req.body.clientId
const secret = req.body.secret

if (!clientId || !secret) {
res.statusCode = 401
Expand Down Expand Up @@ -360,16 +362,16 @@ module.exports.sortBy = function (field, primer) {
}

/**
* Lists all files in a directory.
*
* @param {string} directory Full directory path.
* @param {object} options
* @param {array} options.extensions A list of extensions to filter files by.
* @param {boolean} options.failIfNotFound Whether to throw an error if the directory doesn't exist.
* @param {boolean} options.recursive Whether to read sub-directories.
*
* @return {array} A list of full paths to the discovered files.
*/
* Lists all files in a directory.
*
* @param {string} directory Full directory path.
* @param {object} options
* @param {array} options.extensions A list of extensions to filter files by.
* @param {boolean} options.failIfNotFound Whether to throw an error if the directory doesn't exist.
* @param {boolean} options.recursive Whether to read sub-directories.
*
* @return {array} A list of full paths to the discovered files.
*/
function readDirectory (directory, options) {
options = options || {}

Expand Down Expand Up @@ -421,15 +423,15 @@ function readDirectory (directory, options) {
module.exports.readDirectory = readDirectory

/**
* Executes a callback for each file on a list of paths.
*
* @param {array} files The file paths.
* @param {object} options
* @param {function} options.callback The callback to be executed.
* @param {array} options.extensions A list of extensions to filter files by.
*
* @return {array} A Promise that resolves after all callbacks have executed.
*/
* Executes a callback for each file on a list of paths.
*
* @param {array} files The file paths.
* @param {object} options
* @param {function} options.callback The callback to be executed.
* @param {array} options.extensions A list of extensions to filter files by.
*
* @return {array} A Promise that resolves after all callbacks have executed.
*/
function readFiles (files, options) {
options = options || {}

Expand Down
76 changes: 39 additions & 37 deletions dadi/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,45 +454,43 @@ Server.prototype.loadApi = function (options, reload, callback) {
this.initMiddleware(options.middlewarePath, options)

// Load routes
return this.updatePages(
options.pagePath,
options,
reload || false
).then(() => {
this.addMonitor(options.datasourcePath, dsFile => {
this.updatePages(options.pagePath, options, true)
})

this.addMonitor(options.eventPath, eventFile => {
// Delete the existing cached events
Object.keys(require.cache).forEach(i => {
if (i.includes(options.eventPath)) delete require.cache[i]
return this.updatePages(options.pagePath, options, reload || false).then(
() => {
this.addMonitor(options.datasourcePath, dsFile => {
this.updatePages(options.pagePath, options, true)
})

// Reload
this.updatePages(options.pagePath, options, true)
})
this.addMonitor(options.eventPath, eventFile => {
// Delete the existing cached events
Object.keys(require.cache).forEach(i => {
if (i.includes(options.eventPath)) delete require.cache[i]
})

this.addMonitor(options.pagePath, pageFile => {
this.updatePages(options.pagePath, options, true)
this.compile(options)
templateStore.reInitialise()
})
// Reload
this.updatePages(options.pagePath, options, true)
})

this.addMonitor(options.routesPath, file => {
if (this.app.Router) {
this.app.Router.loadRewrites(options, () => {
this.app.Router.loadRewriteModule()
})
}
})
this.addMonitor(options.pagePath, pageFile => {
this.updatePages(options.pagePath, options, true)
this.compile(options)
templateStore.reInitialise()
})

this.addMonitor(options.routesPath, file => {
if (this.app.Router) {
this.app.Router.loadRewrites(options, () => {
this.app.Router.loadRewriteModule()
})
}
})

debug('load complete')
debug('load complete')

if (typeof callback === 'function') {
callback()
if (typeof callback === 'function') {
callback()
}
}
})
)
}

Server.prototype.initMiddleware = function (directoryPath, options) {
Expand Down Expand Up @@ -665,8 +663,12 @@ Server.prototype.addComponent = function (options, reload) {
debug('use %s', route.path)
if (options.component[req.method.toLowerCase()]) {
// a matching route found, validate it
return this.app.Router
.validate(route, options.component.options, req, res)
return this.app.Router.validate(
route,
options.component.options,
req,
res
)
.then(() => {
return options.component[req.method.toLowerCase()](req, res, next)
})
Expand Down Expand Up @@ -926,9 +928,9 @@ function onListening (e) {

function onError (err) {
if (err.code === 'EADDRINUSE') {
let message = `Can't connect to local address, is something already listening on ${`${config.get(
'server.host'
)}:${config.get('server.port')}`.underline}?`
let message = `Can't connect to local address, is something already listening on ${
`${config.get('server.host')}:${config.get('server.port')}`.underline
}?`
err.localIp = config.get('server.host')
err.localPort = config.get('server.port')
err.message = message
Expand Down
Loading