-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3ffee56
Showing
69 changed files
with
18,432 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# macOS | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": true, | ||
"arrowParens": "always", | ||
"singleQuote": false, | ||
"trailingComma": "all" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 zebbra AG | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
backend: cd backend && PORT=3001 yarn dev | ||
frontend: cd frontend && PORT=3000 yarn dev |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PORT=3001 | ||
MERAKI_API_KEY=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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# next.js build output | ||
.next | ||
|
||
# moleculer build | ||
dist |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
// Use IntelliSense to learn about possible Node.js debug attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug", | ||
"program": "${workspaceRoot}/node_modules/moleculer/bin/moleculer-runner.ts", | ||
"sourceMaps": true, | ||
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"], | ||
"cwd": "${workspaceRoot}", | ||
"args": ["--mask **/*.service.ts", "services"] | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest", | ||
"program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js", | ||
"args": ["--runInBand"], | ||
"cwd": "${workspaceRoot}", | ||
"runtimeArgs": ["--inspect-brk", "--nolazy"] | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
declare namespace MerakiRootCause { | ||
interface IInventory { | ||
mac: string; | ||
serial: string; | ||
networkId?: string; | ||
model: string; | ||
claimedAt: string; | ||
publicIp?: any; | ||
name: string; | ||
[propName: string]: any; | ||
} | ||
|
||
interface IStatus { | ||
name: string; | ||
serial: string; | ||
mac: string; | ||
publicIp?: any; | ||
networkId?: string; | ||
status: string; | ||
lastReportedAt?: any; | ||
usingCellularFailover: boolean; | ||
wan1Ip?: any; | ||
wan2Ip?: any; | ||
lanIp?: any; | ||
} | ||
|
||
export interface INetwork { | ||
id: string; | ||
organizationId: string; | ||
name: string; | ||
timeZone: string; | ||
tags?: string; | ||
productTypes: string[]; | ||
type: "combined" | "appliance" | "switch" | "wireless"; | ||
disableMyMerakiCom: boolean; | ||
disableRemoteStatusPage: boolean; | ||
} | ||
|
||
export interface INetworkId { | ||
netId: string; | ||
} | ||
|
||
export interface IOrganization { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
export interface IOrganizationId { | ||
orgId: string; | ||
} | ||
|
||
export interface ILicense { | ||
status: string; | ||
expirationDate: string; | ||
licensedDeviceCounts: { | ||
[x: string]: number; | ||
}; | ||
} | ||
} | ||
|
||
export default MerakiRootCause; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module "json-bigint"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Root Cause Detection Backend | ||
|
||
> Meraki root cause detection backend built with [Moleculer](https://moleculer.services). | ||
[](https://moleculer.services) | ||
|
||
## NPM scripts | ||
|
||
```bash | ||
# Start development mode (load all services locally with hot-reload & REPL) | ||
$ yarn dev | ||
|
||
# Uses typescript to transpile service to javascript | ||
yarn build | ||
|
||
# Start production mode (set `SERVICES` env variable to load certain services) (previous build needed) | ||
yarn start | ||
|
||
# Start a CLI and connect to production. Don't forget to set production namespace with `--ns` argument in script | ||
yarn cli | ||
|
||
# Run TSLint | ||
yarn lint | ||
|
||
# Run continuous test mode with watching | ||
yarn ci | ||
|
||
# Run tests & generate coverage report | ||
yarn test | ||
``` | ||
|
||
## Requirements | ||
|
||
- [Node.js v12](https://nodejs.org/en/) | ||
|
||
## Development Setup | ||
|
||
1. Copy `.env.example` to `.env` and change values accordingly | ||
1. Run `yarn dev` | ||
|
||
## Production | ||
|
||
1. `yarn build` | ||
1. `yarn start` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Bottleneck from "bottleneck"; | ||
import Moleculer from "moleculer"; | ||
|
||
class Singleton { | ||
static instance: Bottleneck.Group; | ||
private logger: Moleculer.LoggerInstance; | ||
|
||
constructor(logger: Moleculer.LoggerInstance) { | ||
if (!Singleton.instance) { | ||
this.logger = logger; | ||
|
||
Singleton.instance = new Bottleneck.Group({ | ||
maxConcurrent: 5, | ||
minTime: 200, | ||
highWater: 1000, | ||
}); | ||
|
||
Singleton.instance.on("created", (limiter, key) => { | ||
this.logger.info(`A new limiter was created for "${key}"`); | ||
|
||
limiter.on("error", (error) => { | ||
this.logger.error("Limiter received error", error); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
getInstance() { | ||
return Singleton.instance; | ||
} | ||
} | ||
|
||
export default Singleton; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Util from "util"; | ||
|
||
export const delay = Util.promisify(setTimeout); |
Oops, something went wrong.