diff --git a/ApiDocs/.env b/ApiDocs/.env index e69de29bb2..87e03e068a 100644 --- a/ApiDocs/.env +++ b/ApiDocs/.env @@ -0,0 +1 @@ +PORT=1445 \ No newline at end of file diff --git a/ApiDocs/.env.tpl b/ApiDocs/.env.tpl index e69de29bb2..48eb72ff8a 100644 --- a/ApiDocs/.env.tpl +++ b/ApiDocs/.env.tpl @@ -0,0 +1 @@ +PORT={{ .Env.API_DOCS_PORT }} \ No newline at end of file diff --git a/ApiDocs/Index.ts b/ApiDocs/Index.ts index ed0515754c..e52a2b0062 100755 --- a/ApiDocs/Index.ts +++ b/ApiDocs/Index.ts @@ -4,9 +4,12 @@ import Express, { ExpressResponse, ExpressStatic, } from 'CommonServer/Utils/Express'; - +import logger from 'CommonServer/Utils/Logger'; +import App from 'CommonServer/Utils/StartServer'; import path from 'path'; +const APP_NAME: string = 'api-docs'; + const app: ExpressApplication = Express.getExpressApp(); // Set the view engine to ejs @@ -26,4 +29,17 @@ app.get(['/', '/docs'], (_req: ExpressRequest, res: ExpressResponse) => { res.render('pages/index'); }); +const init: Function = async (): Promise => { + try { + // init the app + await App(APP_NAME); + + } catch (err) { + logger.error('App Init Failed:'); + logger.error(err); + } +}; + +init(); + export default app; diff --git a/ApiDocs/package.json b/ApiDocs/package.json index f875708f08..1bf039a415 100755 --- a/ApiDocs/package.json +++ b/ApiDocs/package.json @@ -1,46 +1,55 @@ { - "name": "api-docs", + "name": "oneuptime-homepage", "version": "3.0.0", - "description": "oneuptime api refernce", - "main": "Gruntfile.js", - "repository": { - "type": "git", - "url": "git+https://github.com/OneUptime/ApiDocs.git" - }, - "author": "OneUptime Limited.", - "license": "MIT", - "bugs": { - "url": "https://github.com/oneuptime/ApiDocs/issues" - }, - "homepage": "https://github.com/oneuptime/ApiDocs#readme", - "type": "module", - "dependencies": { - "chai": "^4.3.6", - "chai-http": "^4.3.0", - "Common": "file:../Common", - "CommonServer": "file:../CommonServer", - "cors": "^2.8.5", - "cross-env": "^7.0.3", - "ejs": "^3.1.6", - "express": "^4.17.3", - "mocha": "^9.2.2", - "Model": "file:../Model", - "path": "^0.12.7", - "ts-node": "^10.9.1" - }, "scripts": { "preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'", "start": "node --require ts-node/register Index.ts", "compile": "tsc", "dev": "npx nodemon", - "test": "jest" + "test": "jest", + "lighthouse-test": "jest --forceExit lighthouse-tests/test/index.test.js --env=node", + "lighthouse": "start-server-and-test http://localhost:1444", + "smoketest": "jest --forceExit smoketest/index.test.js --env=node", + "audit": "npm audit --audit-level=low", + "light-house": "node lighthouse.js --web", + "light-house-mobile": "node lighthouse.js --mobile", + "dep-check": "depcheck ./ --skip-missing=true --ignores='ejs,puppeteer'" + }, + "dependencies": { + "@types/body-parser": "^1.19.2", + "@types/cli-table": "^0.3.0", + "@types/compression": "^1.7.2", + "@types/ejs": "^3.1.1", + "@types/minify": "^8.0.0", + "@types/try-to-catch": "^3.0.0", + "axios": "^0.26.1", + "body-parser": "^1.19.2", + "cli-table": "^0.3.11", + "Common": "file:../Common", + "CommonServer": "file:../CommonServer", + "compression": "^1.7.4", + "ejs": "^3.1.8", + "express": "^4.18.1", + "Model": "file:../Model", + "ts-node": "^10.9.1", + "xmlbuilder2": "^3.0.2" }, "resolutions": {}, "devDependencies": { + "@types/jest": "^27.5.1", "@types/node": "^17.0.22", + "chrome-launcher": "^0.15.0", + "commander": "^9.1.0", "depcheck": "^1.4.3", + "jest": "^28.1.0", + "lighthouse": "^9.5.0", "nodemon": "^2.0.20", "npm-force-resolutions": "0.0.10", - "ts-node-dev": "^1.1.8" + "ora": "^6.1.0", + "puppeteer": "^13.5.1", + "start-server-and-test": "^1.14.0", + "ts-jest": "^28.0.2", + "ts-node-dev": "^1.1.8", + "typescript": "^4.6.4" } -} \ No newline at end of file +} diff --git a/ApiDocs/tsconfig.json b/ApiDocs/tsconfig.json index 8d1e02358f..d58d16395d 100644 --- a/ApiDocs/tsconfig.json +++ b/ApiDocs/tsconfig.json @@ -21,8 +21,8 @@ "target": "es2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ "jsx": "react" /* Specify what JSX code is generated. */, - "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + "experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */, + "emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */, // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ @@ -31,16 +31,19 @@ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ /* Modules */ - "module": "es2022" /* Specify what module code is generated. */, - "rootDir": "", /* Specify the root folder within your source files. */ - "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "module": "es2022" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */, // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ "typeRoots": [ - - ], /* Specify multiple folders that act like `./node_modules/@types`. */ - "types": ["node"], /* Specify type package names to be included without being referenced in a source file. */ + "./node_modules/@types" + ] /* Specify multiple folders that act like `./node_modules/@types`. */, + "types": [ + "node", + "jest" + ] /* Specify type package names to be included without being referenced in a source file. */, // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "resolveJsonModule": true, /* Enable importing .json files */ // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ @@ -54,9 +57,9 @@ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ // "declarationMap": true, /* Create sourcemaps for d.ts files. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + "sourceMap": true /* Create source map files for emitted JavaScript files. */, // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ - "outDir": "build/dist", /* Specify an output folder for all emitted files. */ + "outDir": "./build/dist" /* Specify an output folder for all emitted files. */, // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ @@ -84,22 +87,22 @@ /* Type Checking */ "strict": true /* Enable all strict type-checking options. */, - "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ - "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ - "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ - "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ - "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ - "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ - "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ - "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ + "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied `any` type.. */, + "strictNullChecks": true /* When type checking, take into account `null` and `undefined`. */, + "strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */, + "strictBindCallApply": true /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */, + "strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */, + "noImplicitThis": true /* Enable error reporting when `this` is given the type `any`. */, + "useUnknownInCatchVariables": true /* Type catch clause variables as 'unknown' instead of 'any'. */, + "alwaysStrict": true /* Ensure 'use strict' is always emitted. */, + "noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */, + "noUnusedParameters": true /* Raise an error when a function parameter isn't read */, + "exactOptionalPropertyTypes": true /* Interpret optional property types as written, rather than adding 'undefined'. */, + "noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */, + "noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */, + "noUncheckedIndexedAccess": true /* Include 'undefined' in index signature results */, + "noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */, + "noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type */, // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ diff --git a/ApiDocs/views/pages/index.ejs b/ApiDocs/views/pages/index.ejs index a100318a95..45192c3a27 100755 --- a/ApiDocs/views/pages/index.ejs +++ b/ApiDocs/views/pages/index.ejs @@ -1,523 +1,877 @@ - - - - Protocol API Reference - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Protocol API Reference + + + - - - - - - - - - - - - - - - - - -
-
-
-
-
+
+
+
+
+
+
+ +
+ +
+
+

API Documentation

+

Use the Protocol API to access contacts, conversations, group messages, and more and + seamlessly integrate your product into the workflows of dozens of devoted Protocol users.

+ +

Getting started

+

To get started, create a new application in your developer settings, + then read about how to make requests for the resources you need to access using our HTTP APIs or + dedicated client SDKs. When your integration is ready to go live, publish it to our integrations directory to reach the Protocol community.

+ +
+

+ + + Guides + +

+
+
+

Authentication

+

Learn how to authenticate your API + requests.

+

+ + Read more + + +

+
+
+

Pagination

+

Understand how to work with + paginated responses.

+

+ + Read more + + +

+
+
+

Errors

+

Read about the different types of + errors returned by the API.

+

+ + Read more + + +

+
+
+

Webhooks

+

Learn how to programmatically + configure webhooks for your app.

+

+ + Read more + + +

+
+
+
+
+

Resources +

+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+

Contacts

+

Learn about the contact model and + how to create, retrieve, update, delete, and list contacts.

+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+

Conversations

+

Learn about the conversation + model and how to create, retrieve, update, delete, and list conversations.

+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+

Messages

+

Learn about the message model and + how to create, retrieve, update, delete, and list messages.

+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+

Groups

+

Learn about the group model and + how to create, retrieve, update, delete, and list groups.

+
+
+
+
+
+
+
- - - - - - - +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config.tpl.env b/config.tpl.env index d1420cfcb9..0bdc5a6b94 100644 --- a/config.tpl.env +++ b/config.tpl.env @@ -47,9 +47,11 @@ DATA_INGESTOR_HOSTNAME=data-ingestor:3200 ACCOUNTS_HOSTNAME=accounts:3003 HOME_HOSTNAME=home:1444 WORKER_HOSTNAME=worker:3452 +API_DOCS_HOSTNAME=api-docs:1445 # Routes. Usually does not need to change. REALTIME_ROUTE=/realtime +API_DOCS_ROUTE=/docs MAIL_ROUTE=/mail DASHBOARD_ROUTE=/dashboard DASHBOARD_API_ROUTE=/api @@ -67,6 +69,7 @@ STATUS_PAGE_ROUTE=/status-page #Ports. Usually they dont need to change. DASHBOARD_API_PORT=3002 +API_DOCS_PORT=1445 WORKFLOW_PORT=3099 ALERT_PORT=3088 FILE_PORT=3125 diff --git a/package.json b/package.json index 806278a4d9..847d141a09 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "logs": "sudo docker compose logs --tail=100 -f $npm_config_services", "write-logs": "sudo docker compose logs -f $npm_config_services > logs.txt", "build": "npm run prerun && sudo docker compose build $npm_config_services", - "force-build": "bash remove-node-modules.sh && npm run prerun && sudo docker compose build --no-cache $npm_config_services && bash install-node-modules.sh", + "force-build": "npm run prerun && sudo docker compose build --no-cache $npm_config_services", "force-build-dev": "npm run config-to-dev && npm run force-build", "kill": "npm run stop", "prod": "npm run prerun && docker compose up -d",