diff --git a/examples/active-class-name/components/Link.js b/examples/active-class-name/components/Link.js index eadf822e..fc555524 100644 --- a/examples/active-class-name/components/Link.js +++ b/examples/active-class-name/components/Link.js @@ -7,7 +7,9 @@ const ActiveLink = ({ router, children, ...props }) => { let className = child.props.className || null if (router.pathname === props.href && props.activeClassName) { - className = `${className !== null ? className : ''} ${props.activeClassName}`.trim() + className = `${className !== null ? className : ''} ${ + props.activeClassName + }`.trim() } delete props.activeClassName diff --git a/examples/analyze-bundles/pages/about.js b/examples/analyze-bundles/pages/about.js index e5db9621..5fd65c2b 100644 --- a/examples/analyze-bundles/pages/about.js +++ b/examples/analyze-bundles/pages/about.js @@ -1,3 +1 @@ -export default () => ( -
About us
-) +export default () =>
About us
diff --git a/examples/analyze-bundles/pages/contact.js b/examples/analyze-bundles/pages/contact.js index ad1b3696..b0fdbcd7 100644 --- a/examples/analyze-bundles/pages/contact.js +++ b/examples/analyze-bundles/pages/contact.js @@ -1,5 +1 @@ -export default () => ( -
- This is the contact page. -
-) +export default () =>
This is the contact page.
diff --git a/examples/analyze-bundles/pages/index.js b/examples/analyze-bundles/pages/index.js index 11df6e46..db9da9fc 100644 --- a/examples/analyze-bundles/pages/index.js +++ b/examples/analyze-bundles/pages/index.js @@ -21,7 +21,9 @@ export default class Index extends React.Component {

Home Page

Welcome, {name}

- About Page + + About Page +
) diff --git a/examples/basic-export/pages/about.js b/examples/basic-export/pages/about.js index e5db9621..5fd65c2b 100644 --- a/examples/basic-export/pages/about.js +++ b/examples/basic-export/pages/about.js @@ -1,3 +1 @@ -export default () => ( -
About us
-) +export default () =>
About us
diff --git a/examples/basic-export/pages/about2.js b/examples/basic-export/pages/about2.js index 44ce6571..fd84a738 100644 --- a/examples/basic-export/pages/about2.js +++ b/examples/basic-export/pages/about2.js @@ -1,3 +1 @@ -export default () => ( -
About 2
-) +export default () =>
About 2
diff --git a/examples/basic-export/pages/day/index.js b/examples/basic-export/pages/day/index.js index 5a581008..cc400491 100644 --- a/examples/basic-export/pages/day/index.js +++ b/examples/basic-export/pages/day/index.js @@ -1,3 +1 @@ -export default () => ( -
Hello Day
-) +export default () =>
Hello Day
diff --git a/examples/basic-export/pages/index.js b/examples/basic-export/pages/index.js index d120061e..c1af49f3 100644 --- a/examples/basic-export/pages/index.js +++ b/examples/basic-export/pages/index.js @@ -1,4 +1,9 @@ import Link from 'next/link' export default () => ( -
Hello World. About
+
+ Hello World.{' '} + + About + +
) diff --git a/examples/custom-charset/server.js b/examples/custom-charset/server.js index 5cc46fb4..a67e473a 100644 --- a/examples/custom-charset/server.js +++ b/examples/custom-charset/server.js @@ -7,15 +7,13 @@ const dev = process.env.NODE_ENV !== 'production' const app = next({ dev }) const handle = app.getRequestHandler() -app.prepare() - .then(() => { - createServer((req, res) => { - const parsedUrl = parse(req.url, true) - res.setHeader('Content-Type', 'text/html; charset=iso-8859-2') - handle(req, res, parsedUrl) - }) - .listen(port, (err) => { - if (err) throw err - console.log(`> Ready on http://localhost:${port}`) - }) +app.prepare().then(() => { + createServer((req, res) => { + const parsedUrl = parse(req.url, true) + res.setHeader('Content-Type', 'text/html; charset=iso-8859-2') + handle(req, res, parsedUrl) + }).listen(port, err => { + if (err) throw err + console.log(`> Ready on http://localhost:${port}`) }) +}) diff --git a/examples/custom-server-actionhero/actions/render.js b/examples/custom-server-actionhero/actions/render.js index 60bd2700..c5c964e9 100644 --- a/examples/custom-server-actionhero/actions/render.js +++ b/examples/custom-server-actionhero/actions/render.js @@ -1,5 +1,5 @@ 'use strict' -const {Action, api} = require('actionhero') +const { Action, api } = require('actionhero') module.exports = class CreateChatRoom extends Action { constructor () { diff --git a/examples/custom-server-actionhero/config/api.js b/examples/custom-server-actionhero/config/api.js index 3e85fc02..2c474507 100644 --- a/examples/custom-server-actionhero/config/api.js +++ b/examples/custom-server-actionhero/config/api.js @@ -3,7 +3,7 @@ const path = require('path') exports['default'] = { - general: (api) => { + general: api => { const packageJSON = require(api.projectRoot + path.sep + 'package.json') return { @@ -46,16 +46,16 @@ exports['default'] = { cliIncludeInternal: true, // configuration for your actionhero project structure paths: { - 'action': [path.join(__dirname, '/../actions')], - 'task': [path.join(__dirname, '/../tasks')], - 'public': [path.join(__dirname, '/../static')], - 'pid': [path.join(__dirname, '/../pids')], - 'log': [path.join(__dirname, '/../log')], - 'server': [path.join(__dirname, '/../servers')], - 'cli': [path.join(__dirname, '/../bin')], - 'initializer': [path.join(__dirname, '/../initializers')], - 'plugin': [path.join(__dirname, '/../node_modules')], - 'locale': [path.join(__dirname, '/../locales')] + action: [path.join(__dirname, '/../actions')], + task: [path.join(__dirname, '/../tasks')], + public: [path.join(__dirname, '/../static')], + pid: [path.join(__dirname, '/../pids')], + log: [path.join(__dirname, '/../log')], + server: [path.join(__dirname, '/../servers')], + cli: [path.join(__dirname, '/../bin')], + initializer: [path.join(__dirname, '/../initializers')], + plugin: [path.join(__dirname, '/../node_modules')], + locale: [path.join(__dirname, '/../locales')] }, // hash containing chat rooms you wish to be created at server boot startingChatRooms: { @@ -67,17 +67,17 @@ exports['default'] = { } exports.test = { - general: (api) => { + general: api => { return { id: 'test-server-' + process.pid, serverToken: 'serverToken-' + process.pid, developmentMode: true, startingChatRooms: { - 'defaultRoom': {}, - 'otherRoom': {} + defaultRoom: {}, + otherRoom: {} }, paths: { - 'locale': [ + locale: [ // require('os').tmpdir() + require('path').sep + 'locales', path.join(__dirname, '/../locales') ] @@ -88,7 +88,7 @@ exports.test = { } exports.production = { - general: (api) => { + general: api => { return { fileRequestLogLevel: 'debug', developmentMode: false diff --git a/examples/custom-server-actionhero/config/errors.js b/examples/custom-server-actionhero/config/errors.js index 458afb0f..fc9bcce4 100644 --- a/examples/custom-server-actionhero/config/errors.js +++ b/examples/custom-server-actionhero/config/errors.js @@ -2,9 +2,9 @@ // error messages can be strings of objects exports['default'] = { - errors: (api) => { + errors: api => { return { - '_toExpand': false, + _toExpand: false, // /////////////// // SERIALIZERS // @@ -12,28 +12,28 @@ exports['default'] = { serializers: { servers: { - web: (error) => { + web: error => { if (error.message) { return String(error.message) } else { return error } }, - websocket: (error) => { + websocket: error => { if (error.message) { return String(error.message) } else { return error } }, - socket: (error) => { + socket: error => { if (error.message) { return String(error.message) } else { return error } }, - specHelper: (error) => { + specHelper: error => { if (error.message) { return 'Error: ' + String(error.message) } else { @@ -49,38 +49,51 @@ exports['default'] = { // When a params for an action is invalid invalidParams: (data, validationErrors) => { - if (validationErrors.length >= 0) { return validationErrors[0] } + if (validationErrors.length >= 0) { + return validationErrors[0] + } return data.connection.localize('actionhero.errors.invalidParams') }, // When a required param for an action is not provided missingParams: (data, missingParams) => { - return data.connection.localize(['actionhero.errors.missingParams', {param: missingParams[0]}]) + return data.connection.localize([ + 'actionhero.errors.missingParams', + { param: missingParams[0] } + ]) }, // user requested an unknown action - unknownAction: (data) => { + unknownAction: data => { return data.connection.localize('actionhero.errors.unknownAction') }, // action not useable by this client/server type - unsupportedServerType: (data) => { - return data.connection.localize(['actionhero.errors.unsupportedServerType', {type: data.connection.type}]) + unsupportedServerType: data => { + return data.connection.localize([ + 'actionhero.errors.unsupportedServerType', + { type: data.connection.type } + ]) }, // action failed because server is mid-shutdown - serverShuttingDown: (data) => { + serverShuttingDown: data => { return data.connection.localize('actionhero.errors.serverShuttingDown') }, // action failed because this client already has too many pending acitons // limit defined in api.config.general.simultaneousActions - tooManyPendingActions: (data) => { - return data.connection.localize('actionhero.errors.tooManyPendingActions') + tooManyPendingActions: data => { + return data.connection.localize( + 'actionhero.errors.tooManyPendingActions' + ) }, dataLengthTooLarge: (maxLength, receivedLength) => { - return api.i18n.localize(['actionhero.errors.dataLengthTooLarge', {maxLength: maxLength, receivedLength: receivedLength}]) + return api.i18n.localize([ + 'actionhero.errors.dataLengthTooLarge', + { maxLength: maxLength, receivedLength: receivedLength } + ]) }, // /////////////// @@ -89,18 +102,21 @@ exports['default'] = { // The body message to accompany 404 (file not found) errors regarding flat files // You may want to load in the contnet of 404.html or similar - fileNotFound: (connection) => { + fileNotFound: connection => { return connection.localize(['actionhero.errors.fileNotFound']) }, // user didn't request a file - fileNotProvided: (connection) => { + fileNotProvided: connection => { return connection.localize('actionhero.errors.fileNotProvided') }, // something went wrong trying to read the file fileReadError: (connection, error) => { - return connection.localize(['actionhero.errors.fileReadError', {error: String(error)}]) + return connection.localize([ + 'actionhero.errors.fileReadError', + { error: String(error) } + ]) }, // /////////////// @@ -108,41 +124,54 @@ exports['default'] = { // /////////////// verbNotFound: (connection, verb) => { - return connection.localize(['actionhero.errors.verbNotFound', {verb: verb}]) + return connection.localize([ + 'actionhero.errors.verbNotFound', + { verb: verb } + ]) }, verbNotAllowed: (connection, verb) => { - return connection.localize(['actionhero.errors.verbNotAllowed', {verb: verb}]) + return connection.localize([ + 'actionhero.errors.verbNotAllowed', + { verb: verb } + ]) }, - connectionRoomAndMessage: (connection) => { + connectionRoomAndMessage: connection => { return connection.localize('actionhero.errors.connectionRoomAndMessage') }, connectionNotInRoom: (connection, room) => { - return connection.localize(['actionhero.errors.connectionNotInRoom', {room: room}]) + return connection.localize([ + 'actionhero.errors.connectionNotInRoom', + { room: room } + ]) }, connectionAlreadyInRoom: (connection, room) => { - return connection.localize(['actionhero.errors.connectionAlreadyInRoom', {room: room}]) + return connection.localize([ + 'actionhero.errors.connectionAlreadyInRoom', + { room: room } + ]) }, - connectionRoomHasBeenDeleted: (room) => { - return api.i18n.localize('actionhero.errors.connectionRoomHasBeenDeleted') + connectionRoomHasBeenDeleted: room => { + return api.i18n.localize( + 'actionhero.errors.connectionRoomHasBeenDeleted' + ) }, - connectionRoomNotExist: (room) => { + connectionRoomNotExist: room => { return api.i18n.localize('actionhero.errors.connectionRoomNotExist') }, - connectionRoomExists: (room) => { + connectionRoomExists: room => { return api.i18n.localize('actionhero.errors.connectionRoomExists') }, - connectionRoomRequired: (room) => { + connectionRoomRequired: room => { return api.i18n.localize('actionhero.errors.connectionRoomRequired') } - } } } diff --git a/examples/custom-server-actionhero/config/i18n.js b/examples/custom-server-actionhero/config/i18n.js index 979beef7..0c42799f 100644 --- a/examples/custom-server-actionhero/config/i18n.js +++ b/examples/custom-server-actionhero/config/i18n.js @@ -1,5 +1,5 @@ exports['default'] = { - i18n: (api) => { + i18n: api => { return { // visit https://github.com/mashpie/i18n-node to see all configuration options // locale path can be configired from within ./config/api.js @@ -28,7 +28,7 @@ exports['default'] = { } exports.test = { - i18n: (api) => { + i18n: api => { return { updateFiles: true } diff --git a/examples/custom-server-actionhero/config/logger.js b/examples/custom-server-actionhero/config/logger.js index a67e323c..8c447479 100644 --- a/examples/custom-server-actionhero/config/logger.js +++ b/examples/custom-server-actionhero/config/logger.js @@ -4,16 +4,18 @@ const fs = require('fs') const cluster = require('cluster') exports['default'] = { - logger: (api) => { - let logger = {transports: []} + logger: api => { + let logger = { transports: [] } // console logger if (cluster.isMaster) { logger.transports.push(function (api, winston) { - return new (winston.transports.Console)({ + return new winston.transports.Console({ colorize: true, level: 'info', - timestamp: function () { return api.id + ' @ ' + new Date().toISOString() } + timestamp: function () { + return api.id + ' @ ' + new Date().toISOString() + } }) }) } @@ -26,15 +28,18 @@ exports['default'] = { fs.mkdirSync(logDirectory) } catch (e) { if (e.code !== 'EEXIST') { - throw (new Error('Cannot create log directory @ ' + logDirectory)) + throw new Error('Cannot create log directory @ ' + logDirectory) } } } - return new (winston.transports.File)({ - filename: api.config.general.paths.log[0] + '/' + api.pids.title + '.log', + return new winston.transports.File({ + filename: + api.config.general.paths.log[0] + '/' + api.pids.title + '.log', level: 'info', - timestamp: function () { return api.id + ' @ ' + new Date().toISOString() } + timestamp: function () { + return api.id + ' @ ' + new Date().toISOString() + } }) }) @@ -52,7 +57,7 @@ exports['default'] = { } exports.test = { - logger: (api) => { + logger: api => { return { transports: null } diff --git a/examples/custom-server-actionhero/config/plugins.js b/examples/custom-server-actionhero/config/plugins.js index 01b01572..3ed9a464 100644 --- a/examples/custom-server-actionhero/config/plugins.js +++ b/examples/custom-server-actionhero/config/plugins.js @@ -1,5 +1,5 @@ exports['default'] = { - plugins: (api) => { + plugins: api => { /* If you want to use plugins in your application, include them here: diff --git a/examples/custom-server-actionhero/config/redis.js b/examples/custom-server-actionhero/config/redis.js index f392d929..67273b92 100644 --- a/examples/custom-server-actionhero/config/redis.js +++ b/examples/custom-server-actionhero/config/redis.js @@ -11,15 +11,20 @@ if (process.env.REDIS_URL) { } exports['default'] = { - redis: (api) => { + redis: api => { // konstructor: The redis client constructor method. All redis methods must be promises // args: The arguments to pass to the constructor // buildNew: is it `new konstructor()` or just `konstructor()`? function retryStrategy (times) { if (times === 1) { - const error = 'Unable to connect to Redis - please check your Redis config!' - if (process.env.NODE_ENV === 'test') { console.error(error) } else { api.log(error, 'error') } + const error = + 'Unable to connect to Redis - please check your Redis config!' + if (process.env.NODE_ENV === 'test') { + console.error(error) + } else { + api.log(error, 'error') + } return 5000 } return Math.min(times * 50, maxBackoff) @@ -28,20 +33,44 @@ exports['default'] = { return { enabled: true, - '_toExpand': false, + _toExpand: false, client: { konstructor: require('ioredis'), - args: [{ port: port, host: host, password: password, db: db, retryStrategy: retryStrategy }], + args: [ + { + port: port, + host: host, + password: password, + db: db, + retryStrategy: retryStrategy + } + ], buildNew: true }, subscriber: { konstructor: require('ioredis'), - args: [{ port: port, host: host, password: password, db: db, retryStrategy: retryStrategy }], + args: [ + { + port: port, + host: host, + password: password, + db: db, + retryStrategy: retryStrategy + } + ], buildNew: true }, tasks: { konstructor: require('ioredis'), - args: [{ port: port, host: host, password: password, db: db, retryStrategy: retryStrategy }], + args: [ + { + port: port, + host: host, + password: password, + db: db, + retryStrategy: retryStrategy + } + ], buildNew: true } } diff --git a/examples/custom-server-actionhero/config/routes.js b/examples/custom-server-actionhero/config/routes.js index c126f8e5..3d386ba2 100644 --- a/examples/custom-server-actionhero/config/routes.js +++ b/examples/custom-server-actionhero/config/routes.js @@ -1,9 +1,7 @@ exports['default'] = { - routes: (api) => { + routes: api => { return { - get: [ - { path: '/', matchTrailingPathParts: true, action: 'render' } - ] + get: [{ path: '/', matchTrailingPathParts: true, action: 'render' }] } } } diff --git a/examples/custom-server-actionhero/config/servers/socket.js b/examples/custom-server-actionhero/config/servers/socket.js index f4c918d2..cb541979 100644 --- a/examples/custom-server-actionhero/config/servers/socket.js +++ b/examples/custom-server-actionhero/config/servers/socket.js @@ -2,9 +2,9 @@ exports['default'] = { servers: { - socket: (api) => { + socket: api => { return { - enabled: (process.env.ENABLE_TCP_SERVER !== undefined), + enabled: process.env.ENABLE_TCP_SERVER !== undefined, // TCP or TLS? secure: false, // Passed to tls.createServer if secure=true. Should contain SSL certificates @@ -26,7 +26,7 @@ exports['default'] = { exports.test = { servers: { - socket: (api) => { + socket: api => { return { enabled: true, port: 1001 + (process.pid % 64535), diff --git a/examples/custom-server-actionhero/config/servers/web.js b/examples/custom-server-actionhero/config/servers/web.js index 6ad3dd09..ccb10bfe 100644 --- a/examples/custom-server-actionhero/config/servers/web.js +++ b/examples/custom-server-actionhero/config/servers/web.js @@ -4,7 +4,7 @@ const os = require('os') exports['default'] = { servers: { - web: (api) => { + web: api => { return { enabled: true, // HTTP or HTTPS? @@ -13,7 +13,9 @@ exports['default'] = { serverOptions: {}, // Should we redirect all traffic to the first host in this array if hte request header doesn't match? // i.e.: [ 'https://www.site.com' ] - allowedRequestHosts: process.env.ALLOWED_HOSTS ? process.env.ALLOWED_HOSTS.split(',') : [], + allowedRequestHosts: process.env.ALLOWED_HOSTS + ? process.env.ALLOWED_HOSTS.split(',') + : [], // Port or Socket Path port: process.env.PORT || 8080, // Which IP to listen on (use '0.0.0.0' for all; '::' for all on ipv4 and ipv6) @@ -23,7 +25,8 @@ exports['default'] = { httpHeaders: { 'X-Powered-By': api.config.general.serverName, 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS, TRACE', + 'Access-Control-Allow-Methods': + 'HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS, TRACE', 'Access-Control-Allow-Headers': 'Content-Type' }, // Route that actions will be served from; secondary route against this route will be treated as actions, @@ -92,7 +95,7 @@ exports['default'] = { exports.production = { servers: { - web: (api) => { + web: api => { return { padding: null, metadataOptions: { @@ -106,7 +109,7 @@ exports.production = { exports.test = { servers: { - web: (api) => { + web: api => { return { secure: false, port: process.env.PORT || 1000 + (process.pid % 64535), diff --git a/examples/custom-server-actionhero/config/servers/websocket.js b/examples/custom-server-actionhero/config/servers/websocket.js index f72c0975..1800290d 100644 --- a/examples/custom-server-actionhero/config/servers/websocket.js +++ b/examples/custom-server-actionhero/config/servers/websocket.js @@ -4,7 +4,7 @@ exports['default'] = { servers: { - websocket: (api) => { + websocket: api => { return { enabled: true, // you can pass a FQDN (string) here or 'window.location.origin' @@ -55,7 +55,7 @@ exports['default'] = { exports['test'] = { servers: { - websocket: (api) => { + websocket: api => { return { clientUrl: null } } } diff --git a/examples/custom-server-actionhero/config/tasks.js b/examples/custom-server-actionhero/config/tasks.js index b5652c2e..0febe8aa 100644 --- a/examples/custom-server-actionhero/config/tasks.js +++ b/examples/custom-server-actionhero/config/tasks.js @@ -1,5 +1,5 @@ exports['default'] = { - tasks: (api) => { + tasks: api => { return { // Should this node run a scheduler to promote delayed tasks? scheduler: false, @@ -52,7 +52,7 @@ exports['default'] = { } exports.test = { - tasks: (api) => { + tasks: api => { return { timeout: 100, checkTimeout: 50 diff --git a/examples/custom-server-actionhero/initializers/next.js b/examples/custom-server-actionhero/initializers/next.js index 2297e70c..0f650552 100644 --- a/examples/custom-server-actionhero/initializers/next.js +++ b/examples/custom-server-actionhero/initializers/next.js @@ -1,5 +1,5 @@ 'use strict' -const {Initializer, api} = require('actionhero') +const { Initializer, api } = require('actionhero') const next = require('next') module.exports = class NextInitializer extends Initializer { @@ -10,18 +10,22 @@ module.exports = class NextInitializer extends Initializer { async initialize () { api.next = { - render: async (connection) => { - if (connection.type !== 'web') { throw new Error('Connections for NEXT apps must be of type "web"') } + render: async connection => { + if (connection.type !== 'web') { + throw new Error('Connections for NEXT apps must be of type "web"') + } const req = connection.rawConnection.req const res = connection.rawConnection.res return api.next.handle(req, res) } } - api.next.dev = (api.env === 'development') - if (api.next.dev) { api.log('Running next in development mode...') } + api.next.dev = api.env === 'development' + if (api.next.dev) { + api.log('Running next in development mode...') + } - api.next.app = next({dev: api.next.dev}) + api.next.app = next({ dev: api.next.dev }) api.next.handle = api.next.app.getRequestHandler() await api.next.app.prepare() } diff --git a/examples/custom-server-actionhero/pages/index.js b/examples/custom-server-actionhero/pages/index.js index d044fc1e..fe5882e3 100644 --- a/examples/custom-server-actionhero/pages/index.js +++ b/examples/custom-server-actionhero/pages/index.js @@ -3,7 +3,15 @@ import Link from 'next/link' export default () => ( ) diff --git a/examples/custom-server-express/pages/index.js b/examples/custom-server-express/pages/index.js index 5a892506..a369054a 100644 --- a/examples/custom-server-express/pages/index.js +++ b/examples/custom-server-express/pages/index.js @@ -3,13 +3,18 @@ import Link from 'next/link' export default () => (