Requires json2yaml
and, of course, ActionHero itself installed in the project. This script is fairly crude
and has some hard-coded behaviors, such as expecting to find data models defined on api.models
. It is provided
here only for reference.
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
const { loadSecrets } = require('./src/lib/secrets'); | |
exports.default = async function BOOT() { | |
await loadSecrets('path/to/my/secret'); | |
}; |
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
const ReconnectingWebSocket = require('reconnecting-websocket'); | |
const axios = require('axios'); | |
const WS = require('ws'); | |
// Written with ES5 metaphors to eliminate the need for Babel in test. | |
const KEY_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'.split(''); | |
const generateRequestId = () => { | |
const uuid = []; |
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
const { Initializer, api } = require('actionhero'); | |
const fs = require('fs'); | |
const shortid = require('../lib/shortid'); | |
const safeApiRequestId = params => (params.apiRequestId || shortid(20)) | |
.replace(/[^0-9a-zA-Z_-]/g, '') | |
.substring(0, 64); | |
function instrumentAction(data) { | |
const { action, params, response, connection } = data; |
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
const { Initializer, api } = require('actionhero'); | |
// Adjust to suit... Or optionally move into config... | |
const allowedOrigins = [ | |
'https://staging.mydomain.com', | |
'https://www.mydomain.com', | |
'https://mydomain.com', | |
'http://localhost:8080', | |
]; |
This example provides a proof of concept for simple EJS-based template rendering in ActionHero. Note that EJS is this author's favorite "simple" NodeJS template engine but it could easily be replaced with any other engine you wish.
- Copy
ejs.js
toinitializers/
. - Create a folder called
templates/
and copyleaderboard.js
there. - Copy the sample 'getLeaderboard.js' action to
actions/
.
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
module.exports = { | |
start: function(_api, next) { | |
var maxWorkerAge = 10000; | |
api.log('Removing stuck workers older than ' + maxWorkerAge + 'ms', 'info'); | |
api.resque.queue.cleanOldWorkers(maxWorkerAge, function(err, result) { | |
if (err) { | |
api.log(err, 'error'); | |
} | |
if (Object.keys(result).length > 0) { | |
api.log('Removed stuck workers with errors: ', 'info', result); |
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
const Redis = require('redis'); | |
const Config = require('./config.js'); | |
const Log = require('./log.js'); | |
let redisClient = Redis.createClient(Config.redis.uri); | |
// Locking utility function. This is based on https://github.com/errorception/redis-lock but we only needed a simple use-case of it, | |
// and redis-lock continually retries - we wanted to fail immediately if a lock was in use. | |
class Lock { |
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
FROM node:8.6.0 | |
#USER node | |
# Deal with node-gyp permissions issues in Docker | |
RUN npm -g config set user root | |
RUN mkdir /root/.npm-global | |
ENV PATH=/root/.npm-global/bin:$PATH | |
ENV NPM_CONFIG_PREFIX=/root/.npm-global | |
# Base tools |
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
v8.6.0 | |
5.3.0 | |
[email protected] /Users/chad/projects/paltalk/webng/chat | |
├─┬ @webng/[email protected] | |
│ └── @webng/[email protected] deduped | |
├─┬ @webng/[email protected] | |
│ ├── [email protected] deduped | |
│ └── [email protected] deduped | |
├─┬ @webng/[email protected] | |
│ ├─┬ [email protected] |
NewerOlder