From cb04a081eee79489e3fd131d7283211f1e62f85c Mon Sep 17 00:00:00 2001 From: Junaid Atari Date: Fri, 29 Nov 2024 18:37:22 +0500 Subject: [PATCH] initial commit --- .editorconfig | 19 ++++ .env.sample | 8 ++ .gitignore | 39 +++++++ LICENSE | 201 +++++++++++++++++++++++++++++++++++ README.md | 74 +++++++++++++ __tests__/App.test.ts | 21 ++++ deno.json | 101 ++++++++++++++++++ deno.lock | 238 ++++++++++++++++++++++++++++++++++++++++++ ecosystem.config.js | 21 ++++ src/app/index.ts | 13 +++ src/cron.ts | 11 ++ src/index.ts | 16 +++ 12 files changed, 762 insertions(+) create mode 100644 .editorconfig create mode 100644 .env.sample create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 __tests__/App.test.ts create mode 100644 deno.json create mode 100644 deno.lock create mode 100644 ecosystem.config.js create mode 100644 src/app/index.ts create mode 100644 src/cron.ts create mode 100644 src/index.ts diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d307069 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 172 +tab_width = 2 + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false + +[*.{js,json,ts,yml,yaml}] +indent_size = 2 +indent_style = space diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..8bb2dea --- /dev/null +++ b/.env.sample @@ -0,0 +1,8 @@ +# +# @author Junaid Atari +# @see https://github.com/jiifw/deno-ts-boilerplate +# @link https://github.com/blacksmoke26 Author Website +# @since 2024-11-29 +# + +NODE_ENV=development diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0425f54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +# Environment files +.env +.env.local +.env.staging +.env.development +.env.production + +# Logs +logs +*.log +npm-debug.log* + +# Backup files +*.*bak* + +# Dependencies +node_modules/ + +# VS Code +.vscode +!.vscode/tasks.js + +# Coverage +coverage + +# Transpiled files +dist/ + +# JetBrains IDEs +.idea/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Misc +.DS_Store diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4d1c1f7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2024 Junaid Atari + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf9c591 --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +# deno-ts-boilerplate + +Developer Ready: A comprehensive template. Works out of the box for most [Deno](https://deno.com) projects. + +Instant Value: All basic tools included and configured: + +- [TypeScript](https://www.typescriptlang.org/). +- [Deno Lint](https://docs.deno.com/runtime/fundamentals/linting_and_formatting/) with some initial rules' recommendation. +- [Deno Test](https://docs.deno.com/runtime/fundamentals/testing/) for fast unit testing and code coverage. +- [Deno Format](https://docs.deno.com/runtime/fundamentals/testing/) to enforce consistent code style. +- Deno [scripts](#available-scripts) for common operations. +- `.editorconfig` for consistent file format. +- Simple example of TypeScript code and unit test. +- Use all ES6 features *(including experimental and proposal)*. +- Minimal `.env` files for environment customization. +- Clean imports: No relative files path. +- Zero dependencies: Install your own packages. +- `Deno Cron` as a task schedular +- `PM2` as a process manager + +🤲 Free as in speech: available under the APLv2 license. + +## Getting Started + +This project is intended to be used with the latest Active LTS release of [Deno](https://docs.deno.com/runtime/fundamentals/stability_and_releases/). + +If you don't have Deno 2+, Check installation guide [here](https://docs.deno.com/runtime/getting_started/installation/). + +### Use as a repository template + +To start, +1. Install PM2 process manager globally: `deno install --global npm:pm2` +2. Clone this repository. +3. Copy `.env.sample` to `.env`. +4. Install dependencies by `deno install`. +5. Start adding your code in the `src` and unit tests in the `__tests__` directories. + +### Clone repository + +To clone the repository, use the following commands: + +```sh +git clone https://github.com/jiifw/deno-ts-boilerplate +cd deno-ts-boilerplate +deno install +``` + +### Download latest release + +Download and unzip the current **main** branch or one of the tags: + +```sh +wget https://github.com/jiifw/deno-ts-boilerplate/archive/main.zip -O deno-ts-boilerplate.zip +unzip deno-ts-boilerplate.zip && rm deno-ts-boilerplate.zip +``` + +## Available Scripts + +- `start` - serve built project. +- `start:dev` - interactive watch mode to automatically transpile source files. +- `start:debug` - interactive watch mode with debugger to automatically transpile source files. +- `cron` - starts the experimental cron scheduler +- `clean` - remove coverage data, Jest cache, transpiled files and runtime files. +- `lint` - lint source files and tests. +- `fromat` - reformat files. +- `test` - run tests. +- `test:watch` - interactive watch mode to automatically re-run tests. +- `pm2:start` - [PM2](https://pm2.keymetrics.io/) specific start service(s). +- `pm2:stop` - [PM2](https://pm2.keymetrics.io/) specific stop service(s). +- `pm2:delete` - [PM2](https://pm2.keymetrics.io/) specific delete service(s). + +## License + +Licensed under the APLv2. See the [LICENSE](https://github.com/jiifw/deno-ts-boilerplate/blob/main/LICENSE) file for details. diff --git a/__tests__/App.test.ts b/__tests__/App.test.ts new file mode 100644 index 0000000..f533234 --- /dev/null +++ b/__tests__/App.test.ts @@ -0,0 +1,21 @@ +/** + * @author Junaid Atari + * @see https://github.com/jiifw/deno-ts-boilerplate + * @link https://github.com/blacksmoke26 Author Website + * @since 2024-11-29 + */ + +import { describe, it } from 'jsr:@std/testing/bdd'; +import { expect } from 'jsr:@std/expect'; + +import { fromApp } from '~/app/index.ts'; + +/// READ MORE: https://docs.deno.com/runtime/fundamentals/testing + +describe('greeter function', () => { + it('A valid message should return from promise method', async () => { + const result = await fromApp(); + expect(typeof result).toBe('string'); + expect(result).toEqual('message from app'); + }); +}); diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..9c2edaa --- /dev/null +++ b/deno.json @@ -0,0 +1,101 @@ +{ + "name": "deno-ts-boilerplate", + "version": "0.0.1", + "description": "Minimalistic boilerplate to quick-start Deno development in TypeScript.", + "homepage": "https://github.com/jiifw/deno-ts-boilerplate", + "exports": { + "name": "deno-ts-boilerplate" + }, + "keywords": [ + "deno", + "javascript", + "boilerplate", + "express", + "fastify", + "microservices", + "typescript", + "eslint", + "serverless", + "backend", + "jest", + "service", + "back-end", + "prettier", + "project-template", + "starter-template", + "deno-server", + "typescript-boilerplate", + "cjs-modules", + "deno-typescript-boilerplate" + ], + "author": { + "name": "Junaid Atari", + "email": "mj.atari@gmail.com", + "url": "https://github.com/blacksmoke26" + }, + "compilerOptions": { + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": false, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true + }, + "fmt": { + "include": [ + "src/", + "__tests__/" + ], + "indentWidth": 2, + "singleQuote": true, + "useTabs": false, + "lineWidth": 160, + "semiColons": true + }, + "lint": { + "include": [ + "src/", + "__tests__/" + ], + "report": "json", + "rules": { + "tags": [ + "recommended" + ], + // See more: https://lint.deno.land/ + "exclude": [ + "no-unused-vars", + "require-await" + ] + } + }, + "test": { + "include": [ + "__tests__/" + ] + }, + "tasks": { + "start": "deno run --config ./deno.json -A src/index.ts", + "start:dev": "deno run --config ./deno.json -A --watch src/index.ts", + "start:debug": "deno run --config ./deno.json -A --inspect --watch src/index.ts", + "cron": "deno run --config ./deno.json -A src/cron.ts", + "clean": "rimraf coverage tmp runtime && mkdir coverage runtime", + "lint": "deno lint", + "prettier": "deno fmt", + "test": "deno test --reporter=dot ", + "test:watch": "deno test --watch", + "pm2:start": "pm2 start ecosystem.config.js", + "pm2:stop": "pm2 stop ecosystem.config.js", + "pm2:delete": "pm2 delete ecosystem.config.js" + }, + "unstable": [ + "cron" + ], + "imports": { + "~/": "./src/", + "@faker-js/faker": "npm:@faker-js/faker@^9.2.0", + "rimraf": "npm:rimraf@6.0.1", + "@std/assert": "jsr:@std/assert@1" + } +} diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..f25aecb --- /dev/null +++ b/deno.lock @@ -0,0 +1,238 @@ +{ + "version": "4", + "specifiers": { + "jsr:@std/assert@1": "1.0.8", + "jsr:@std/assert@^1.0.8": "1.0.8", + "jsr:@std/dotenv@*": "0.225.2", + "jsr:@std/expect@*": "1.0.8", + "jsr:@std/internal@^1.0.5": "1.0.5", + "jsr:@std/testing@*": "1.0.5", + "npm:@faker-js/faker@^9.2.0": "9.2.0", + "npm:rimraf@6.0.1": "6.0.1" + }, + "jsr": { + "@std/assert@1.0.8": { + "integrity": "ebe0bd7eb488ee39686f77003992f389a06c3da1bbd8022184804852b2fa641b", + "dependencies": [ + "jsr:@std/internal" + ] + }, + "@std/dotenv@0.225.2": { + "integrity": "e2025dce4de6c7bca21dece8baddd4262b09d5187217e231b033e088e0c4dd23" + }, + "@std/expect@1.0.8": { + "integrity": "27e40d8f3aefb372fc6a703fb0b69e34560e72a2f78705178babdffa00119a5f", + "dependencies": [ + "jsr:@std/assert@^1.0.8", + "jsr:@std/internal" + ] + }, + "@std/internal@1.0.5": { + "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" + }, + "@std/testing@1.0.5": { + "integrity": "6e693cbec94c81a1ad3df668685c7ba8e20742bb10305bc7137faa5cf16d2ec4", + "dependencies": [ + "jsr:@std/assert@^1.0.8", + "jsr:@std/internal" + ] + } + }, + "npm": { + "@faker-js/faker@9.2.0": { + "integrity": "sha512-ulqQu4KMr1/sTFIYvqSdegHT8NIkt66tFAkugGnHA+1WAfEn6hMzNR+svjXGFRVLnapxvej67Z/LwchFrnLBUg==" + }, + "@isaacs/cliui@8.0.2": { + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dependencies": [ + "string-width@5.1.2", + "string-width-cjs@npm:string-width@4.2.3", + "strip-ansi@7.1.0", + "strip-ansi-cjs@npm:strip-ansi@6.0.1", + "wrap-ansi@8.1.0", + "wrap-ansi-cjs@npm:wrap-ansi@7.0.0" + ] + }, + "ansi-regex@5.0.1": { + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-regex@6.1.0": { + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==" + }, + "ansi-styles@4.3.0": { + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": [ + "color-convert" + ] + }, + "ansi-styles@6.2.1": { + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==" + }, + "balanced-match@1.0.2": { + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "brace-expansion@2.0.1": { + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": [ + "balanced-match" + ] + }, + "color-convert@2.0.1": { + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": [ + "color-name" + ] + }, + "color-name@1.1.4": { + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "cross-spawn@7.0.6": { + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dependencies": [ + "path-key", + "shebang-command", + "which" + ] + }, + "eastasianwidth@0.2.0": { + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" + }, + "emoji-regex@8.0.0": { + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "emoji-regex@9.2.2": { + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" + }, + "foreground-child@3.3.0": { + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", + "dependencies": [ + "cross-spawn", + "signal-exit" + ] + }, + "glob@11.0.0": { + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", + "dependencies": [ + "foreground-child", + "jackspeak", + "minimatch", + "minipass", + "package-json-from-dist", + "path-scurry" + ] + }, + "is-fullwidth-code-point@3.0.0": { + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "isexe@2.0.0": { + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "jackspeak@4.0.2": { + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", + "dependencies": [ + "@isaacs/cliui" + ] + }, + "lru-cache@11.0.2": { + "integrity": "sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==" + }, + "minimatch@10.0.1": { + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "dependencies": [ + "brace-expansion" + ] + }, + "minipass@7.1.2": { + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==" + }, + "package-json-from-dist@1.0.1": { + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==" + }, + "path-key@3.1.1": { + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "path-scurry@2.0.0": { + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "dependencies": [ + "lru-cache", + "minipass" + ] + }, + "rimraf@6.0.1": { + "integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==", + "dependencies": [ + "glob", + "package-json-from-dist" + ] + }, + "shebang-command@2.0.0": { + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": [ + "shebang-regex" + ] + }, + "shebang-regex@3.0.0": { + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "signal-exit@4.1.0": { + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==" + }, + "string-width@4.2.3": { + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": [ + "emoji-regex@8.0.0", + "is-fullwidth-code-point", + "strip-ansi@6.0.1" + ] + }, + "string-width@5.1.2": { + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dependencies": [ + "eastasianwidth", + "emoji-regex@9.2.2", + "strip-ansi@7.1.0" + ] + }, + "strip-ansi@6.0.1": { + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": [ + "ansi-regex@5.0.1" + ] + }, + "strip-ansi@7.1.0": { + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dependencies": [ + "ansi-regex@6.1.0" + ] + }, + "which@2.0.2": { + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": [ + "isexe" + ] + }, + "wrap-ansi@7.0.0": { + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": [ + "ansi-styles@4.3.0", + "string-width@4.2.3", + "strip-ansi@6.0.1" + ] + }, + "wrap-ansi@8.1.0": { + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dependencies": [ + "ansi-styles@6.2.1", + "string-width@5.1.2", + "strip-ansi@7.1.0" + ] + } + }, + "workspace": { + "dependencies": [ + "jsr:@std/assert@1", + "npm:@faker-js/faker@^9.2.0", + "npm:rimraf@6.0.1" + ] + } +} diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 0000000..2125506 --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,21 @@ +/** + * @author Junaid Atari + * @see https://github.com/jiifw/deno-ts-boilerplate + * @link https://github.com/blacksmoke26 Author Website + * @since 2024-11-29 + */ + +/** + * @see https://pm2.keymetrics.io/docs/usage/application-declaration/ + */ +module.exports = { + apps: [ + { + name: 'deno-ts-boilerplate', + script: 'src/index.js', + //watch: true, + //instances: 4, + //exec_mode: 'cluster', + }, + ], +}; diff --git a/src/app/index.ts b/src/app/index.ts new file mode 100644 index 0000000..4ab5ac7 --- /dev/null +++ b/src/app/index.ts @@ -0,0 +1,13 @@ +/** + * @author Junaid Atari + * @see https://github.com/jiifw/deno-ts-boilerplate + * @link https://github.com/blacksmoke26 Author Website + * @since 2024-11-29 + */ + +/** + * A test function + */ +export async function fromApp(): Promise { + return 'message from app'; +} diff --git a/src/cron.ts b/src/cron.ts new file mode 100644 index 0000000..11e2565 --- /dev/null +++ b/src/cron.ts @@ -0,0 +1,11 @@ +/** + * @author Junaid Atari + * @see https://github.com/jiifw/deno-ts-boilerplate + * @link https://github.com/blacksmoke26 Author Website + * @since 2024-11-29 + */ + +// READ MORE: https://docs.deno.com/deploy/kv/manual/cron/ +Deno.cron('Log a message', '* * * * *', async () => { + console.log('This will print once a minute.'); +}); diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..534da3e --- /dev/null +++ b/src/index.ts @@ -0,0 +1,16 @@ +/** + * @author Junaid Atari + * @see https://github.com/jiifw/deno-ts-boilerplate + * @link https://github.com/blacksmoke26 Author Website + * @since 2024-11-29 + */ + +import 'jsr:@std/dotenv/load'; + +// App +import { fromApp } from '~/app/index.ts'; + +// Bootstrapper +(async (): Promise => { + console.log(await fromApp()); +})();