my-project/api/heartbeat/config/routes.json
{
"routes": [{
"method": "GET",
"path": "/heartbeat",
"handler": "heartbeat.index",
"config": {}
}]
$(window).on('hashchange', function() { | |
var i = parseInt(window.location.hash.substr(1)); | |
if (isFinite(i) && $.fancybox.isOpen) { $.fancybox.jumpto(i) } | |
}) |
/** | |
|--------| | |
/--X--| SMTP 1 | | |
/ ^ |--------| | |
/ \--- Retry with next provider | |
|----------------|/ |--------| |------------------| | |
| Mail | ---X--> | SMTP 2 | /->| ^_^ Happy user | | |
|----------------|\ ^ |--------| / |------------------| | |
\ \--- Retry / | |
\ |--------| / |
/** | |
* Calls the translation.googleapis | |
* @param {Object} term, term to be translated the shape of `{key:"", value:""}`, eg. `{key:"fullName", value:"Full name"} | |
* @param {String} target language code eg `en` | |
* @param {String} key Google Api Key generated with `gcloud auth application-default print-access-token` | |
* @returns {Promise} resolve object is in the same shape as input | |
*/ | |
const getTranslation = (term, target, key) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { |
/** | |
* Converts object to array | |
* @param {Object} obj | |
* @returns {Array} | |
* @example | |
* | |
* convertToArray({fullName:"Full Name"}) // returns [{key:"fullName", value:"Full name"}] | |
*/ | |
const convertToArray = obj => | |
Object.keys(obj).map(key => ({ key, value: obj[key] })); |
/** | |
* Proccess all the input array and calls `getTranslation` onEach row | |
* @param {Array} arr, array of objects term to be translated in the shape of `{key:"", value:""}`, eg. `{key:"fullName", value:"Full name"} | |
* @returns {Promise} resolved array is in the same shape as input | |
*/ | |
const processTranslation = (arr, target = "de", api_key = process.env.GKEY) => { | |
return new Promise((resolve) => { | |
/** | |
* | |
* @param {Array} arr input variables array. Terms to be translated. |
/** | |
* Get json from local machine | |
* @param {String} filename on local machine | |
* @returns {Promise} resolved object is JSON | |
*/ | |
const getJSON = filename => { | |
return new Promise((resolve, reject) => { | |
fs.readFile(filename, (err, data) => { | |
if (err) { | |
reject(err); |
/** Runs the application */ | |
// INPUT_FILE is a path to json file with input_vars | |
// TARGET_LANG is langauge code that input_vars should be translated to | |
// process.env.GKEY is Google API Key generated by `gcloud auth application-default print-access-token` | |
getJSON(INPUT_FILE) // get data from input file | |
.then(input_vars => convertToArray(input_vars)) // convert data from object to array | |
.then(input_arr =>processTranslation(input_arr, TARGET_LANG, process.env.GKEY)) // process the whole array | |
.then(transl_arr => convertToObject(transl_arr)) // convert data from array to object |
{ | |
"defaultConnection": "default", | |
"connections": { | |
"default": { | |
"connector": "bookshelf", | |
"settings": { | |
"client": "sqlite", | |
"filename": ".tmp/test.db", | |
"host": "${process.env.DATABASE_HOST || '127.0.0.1'}", | |
"port": "${process.env.DATABASE_PORT || 27017}", |
const fs = require("fs"); | |
const Strapi = require("strapi"); | |
let instance; | |
async function setupStrapi(entryNamesToOpen) { | |
if (!instance) { | |
//delete test database if exists | |
const testDataBase = `${__dirname}/../../.tmp/test.db`; | |
if (fs.existsSync(testDataBase)) { |
my-project/api/heartbeat/config/routes.json
{
"routes": [{
"method": "GET",
"path": "/heartbeat",
"handler": "heartbeat.index",
"config": {}
}]