Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docs/
packages/port-queue/lib/
packages/adapter-beequeue/lib/
packages/adapter-zmq/lib/
32 changes: 32 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
},
extends: [
'standard' // Out of the box StandardJS rules
],
plugins: [
'@typescript-eslint' // Let's us override rules below.
],
rules: {
// Prevent unused vars errors when variables are only used as TS types
// see: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md#options
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false
}
],
'no-unused-vars': 'off',
/**
* hyper rejects promises with a lot of !instanceof Error,
* so we disable this rule
*/
'prefer-promise-reject-errors': 'off'
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env
.eslintcache
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 0 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
}

3 changes: 1 addition & 2 deletions images/couchdb/hyper63.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const couchdb = require('@hyper63/adapter-couchdb')
module.exports = {
app: express,
adapters: [
{ port: 'data', plugins: [ couchdb({ url: process.env.COUCHDB_SERVER})]}
{ port: 'data', plugins: [couchdb({ url: process.env.COUCHDB_SERVER })] }
],
middleware: [jwt]
}

4 changes: 2 additions & 2 deletions images/couchdb/middleware/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const jwt = require('express-jwt')
module.exports = (app) => {
// only secure data endpoint
app.use('/data', jwt({
secret: process.env.SECRET,
secret: process.env.SECRET,
algorithms: ['HS256']
}))
return app
}
}
9 changes: 4 additions & 5 deletions images/dev/hyper63.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ const express = require('@hyper63/app-express')
const minisearch = require('@hyper63/adapter-minisearch')
const zmq = require('@hyper63/adapter-zmq')


module.exports = {
app: express,
adapters: [
{ port: 'cache', plugins: [memory()]},
{ port: 'data', plugins: [pouchdb({dir: process.env.DATA})]},
{ port: 'search', plugins: [minisearch()]},
{ port: 'queue', plugins: [zmq('7373')]}
{ port: 'cache', plugins: [memory()] },
{ port: 'data', plugins: [pouchdb({ dir: process.env.DATA })] },
{ port: 'search', plugins: [minisearch()] },
{ port: 'queue', plugins: [zmq('7373')] }
],
middleware: [jwt]
}
5 changes: 3 additions & 2 deletions images/dev/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// load config and supply it to core
const config = require(__dirname + '/hyper63.config.js')
const app = require('@hyper63/core')(config)
const path = require('path')
const config = require(path.join(__dirname, '/hyper63.config.js'))
require('@hyper63/core')(config)
4 changes: 2 additions & 2 deletions images/dev/middleware/jwt.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const jwt = require('express-jwt')
module.exports = (app) => {
app.use(jwt({
secret: process.env.SECRET,
secret: process.env.SECRET,
algorithms: ['HS256']
}))
return app
}
}
21 changes: 12 additions & 9 deletions images/graphql/hyper63.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ const hooks = require('@hyper63/adapter-hooks')
module.exports = {
app: graphql(),
adapters: [
{ port: 'cache', plugins: [ memory() ] },
{ port: 'data', plugins: [ pouchdb({ dir: process.env.DATA })]},
{ port: 'storage', plugins: [ fs({ dir: process.env.DATA })]},
{ port: 'hooks', plugins: [
hooks([{
matcher: '*',
target: 'http://127.0.0.1:9200/log/_doc'
}])
]}
{ port: 'cache', plugins: [memory()] },
{ port: 'data', plugins: [pouchdb({ dir: process.env.DATA })] },
{ port: 'storage', plugins: [fs({ dir: process.env.DATA })] },
{
port: 'hooks',
plugins: [
hooks([{
matcher: '*',
target: 'http://127.0.0.1:9200/log/_doc'
}])
]
}
]
}
10 changes: 5 additions & 5 deletions images/micro/hyper63.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import bq from '@hyper63/adapter-beequeue'
export default {
app: express,
adapters: [
{ port: 'data', plugins:[couchdb({url: 'http://admin:[email protected]:5984'})]},
{ port: 'cache', plugins:[redis({url: 'redis://0.0.0.0:6379'})]},
{ port: 'storage', plugins:[minio({url: 'http://admin:[email protected]:9000'})]},
{ port: 'search', plugins:[es({url: 'http://0.0.0.0:9200'})]},
{ port: 'queue', plugins:[bq.default({redis: 'redis://0.0.0.0:6379'})]}
{ port: 'data', plugins: [couchdb({ url: 'http://admin:[email protected]:5984' })] },
{ port: 'cache', plugins: [redis({ url: 'redis://0.0.0.0:6379' })] },
{ port: 'storage', plugins: [minio({ url: 'http://admin:[email protected]:9000' })] },
{ port: 'search', plugins: [es({ url: 'http://0.0.0.0:9200' })] },
{ port: 'queue', plugins: [bq.default({ redis: 'redis://0.0.0.0:6379' })] }
]
}
29 changes: 15 additions & 14 deletions images/nano/hyper63.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ const minisearch = require('@hyper63/adapter-minisearch')
const hooks = require('@hyper63/adapter-hooks')
const q = require('@hyper63/adapter-zmq')


module.exports = {
app: express,
adapters: [
{ port: 'cache', plugins: [ memory() ] },
{ port: 'data', plugins: [ pouchdb({dir: process.env.DATA})]},
{ port: 'storage', plugins: [ fs({dir: process.env.DATA})]},
{ port: 'search', plugins: [ minisearch()]},
{ port: 'queue', plugins: [ q('7373') ]},
{ port: 'hooks', plugins: [
hooks([{
matcher: '*',
target: 'http://127.0.0.1:9200/log/_doc'
}])
]}
{ port: 'cache', plugins: [memory()] },
{ port: 'data', plugins: [pouchdb({ dir: process.env.DATA })] },
{ port: 'storage', plugins: [fs({ dir: process.env.DATA })] },
{ port: 'search', plugins: [minisearch()] },
{ port: 'queue', plugins: [q('7373')] },
{
port: 'hooks',
plugins: [
hooks([{
matcher: '*',
target: 'http://127.0.0.1:9200/log/_doc'
}])
]
}
],
logs: {
level: 'INFO' // ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
}
}
}

40 changes: 19 additions & 21 deletions launcher/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
const sh = require("shelljs");
const fs = require("fs");
const path = require("path");
const child_process = require("child_process");
const sh = require('shelljs')
const fs = require('fs')

module.exports = () => {
if (!sh.which("docker-compose")) {
if (!sh.which('docker-compose')) {
sh.echo(
"Sorry, this script requires docker-compose which can be installed from docker desktop"
);
sh.exit(1);
'Sorry, this script requires docker-compose which can be installed from docker desktop'
)
sh.exit(1)
}
if (!sh.test("-e", "~/.hyper63")) {
sh.mkdir("~/.hyper63");
if (!sh.test('-e', '~/.hyper63')) {
sh.mkdir('~/.hyper63')
}

const config = `version: "3.8"
Expand Down Expand Up @@ -52,24 +50,24 @@ services:
- "./data:/usr/share/elasticsearch/data"
environment:
discovery.type: single-node
`;
`

fs.writeFileSync(`${process.env.HOME}/.hyper63/docker-compose.yml`, config);
fs.writeFileSync(`${process.env.HOME}/.hyper63/docker-compose.yml`, config)

sh.cd("~/.hyper63");
sh.exec("docker-compose up -d");
sh.cd('~/.hyper63')
sh.exec('docker-compose up -d')

setTimeout(() => {
sh.exec(
`docker exec hyper63_couchdb_1 curl -X POST -H "Content-Type: application/json" localhost:5984/_cluster_setup -d '{"action":"enable_single_node", "bind_address":"0.0.0.0"}' -u 'admin:password' `,
'docker exec hyper63_couchdb_1 curl -X POST -H "Content-Type: application/json" localhost:5984/_cluster_setup -d \'{"action":"enable_single_node", "bind_address":"0.0.0.0"}\' -u \'admin:password\' ',
{ silent: true },
(code, stdout, stderr) => {
(code) => {
if (code === 0) {
console.log("Successfully setup database");
console.log('Successfully setup database')
} else {
console.log("ERROR! Could not setup database, try to re-run script");
console.log('ERROR! Could not setup database, try to re-run script')
}
}
);
}, 5000);
};
)
}, 5000)
}
5 changes: 5 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

module.exports = {
'*.{js,ts,jsx,tsx}': ['eslint --cache --fix'],
'package.json': ['sort-package-json']
}
63 changes: 36 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@hyper63/monorepo",
"description": "service gateway",
"version": "1.0.0",
"main": "src/index.js",
"private": true,
"description": "service gateway",
"repository": "[email protected]:hyper63/hyper63.git",
"author": "Tom Wilson <[email protected]>",
"license": "MIT",
"private": true,
"author": "Tom Wilson <[email protected]>",
"main": "src/index.js",
"workspaces": [
"packages/core",
"packages/adapter-couchdb",
Expand All @@ -33,20 +33,16 @@
"images/micro",
"images/test"
],
"devDependencies": {
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@twilson63/test-server": "^1.0.1",
"dotenv": "^8.2.0",
"eslint": "^7.10.0",
"fetch-mock": "^9.10.7",
"husky": "^6.0.0",
"node-fetch": "^2.6.1",
"nodemon": "^2.0.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"redis-mock": "^0.54.0",
"tape": "^5.0.1"
"scripts": {
"build": "docker build -t hyper63/hyper63:dev .",
"start:server": "node index.js",
"start": "run-s start:*",
"dev": "nodemon index.js",
"test:core": "tape packages/core/**/**/*_test.js",
"test:integration": "tape -r esm test/**/*_test.js",
"test": "run-p test:core",
"lint": "eslint \"**/*.{ts,tsx,js,jsx}\"",
"prepare": "husky install"
},
"dependencies": {
"@vercel/fetch": "^6.1.0",
Expand All @@ -66,14 +62,27 @@
"redis": "^3.0.2",
"zod": "^2.0.0-beta.20"
},
"scripts": {
"build": "docker build -t hyper63/hyper63:dev .",
"start:server": "node index.js",
"start": "run-s start:*",
"dev": "nodemon index.js",
"test:core": "tape packages/core/**/**/*_test.js",
"test:integration": "tape -r esm test/**/*_test.js",
"test": "run-p test:core",
"prepare": "husky install"
"devDependencies": {
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@twilson63/test-server": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"dotenv": "^8.2.0",
"eslint": "^7.10.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"fetch-mock": "^9.10.7",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"node-fetch": "^2.6.1",
"nodemon": "^2.0.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"redis-mock": "^0.54.0",
"sort-package-json": "^1.50.0",
"tape": "^5.0.1"
}
}
12 changes: 6 additions & 6 deletions packages/adapter-beequeue/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "@hyper63/adapter-beequeue",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",
"main": "lib/index.js",
"typings": "lib/index",
"license": "MIT",
"scripts": {
"build": "tsc",
"test": "tsc && tape lib/*_test.js"
},
"dependencies": {
"@hyper63/port-queue": "^0.1.2",
"bee-queue": "^1.3.1",
Expand All @@ -12,10 +16,6 @@
"typescript": "^4.2.3",
"zod": "^3.0.0-alpha.30"
},
"scripts": {
"build": "tsc",
"test": "tsc && tape lib/*_test.js"
},
"devDependencies": {
"@types/node-fetch": "^2.5.8",
"@types/ramda": "^0.27.39",
Expand Down
Loading