My Elasticsearch cheatsheet with example usage via rest api (still a work-in-progress)
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 Mocha = require('mocha') | |
const mocha = new Mocha() // Instantiate a Mocha instance. | |
var testsDir = [ | |
'./tests/api/users/' | |
] | |
for (var i = 0; i < testsDir.length; i++) { | |
mocha.addFile(testsDir[i]) | |
} |
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 request = require('supertest') | |
const headers = { | |
'Content-type': 'application/json', | |
'x-api-version': '0.1', | |
'token': '' | |
} | |
const baseurl = 'http://localhost:3000/api' | |
module.exports = { | |
/** |
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 chalk = require('chalk') | |
const expect = require('chai').expect | |
const request = require('./../request') | |
describe(chalk.cyanBright.bold('#GET: request to /user'), function () { | |
let auth = null | |
let user = [] | |
before(async function () { | |
this.timeout(10000) // 10 second | |
auth = await request.login({username: 'user', password: 'password'}) |
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
config: | |
target: "http://localhost:8000" | |
http: | |
timeout: 10 # Responses have to be sent within 10 seconds or the request will be aborted | |
processor: "./processor.js" | |
phases: | |
# Create 100 virtual users every second for 60 seconds | |
- duration: 60 # seconds | |
arrivalRate: 100 # virtual users |
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
// out scenario test write here | |
const chalk = require('chalk') | |
const expect = require('chai').expect | |
const request = require('./../request') | |
describe(chalk.cyanBright.bold('#GET: request to /user'), function () { | |
let auth = null | |
let user = [] | |
before(async function () { |
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
{ | |
getNestedObject: (nestedObj, pathArr) => { | |
return pathArr.reduce((obj, key) => (obj && obj[key] !== 'undefined') ? obj[key] : undefined, nestedObj) | |
}, | |
extendObject: (accumulator, currentValue) => { | |
for (var p in currentValue) { | |
try { | |
if (currentValue[p].constructor == Object) { | |
accumulator[p] = _helper.extendObject(accumulator[p], currentValue[p]) |
Setup Golang Workspace (My ZSH Configuration)
Download & Install
https://go.dev/dl/go1.19.10.darwin-arm64.pkg
Update your shell profile
Go expects the path of the go workspace as the $GOPATH
environment variable.
So you need to set up two environments to add the following two lines to your ~/.zshrc
or ~/.bashrc
or ~/.profile
: