{"id":18030304,"url":"https://github.com/screamz/warp-prism-kernel","last_synced_at":"2025-03-27T03:31:19.165Z","repository":{"id":88071133,"uuid":"91688038","full_name":"ScreamZ/warp-prism-kernel","owner":"ScreamZ","description":"Modern backend framework on top of Deepstream.io","archived":false,"fork":false,"pushed_at":"2017-06-15T16:21:40.000Z","size":70,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T01:12:14.820Z","etag":null,"topics":["backend","deepstream","framework","javascript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ScreamZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-18T11:59:36.000Z","updated_at":"2019-03-28T17:09:00.000Z","dependencies_parsed_at":"2023-03-04T15:30:29.307Z","dependency_job_id":null,"html_url":"https://github.com/ScreamZ/warp-prism-kernel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreamZ%2Fwarp-prism-kernel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreamZ%2Fwarp-prism-kernel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreamZ%2Fwarp-prism-kernel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreamZ%2Fwarp-prism-kernel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScreamZ","download_url":"https://codeload.github.com/ScreamZ/warp-prism-kernel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245778708,"owners_count":20670682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","deepstream","framework","javascript"],"created_at":"2024-10-30T09:13:57.961Z","updated_at":"2025-03-27T03:31:19.159Z","avatar_url":"https://github.com/ScreamZ.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  Warp Prism Kernel\n  \u003cbr\u003e\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eModern backend framework on top of Deepstream.io\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.typescriptlang.org\"\u003e\u003cimg src=\"https://badges.frapsoft.com/typescript/code/typescript-200x44.png?v=101\" alt=\"Typescript - Style Guide\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\nWarp Prism is a back-end framework which allows you to build real time applications in a easier way.\n\n# Requirements\n\n- **NodeJS** \u003e= 6.0.0\n- **A deepstream.io server.** Feel also free to use deepstreamhub.\n\n# Introduction\n\nDeepstream is a realtime server where clients are connected to communicate between each others and dispatch some actions, it can be mutating objects, asking for some RPC, whatever...\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://deepstream.io/tutorials/core/active-data-providers/data-providers.png\" alt=\"warp prism architecture\"\u003e\n\u003c/p\u003e\n\nIn this architecture, there is (at least) two kinds of clients :\n\n- **Consumers clients** - Which will most of time subscribe to resources, and update some. This still remain on your own implementation.\n- **Providers clients** - Those will provide data to the consumers clients and feed the data stream. **This is that kind of clients that Warp Prism Kernel aim to simplify**.\n\nIn the previous schema, clients A, B and C are **consumers clients**, they subscribe to stocks rate changes where LSE and NASDAQ are **providers clients**, they feed the stream with new rates each seconds and to do that, they could have used WPK.\n\n# Setup\n\nA classic WPK (Warp Prism Kernel) app is just a sum of multiple providers that will do whatever you needs. Think of *Controllers* of usual M.V.C. apps. All of these providers wrapped by a root kernel which allows to use additionnal helpers in order to validate data, check system charge and many other things.\n\n## Register custom providers\nNow you need to register custom providers that will fill your needs. Warp prism give you some helpers in order to simplify this task.\n\nYou need to create one file per *\"category\"* of actions. Below example highlight a set of booking actions, this is standard C.R.U.D. operations.\n\n```typescript\n// src/providers/booking.ts\nimport { Provider } from \"warp-prism-kernel\";\nimport * as deepstream from 'deepstream.io-client-js';\n\nconst bookAction = (data, response: deepstreamIO.RPCResponse) =\u003e {\n  // Your custom logic... see https://deepstreamhub.com/docs/client-js/reqres-response/\n\n  response.send('Not implemented yet !');\n}\n\nexport default new Provider([\n  { name: \"saveBook\", handler: bookAction }\n]);\n```\n\nThe kernel will auto-register your providers. Default looking to a `src/providers`directory, but you can override this behavior by setting the `providersDir` option on the kernel instantiation.\n\n```typescript\nimport * as path from \"path\";\nimport { WarpPrismKernel } from \"warp-prism-kernel\";\n\n// Export application kernel for further uses.\nexport const kernel = new WarpPrismKernel({\n  deepstreamUrl: \"wss://154.deepstreamhub.com?apiKey=e07b9fd3-5569-468f-807b-cee020668042\",\n  providersDir: path.resolve(\"dist\", \"providers\"), // Override providers dir to /dist/providers, useful when using compiled sources like typescript.\n});\n```\n\nTake care of how the system register providers, imagine we have the following directories structure: \n\n- src/\n  - providers/cook.js\n    - subfolder/another-provider.js\n\nFirst a `cook/actionName` provider will be registered and then, because we have subfolder, a `subfolder-another-provider/actionName` provider will be registered. This is how WarpPrism handle folding depth.\n\nHere we are ! Once we will have booted our kernel, we will be able to use this provider on client side that will be named `booking/saveBook`.\n\n## Instantiate a kernel\nThe kernel is the heart of your application. Each application need one in order to work.\n\nStart by creating a `kernel.ts` file in which your kernel is going to live.\n\n```typescript\n// src/kernel.ts\nimport { WarpPrismKernel } from 'warp-prism';\nimport providers from './providers';\n\n// Initialize app kernel\nexport const kernel = new WarpPrismKernel({\n  deepstreamUrl: 'wss://your_server',\n  providers: providers\n});\n```\nYou can import the kernel everywhere to access the service container among others.\nNow we just need to boot the kernel and our app will be running.\n\n```typescript\n// src/main.ts\nimport { kernel } from './kernel';\n\n// Boostrap application\nkernel.boot().then(() =\u003e {\n  console.log('Kernel started !')\n});\n```\n\nThats simple as that ! Enjoy your application.\n\n# Helper services\n\nWarp prism provide some helpers, you can use it by accessing the service container which is kind of a toolbox.\n\n- **System service** - Provide a `systemUnderStress` boolean representing the system state in term of CPU load and RAM usage.\n- **Mailer service** - Provide a way to send e-mail through your application.\n- **Validator service** - Provide a way to validate data that your application receive.\n- **Image service** - Provide a way to validate transform and adapt images that your application receive.\n\n# Kernel configuration\n\nHere are the options you can provide to your kernel on instantiation.\n\n```typescript\ninterface IWarpPrismConfig {\n    deepstreamUrl: string; // The endpoint your backend will try to connect to.\n    providersDir?: string; // A path to providers dir. Default: src/providers\n    authData?: any; // Anything that will be passed to deepstream auth. Depends on your implementation.\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscreamz%2Fwarp-prism-kernel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscreamz%2Fwarp-prism-kernel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscreamz%2Fwarp-prism-kernel/lists"}