Skip to content

Commit

Permalink
✨ 💥 Added more mongo, and memory db options
Browse files Browse the repository at this point in the history
  • Loading branch information
bmiddha committed May 17, 2020
1 parent f0de133 commit 552f675
Show file tree
Hide file tree
Showing 21 changed files with 8,124 additions and 2,420 deletions.
13 changes: 8 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"parser": "@typescript-eslint/parser",
"extends": ["plugin:@typescript-eslint/recommended"],
"parserOptions": {
"ecmaVersion": 2019,
"ecmaVersion": 2020,
"sourceType": "module"
},
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"rules": {
"quotes": ["error", "single"],
"semi": "error",
"no-trailing-spaces": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": 1,
"@typescript-eslint/no-inferrable-types": [
Expand All @@ -19,4 +22,4 @@
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-var-requires": "off"
}
}
}
9 changes: 3 additions & 6 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 13.x]
node-version: [12.x, 14.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '13.x'
node-version: ${{ matrix.node-version }}
- name: Get npm cache directory
id: npm-cache
run: |
Expand All @@ -25,8 +25,5 @@ jobs:
${{ runner.os }}-node-
- run: npm install
- run: npm run build
- name: npm test
run: |
docker run -d -p 6379:6379 redis
npm test
- run: npm test
- uses: codecov/codecov-action@v1
11 changes: 4 additions & 7 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 13.x
node-version: 12.x
- run: npm install
- run: npm run build
- name: npm test
run: |
docker run -d -p 6379:6379 redis
npm test
- run: npm test

publish-npm:
needs: build
Expand All @@ -26,7 +23,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 13.x
node-version: 12.x
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --access public
Expand All @@ -40,7 +37,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 13.x
node-version: 12.x
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist/*
!dist/index.js
coverage
.nyc_output
.DS_Store
.DS_Store
*.tgz
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*
!package.json
!package-lock.json
!dist/index.js
!dist/**/*.d.ts
!README.md
!LICENSE
19 changes: 7 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
"version": "0.2.0",
"configurations": [
{
"name": "Node Inspector",
"type": "node",
"request": "launch",
"args": ["${workspaceRoot}/src/Example.ts"],
"runtimeArgs": ["-r", "ts-node/register"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart",
"runtimeExecutable": "/usr/local/bin/node",
"env": {
"TS_NODE_IGNORE": "false"
}
"name": "Attach",
"port": 9229,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
}
]
}
18 changes: 18 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
coverage:
status:
project:
default:
target: 80%
threshold: 5%
informational: true
if_not_found: success
patch:
default:
target: 80%
threshold: 5%
base: auto
branches:
- master
if_not_found: success
only_pulls: false

36 changes: 17 additions & 19 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
/// <reference types="node" />
import { Redis } from 'ioredis';
import { EventEmitter } from 'events';
import { Connection } from 'mongoose';
import { Redis } from 'ioredis';
import { HashTable } from './db/memory';
export declare type Hook = {
key: string;
urls: string[];
};
declare type RequestFunction = (name: string, jsonData: {}, headersData?: {}) => Promise<void>;
export declare class DatabaseError extends Error {
constructor(message: string);
}
declare type Options = {
mongooseConnection?: Connection;
redisClient?: Redis;
memoryDB?: HashTable<string[]>;
};
interface DB {
[key: string]: string[];
}
interface HashTable<T> {
[key: string]: T;
}
declare type RequestFunction = (name: string, jsonData: {}, headersData?: {}) => Promise<void>;
export declare class WebHooks {
#private;
constructor({ redisClient }: Options);
constructor(options: Options);
/**
* @param {string} name
* @param {Object} jsonData
* @param {Object} headersData?
* @returns boolean
*/
trigger: (name: string, jsonData: {}, headersData?: {}) => boolean;
trigger: (name: string, jsonData: {}, headersData?: {}) => void;
/**
* Add WebHook to name.
*
Expand All @@ -40,20 +44,14 @@ export declare class WebHooks {
*
* @returns Promise
*/
getDB: () => Promise<DB>;
/**
* Return array of URLs for specified name.
*
* @param {string} name
* @returns Promise
*/
getWebHook: (name: string) => Promise<string>;
getDB: () => Promise<Hook[]>;
/**
* Return array of URLs for specified name.
*
* @param {string} name
* @returns Promise
*/
getWebHook: (name: string) => Promise<string[]>;
/**
* Return all request functions hash table
*
Expand Down
Loading

0 comments on commit 552f675

Please sign in to comment.