Skip to content

Commit

Permalink
add common package with types
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay288 committed Aug 3, 2022
1 parent acbd35e commit ab4218b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
9 changes: 9 additions & 0 deletions common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@metlo/common",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"build": "tsc",
"watch": "tsc -w"
}
}
30 changes: 30 additions & 0 deletions common/src/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export enum RestMethod {
GET = "GET",
HEAD = "HEAD",
POST = "POST",
PUT = "PUT",
PATCH = "PATCH",
DELETE = "DELETE",
CONNECT = "CONNECT",
OPTIONS = "OPTIONS",
TRACE = "TRACE",
}

export enum DataClass {
EMAIL = "Email",
CREDIT_CARD = "Credit Card Number",
SSN = "Social Security Number",
PHONE_NUMBER = "Phone Number",
IP_ADDRESS = "IP Address",
COORDINATE = "Geographic Coordinates",
VIN = "Vehicle Identification Number",
ADDRESS = "Address",
DOB = "Date of Birth",
DL_NUMBER = "Driver License Number",
}

export enum RiskScore {
LOW = "low",
MEDIUM = "medium",
HIGH = "high",
}
40 changes: 40 additions & 0 deletions common/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { RestMethod } from "./enums";

export interface Meta {
incoming: boolean;
source: string;
sourcePort: string;
destination: string;
destinationPort: string;
environment: string;
}

export interface PairObject {
name: string;
value: string;
}

export interface Url {
host: string;
path: string;
parameters: PairObject[];
}

export interface Request {
url: Url;
headers: PairObject[];
body: string;
method: RestMethod;
}

export interface Response {
status: number;
headers: PairObject[];
body: string;
}

export interface TraceParams {
request: Request;
response: Response;
meta: Meta;
}
26 changes: 26 additions & 0 deletions common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compileOnSave": false,
"compilerOptions": {
"target": "es6",
"lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"module": "commonjs",
"pretty": true,
"sourceMap": true,
"declaration": true,
"outDir": "dist",
"allowJs": true,
"noEmit": false,
"skipLibCheck": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"importHelpers": true,
"baseUrl": "src"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}

0 comments on commit ab4218b

Please sign in to comment.