create-gramstax 0.0.27 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +25 -25
- package/dist/src/index.cjs +2 -2
- package/dist/src/index.js +2 -2
- package/dist/src/templates/.env.example +15 -18
- package/dist/src/templates/.prettierrc +23 -23
- package/dist/src/templates/README.md +120 -121
- package/dist/src/templates/bunfig.toml +1 -1
- package/dist/src/templates/package.json +48 -54
- package/dist/src/templates/src/base/guard.ts +11 -11
- package/dist/src/templates/src/base/index.ts +4 -0
- package/dist/src/templates/src/base/page.ts +3 -3
- package/dist/src/templates/src/base/repository.ts +1 -1
- package/dist/src/templates/src/base/service.ts +1 -1
- package/dist/src/templates/src/core/bot.ts +23 -23
- package/dist/src/templates/src/core/ctx.ts +3 -3
- package/dist/src/templates/src/core/index.ts +2 -0
- package/dist/src/templates/src/db/index.ts +1 -3
- package/dist/src/templates/src/env.ts +5 -6
- package/dist/src/templates/src/guards/index.ts +1 -0
- package/dist/src/templates/src/guards/user.ts +19 -19
- package/dist/src/templates/src/index.ts +15 -15
- package/dist/src/templates/src/pages/general-error-input-notfound.ts +28 -39
- package/dist/src/templates/src/pages/general-error.ts +60 -59
- package/dist/src/templates/src/pages/help.ts +49 -61
- package/dist/src/templates/src/pages/start.ts +69 -70
- package/dist/src/templates/src/pages/username-notfound.ts +33 -46
- package/dist/src/templates/src/repositories/example.ts +3 -5
- package/dist/src/templates/src/repositories/index.ts +1 -0
- package/dist/src/templates/src/services/example.ts +3 -4
- package/dist/src/templates/src/services/index.ts +1 -0
- package/dist/src/templates/src/threads/index.ts +1 -0
- package/dist/src/templates/src/threads/main.ts +9 -9
- package/dist/src/templates/src/utils/index.ts +1 -0
- package/dist/src/templates/src/utils/log.ts +2 -3
- package/dist/src/templates/tsconfig.json +37 -37
- package/package.json +8 -2
- package/dist/src/templates/.prettierignore +0 -1
- package/dist/src/templates/ecosystem.config.js +0 -26
- package/dist/src/templates/src/base/general.ts +0 -3
package/LICENSE
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
MIT License (with Fair Donation Clause)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Gramstax
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following condition:
|
|
11
|
-
|
|
12
|
-
If this Software is used in any commercial, revenue-generating, or
|
|
13
|
-
client-based project (including freelance, agency, or product development),
|
|
14
|
-
users are encouraged—but not legally required—to make a fair donation
|
|
15
|
-
to support the ongoing development and maintenance of this Software.
|
|
16
|
-
|
|
17
|
-
Donations can be made through: [your donation link here]
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
-
THE SOFTWARE.
|
|
1
|
+
MIT License (with Fair Donation Clause)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Gramstax
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following condition:
|
|
11
|
+
|
|
12
|
+
If this Software is used in any commercial, revenue-generating, or
|
|
13
|
+
client-based project (including freelance, agency, or product development),
|
|
14
|
+
users are encouraged—but not legally required—to make a fair donation
|
|
15
|
+
to support the ongoing development and maintenance of this Software.
|
|
16
|
+
|
|
17
|
+
Donations can be made through: [your donation link here]
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
package/dist/src/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var M=Object.create;var f=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var m=(o,e)=>f(o,"name",{value:e,configurable:!0});var N=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of F(e))!E.call(o,a)&&a!==t&&f(o,a,{get:()=>e[a],enumerable:!(n=D(e,a))||n.enumerable});return o};var d=(o,e,t)=>(t=o!=null?M(R(o)):{},N(e||!o||!o.__esModule?f(t,"default",{value:o,enumerable:!0}):t,o));var L=m(()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,"getImportMetaUrl"),u=L();var v=require("logging-pretty"),r=new v.LoggingPretty;var i=d(require("fs"),1),s=d(require("path"),1),w=require("url");var _=require("child_process"),y=d(require("enquirer"),1);var T=(0,w.fileURLToPath)(u),U=s.dirname(T),g=class{constructor(e){this.projectDirectory=e}static{m(this,"Create")}config;printBanner(){console.log(`
|
|
3
3
|
$$$$$$\\ $$\\
|
|
4
4
|
$$ __$$\\ $$ |
|
|
5
5
|
$$ / \\__| $$$$$$\\ $$$$$$\\ $$$$$$\\$$$$\\ $$$$$$$\\ $$$$$$\\ $$$$$$\\ $$\\ $$\\
|
|
@@ -9,4 +9,4 @@ $$ | $$ |$$ | $$ __$$ |$$ | $$ | $$ | \\____$$\\ $$ |$$\\ $$ __$$ | $$
|
|
|
9
9
|
\\$$$$$$ |$$ | \\$$$$$$$ |$$ | $$ | $$ |$$$$$$$ | \\$$$$ |\\$$$$$$$ |$$ /\\$$\\
|
|
10
10
|
\\______/ \\__| \\_______|\\__| \\__| \\__|\\_______/ \\____/ \\_______|\\__/ \\__|
|
|
11
11
|
|
|
12
|
-
`)}getPackageManagerCommands(e){return{bun:{install:"bun install",dev:"bun dev",start:"bun start"
|
|
12
|
+
`)}getPackageManagerCommands(e){return{bun:{install:"bun install",dev:"bun dev",start:"bun start"},npm:{install:"npm install",dev:"npm run dev",start:"npm start"},pnpm:{install:"pnpm install",dev:"pnpm dev",start:"pnpm start"},yarn:{install:"yarn install",dev:"yarn dev",start:"yarn start"}}[e]}copyDirectorySync(e,t,n={}){i.existsSync(t)||i.mkdirSync(t,{recursive:!0});let a=i.readdirSync(e,{withFileTypes:!0});for(let c of a){let p=s.join(e,c.name),$=s.join(t,c.name);if(c.isDirectory())this.copyDirectorySync(p,$,n);else if(c.isFile()){let l=i.readFileSync(p,"utf-8");l=this.replaceTemplateVariables(l,n),i.writeFileSync($,l)}}}replaceTemplateVariables(e,t){let n=e;for(let[a,c]of Object.entries(t))n=n.replace(new RegExp(`{{${a}}}`,"g"),c);return n}async promptForProjectName(){return(await y.default.prompt({type:"input",name:"projectName",message:"What is your project named?",initial:"",validate:m(t=>t===""||/^[a-z0-9-_]+$/i.test(t)?!0:"Project name can only contain letters, numbers, hyphens, and underscores","validate")})).projectName}async promptForConfiguration(){let e=[];e.push({type:"select",name:"packageManager",message:"Which package manager would you like to use?",choices:[{name:"bun",message:"Bun (recommended)",value:"bun"},{name:"npm",message:"npm",value:"npm"},{name:"pnpm",message:"pnpm",value:"pnpm"},{name:"yarn",message:"Yarn",value:"yarn"}],initial:0}),e.push({type:"select",name:"runtime",message:"Which runtime would you like to use?",choices:[{name:"bun",message:"Bun (recommended)",value:"bun"},{name:"node",message:"Node.js",value:"node"}],initial:0}),e.push({type:"confirm",name:"eslint",message:"Would you like to use ESLint?",initial:!0});let t=await y.default.prompt(e);return{packageManager:t.packageManager,runtime:t.runtime,eslint:t.eslint}}async installDependencies(e,t){return await new Promise(n=>{let p=(0,_.spawn)(t,["install"],{cwd:e,stdio:"inherit",shell:!0});p.on("close",$=>{$===0?n(!0):(r.fail("Dependencies installation failed"),n(!1))}),p.on("error",$=>{r.fail(`Dependencies installation failed: ${$.message}`),n(!1)})})}async gatherProjectConfig(){this.printBanner();let e=this.projectDirectory,t,n=!1;e?(t=s.resolve(process.cwd(),e),n=!1):(e=await this.promptForProjectName(),e===""?(e=s.basename(process.cwd()),t=process.cwd(),n=!0):(t=s.resolve(process.cwd(),e),n=!1));let a=await this.promptForConfiguration(),c=a.packageManager,p=a.runtime,$=a.eslint;return r.info(`Project: ${e}`),r.info(`Location: ${t}`),r.info(`Package Manager: ${c}`),r.info(`Runtime: ${p}`),r.info(`ESLint: ${$?"Yes":"No"}`),n?i.readdirSync(t).length>0&&(r.error("Current directory is not empty!"),process.exit(1)):i.existsSync(t)&&(r.error(`Directory "${e}" already exists!`),process.exit(1)),{projectName:e,projectPath:t,packageManager:c,runtime:p,setupEslint:$}}async executeProjectGeneration(e){let{projectName:t,projectPath:n,packageManager:a,runtime:c,setupEslint:p}=e;r.info("Creating project directory.."),i.existsSync(n)||i.mkdirSync(n,{recursive:!0}),r.info("Copying template files..");let $=s.join(U,"templates"),l=this.getPackageManagerCommands(a),k={projectName:t,installCmd:l.install,runDevCmd:l.dev,runStartCmd:l.start};this.copyDirectorySync($,n,k),r.info("Creating logs directory.."),i.mkdirSync(s.join(n,"logs"),{recursive:!0}),i.writeFileSync(s.join(n,"logs/.gitkeep"),"");let C=s.join(n,".env"),h=s.join(n,".env.example");if(i.existsSync(h)&&(r.info("Creating .env file.."),i.renameSync(h,C)),c!=="bun"){r.info("Removing bunfig.toml for Node.js runtime..");let P=s.join(n,"bunfig.toml");i.existsSync(P)&&i.unlinkSync(P)}let j=s.join(n,"tsconfig.json"),x=i.readFileSync(j,{encoding:"utf8"}).replace("//{{types}}",c=="bun"?'"bun-types"':"");if(i.writeFileSync(j,x,{encoding:"utf8"}),r.info("Installing dependencies.."),!await this.installDependencies(n,a))return r.fail("Project created failed!"),process.exit();p&&(r.info("Setting up ESLint.."),await this.setupEslintConfig(n)),r.info("Project created successfully!"),r.info(`Next steps: ${e.projectPath!==process.cwd()?`cd ${t} && `:" "}${l.install} && ${l.dev}`),r.info("Done..")}async setupEslintConfig(e){return new Promise(t=>{let n=(0,_.spawn)("npm",["init","@eslint/config@latest"],{cwd:e,stdio:"inherit",shell:!0});n.on("close",a=>{a===0||r.fail("ESLint setup failed. You can set it up later with: npm init @eslint/config"),t()}),n.on("error",a=>{r.fail(`ESLint setup failed: ${a.message}`),r.info("You can set it up later with: npm init @eslint/config"),t()})})}async createProject(){try{this.config=await this.gatherProjectConfig(),await this.executeProjectGeneration(this.config)}catch(e){e instanceof Error?r.error(`Failed to create project: ${e.message}`):r.error(`Failed to create project: ${String(e)}`),process.exit(1)}}};var b=require("commander"),I="0.0.0",S=new b.Command;S.name("create-gramstax").description("CLI to create a new Gramstax Telegram bot project").version(I).argument("[project-directory]","Directory to create the project in").action(async o=>{try{await new g(o).createProject()}catch(e){r.error(`Failed to create project: ${String(e)}`),process.exit(1)}});S.parse();
|
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var w=Object.defineProperty;var g=(l,e)=>w(l,"name",{value:e,configurable:!0});import{LoggingPretty as k}from"logging-pretty";var r=new k;import*as i from"fs";import*as a from"path";import{fileURLToPath as C}from"url";import{spawn as _}from"child_process";import y from"enquirer";var x=C(import.meta.url),M=a.dirname(x),m=class{constructor(e){this.projectDirectory=e}static{g(this,"Create")}config;printBanner(){console.log(`
|
|
3
3
|
$$$$$$\\ $$\\
|
|
4
4
|
$$ __$$\\ $$ |
|
|
5
5
|
$$ / \\__| $$$$$$\\ $$$$$$\\ $$$$$$\\$$$$\\ $$$$$$$\\ $$$$$$\\ $$$$$$\\ $$\\ $$\\
|
|
@@ -9,4 +9,4 @@ $$ | $$ |$$ | $$ __$$ |$$ | $$ | $$ | \\____$$\\ $$ |$$\\ $$ __$$ | $$
|
|
|
9
9
|
\\$$$$$$ |$$ | \\$$$$$$$ |$$ | $$ | $$ |$$$$$$$ | \\$$$$ |\\$$$$$$$ |$$ /\\$$\\
|
|
10
10
|
\\______/ \\__| \\_______|\\__| \\__| \\__|\\_______/ \\____/ \\_______|\\__/ \\__|
|
|
11
11
|
|
|
12
|
-
`)}getPackageManagerCommands(e){return{bun:{install:"bun install",dev:"bun dev",start:"bun start"
|
|
12
|
+
`)}getPackageManagerCommands(e){return{bun:{install:"bun install",dev:"bun dev",start:"bun start"},npm:{install:"npm install",dev:"npm run dev",start:"npm start"},pnpm:{install:"pnpm install",dev:"pnpm dev",start:"pnpm start"},yarn:{install:"yarn install",dev:"yarn dev",start:"yarn start"}}[e]}copyDirectorySync(e,t,n={}){i.existsSync(t)||i.mkdirSync(t,{recursive:!0});let s=i.readdirSync(e,{withFileTypes:!0});for(let o of s){let $=a.join(e,o.name),c=a.join(t,o.name);if(o.isDirectory())this.copyDirectorySync($,c,n);else if(o.isFile()){let p=i.readFileSync($,"utf-8");p=this.replaceTemplateVariables(p,n),i.writeFileSync(c,p)}}}replaceTemplateVariables(e,t){let n=e;for(let[s,o]of Object.entries(t))n=n.replace(new RegExp(`{{${s}}}`,"g"),o);return n}async promptForProjectName(){return(await y.prompt({type:"input",name:"projectName",message:"What is your project named?",initial:"",validate:g(t=>t===""||/^[a-z0-9-_]+$/i.test(t)?!0:"Project name can only contain letters, numbers, hyphens, and underscores","validate")})).projectName}async promptForConfiguration(){let e=[];e.push({type:"select",name:"packageManager",message:"Which package manager would you like to use?",choices:[{name:"bun",message:"Bun (recommended)",value:"bun"},{name:"npm",message:"npm",value:"npm"},{name:"pnpm",message:"pnpm",value:"pnpm"},{name:"yarn",message:"Yarn",value:"yarn"}],initial:0}),e.push({type:"select",name:"runtime",message:"Which runtime would you like to use?",choices:[{name:"bun",message:"Bun (recommended)",value:"bun"},{name:"node",message:"Node.js",value:"node"}],initial:0}),e.push({type:"confirm",name:"eslint",message:"Would you like to use ESLint?",initial:!0});let t=await y.prompt(e);return{packageManager:t.packageManager,runtime:t.runtime,eslint:t.eslint}}async installDependencies(e,t){return await new Promise(n=>{let $=_(t,["install"],{cwd:e,stdio:"inherit",shell:!0});$.on("close",c=>{c===0?n(!0):(r.fail("Dependencies installation failed"),n(!1))}),$.on("error",c=>{r.fail(`Dependencies installation failed: ${c.message}`),n(!1)})})}async gatherProjectConfig(){this.printBanner();let e=this.projectDirectory,t,n=!1;e?(t=a.resolve(process.cwd(),e),n=!1):(e=await this.promptForProjectName(),e===""?(e=a.basename(process.cwd()),t=process.cwd(),n=!0):(t=a.resolve(process.cwd(),e),n=!1));let s=await this.promptForConfiguration(),o=s.packageManager,$=s.runtime,c=s.eslint;return r.info(`Project: ${e}`),r.info(`Location: ${t}`),r.info(`Package Manager: ${o}`),r.info(`Runtime: ${$}`),r.info(`ESLint: ${c?"Yes":"No"}`),n?i.readdirSync(t).length>0&&(r.error("Current directory is not empty!"),process.exit(1)):i.existsSync(t)&&(r.error(`Directory "${e}" already exists!`),process.exit(1)),{projectName:e,projectPath:t,packageManager:o,runtime:$,setupEslint:c}}async executeProjectGeneration(e){let{projectName:t,projectPath:n,packageManager:s,runtime:o,setupEslint:$}=e;r.info("Creating project directory.."),i.existsSync(n)||i.mkdirSync(n,{recursive:!0}),r.info("Copying template files..");let c=a.join(M,"templates"),p=this.getPackageManagerCommands(s),j={projectName:t,installCmd:p.install,runDevCmd:p.dev,runStartCmd:p.start};this.copyDirectorySync(c,n,j),r.info("Creating logs directory.."),i.mkdirSync(a.join(n,"logs"),{recursive:!0}),i.writeFileSync(a.join(n,"logs/.gitkeep"),"");let P=a.join(n,".env"),u=a.join(n,".env.example");if(i.existsSync(u)&&(r.info("Creating .env file.."),i.renameSync(u,P)),o!=="bun"){r.info("Removing bunfig.toml for Node.js runtime..");let d=a.join(n,"bunfig.toml");i.existsSync(d)&&i.unlinkSync(d)}let f=a.join(n,"tsconfig.json"),v=i.readFileSync(f,{encoding:"utf8"}).replace("//{{types}}",o=="bun"?'"bun-types"':"");if(i.writeFileSync(f,v,{encoding:"utf8"}),r.info("Installing dependencies.."),!await this.installDependencies(n,s))return r.fail("Project created failed!"),process.exit();$&&(r.info("Setting up ESLint.."),await this.setupEslintConfig(n)),r.info("Project created successfully!"),r.info(`Next steps: ${e.projectPath!==process.cwd()?`cd ${t} && `:" "}${p.install} && ${p.dev}`),r.info("Done..")}async setupEslintConfig(e){return new Promise(t=>{let n=_("npm",["init","@eslint/config@latest"],{cwd:e,stdio:"inherit",shell:!0});n.on("close",s=>{s===0||r.fail("ESLint setup failed. You can set it up later with: npm init @eslint/config"),t()}),n.on("error",s=>{r.fail(`ESLint setup failed: ${s.message}`),r.info("You can set it up later with: npm init @eslint/config"),t()})})}async createProject(){try{this.config=await this.gatherProjectConfig(),await this.executeProjectGeneration(this.config)}catch(e){e instanceof Error?r.error(`Failed to create project: ${e.message}`):r.error(`Failed to create project: ${String(e)}`),process.exit(1)}}};import{Command as D}from"commander";var F="0.0.0",h=new D;h.name("create-gramstax").description("CLI to create a new Gramstax Telegram bot project").version(F).argument("[project-directory]","Directory to create the project in").action(async l=>{try{await new m(l).createProject()}catch(e){r.error(`Failed to create project: ${String(e)}`),process.exit(1)}});h.parse();
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
# Telegram Bot Token
|
|
2
|
-
BOT_TOKEN=your_bot_token_here
|
|
3
|
-
|
|
4
|
-
# Bot Deployment Mode
|
|
5
|
-
# Options:
|
|
6
|
-
# - polling
|
|
7
|
-
# - webhook:https://yourdomain.com
|
|
8
|
-
# - serverless:std/http
|
|
9
|
-
BOT_DEPLOY=polling
|
|
10
|
-
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
# - memory
|
|
17
|
-
# - redis://... (use redis)
|
|
18
|
-
CACHE_SESSION=memory
|
|
1
|
+
# Telegram Bot Token
|
|
2
|
+
BOT_TOKEN=your_bot_token_here
|
|
3
|
+
|
|
4
|
+
# Bot Deployment Mode
|
|
5
|
+
# Options:
|
|
6
|
+
# - polling
|
|
7
|
+
# - webhook:<full-public-url> | example: webhook:https://yourdomain.com/telegram-webhook
|
|
8
|
+
# - serverless:<adapter> | example: serverless:std/http
|
|
9
|
+
BOT_DEPLOY=polling
|
|
10
|
+
|
|
11
|
+
# Cache configuration for session
|
|
12
|
+
# Options:
|
|
13
|
+
# - memory
|
|
14
|
+
# - redis:<url> | example: redis://127.0.0.1:6379
|
|
15
|
+
CACHE_SESSION=memory
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"overrides": [
|
|
3
|
-
{
|
|
4
|
-
"files": "*.{json,sol}",
|
|
5
|
-
"options": {
|
|
6
|
-
"tabWidth": 2,
|
|
7
|
-
"printWidth": 200
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"files": "*.{ts,js}",
|
|
12
|
-
"options": {
|
|
13
|
-
"printWidth": 300,
|
|
14
|
-
"tabWidth": 2,
|
|
15
|
-
"useTabs": false,
|
|
16
|
-
"semi": false,
|
|
17
|
-
"arrowParens": "always",
|
|
18
|
-
"trailingComma": "none",
|
|
19
|
-
"bracketSameLine": false
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"overrides": [
|
|
3
|
+
{
|
|
4
|
+
"files": "*.{json,sol}",
|
|
5
|
+
"options": {
|
|
6
|
+
"tabWidth": 2,
|
|
7
|
+
"printWidth": 200
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"files": "*.{ts,js}",
|
|
12
|
+
"options": {
|
|
13
|
+
"printWidth": 300,
|
|
14
|
+
"tabWidth": 2,
|
|
15
|
+
"useTabs": false,
|
|
16
|
+
"semi": false,
|
|
17
|
+
"arrowParens": "always",
|
|
18
|
+
"trailingComma": "none",
|
|
19
|
+
"bracketSameLine": false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -1,121 +1,120 @@
|
|
|
1
|
-
# {{projectName}}
|
|
2
|
-
|
|
3
|
-
A Telegram bot built with Gramstax framework.
|
|
4
|
-
|
|
5
|
-
## Getting Started
|
|
6
|
-
|
|
7
|
-
### Development
|
|
8
|
-
|
|
9
|
-
1. Install dependencies:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
{{installCmd}}
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
2. Set up your environment variables:
|
|
16
|
-
|
|
17
|
-
Copy `.env.example` to `.env` and add your Telegram bot token:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
BOT_TOKEN=your_bot_token_here
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
3. Run the development server:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
{{runDevCmd}}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Production
|
|
30
|
-
|
|
31
|
-
#### Using PM2 (Recommended)
|
|
32
|
-
|
|
33
|
-
PM2 is a production process manager for Node.js applications with built-in load balancer.
|
|
34
|
-
|
|
35
|
-
1. Install dependencies:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
{{installCmd}}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
2. Set up production environment:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
cp .env.example .env
|
|
45
|
-
# Edit .env with your production BOT_TOKEN
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
3. Start with PM2:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
{{runPm2StartCmd}}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
4. PM2 Management Commands:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
# View logs
|
|
58
|
-
{{runPm2LogsCmd}}
|
|
59
|
-
|
|
60
|
-
# Monitor processes
|
|
61
|
-
{{runPm2MonitCmd}}
|
|
62
|
-
|
|
63
|
-
# Restart bot
|
|
64
|
-
{{runPm2RestartCmd}}
|
|
65
|
-
|
|
66
|
-
# Stop bot
|
|
67
|
-
{{runPm2StopCmd}}
|
|
68
|
-
|
|
69
|
-
# Delete from PM2
|
|
70
|
-
{{runPm2DeleteCmd}}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
5. Setup PM2 to start on system boot:
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
pm2 startup
|
|
77
|
-
pm2 save
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
#### Using Bun directly
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
{{runStartCmd}}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Project Structure
|
|
87
|
-
|
|
88
|
-
- `src/base/` - Base classes for your bot components
|
|
89
|
-
- `src/core/` - Core bot configuration and hooks
|
|
90
|
-
- `src/pages/` - Bot pages/screens
|
|
91
|
-
- `src/guards/` - Route guards and middleware
|
|
92
|
-
- `src/services/` - Business logic services
|
|
93
|
-
- `src/repositories/` - Data access layer
|
|
94
|
-
- `src/templates/` - Message templates
|
|
95
|
-
- `src/utils/` - Utility functions
|
|
96
|
-
- `logs/` - Application logs (created automatically)
|
|
97
|
-
|
|
98
|
-
## Configuration
|
|
99
|
-
|
|
100
|
-
### Environment Variables
|
|
101
|
-
|
|
102
|
-
- `BOT_TOKEN` - Your Telegram bot token (required)
|
|
103
|
-
- `
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
- **
|
|
111
|
-
- **
|
|
112
|
-
- **
|
|
113
|
-
- **
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
- [
|
|
119
|
-
- [
|
|
120
|
-
- [
|
|
121
|
-
- [PM2 Documentation](https://pm2.keymetrics.io/)
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
A Telegram bot built with Gramstax framework.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
### Development
|
|
8
|
+
|
|
9
|
+
1. Install dependencies:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
{{installCmd}}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. Set up your environment variables:
|
|
16
|
+
|
|
17
|
+
Copy `.env.example` to `.env` and add your Telegram bot token:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
BOT_TOKEN=your_bot_token_here
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. Run the development server:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
{{runDevCmd}}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Production
|
|
30
|
+
|
|
31
|
+
#### Using PM2 (Recommended)
|
|
32
|
+
|
|
33
|
+
PM2 is a production process manager for Node.js applications with built-in load balancer.
|
|
34
|
+
|
|
35
|
+
1. Install dependencies:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
{{installCmd}}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. Set up production environment:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cp .env.example .env
|
|
45
|
+
# Edit .env with your production BOT_TOKEN
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
3. Start with PM2:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
{{runPm2StartCmd}}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
4. PM2 Management Commands:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# View logs
|
|
58
|
+
{{runPm2LogsCmd}}
|
|
59
|
+
|
|
60
|
+
# Monitor processes
|
|
61
|
+
{{runPm2MonitCmd}}
|
|
62
|
+
|
|
63
|
+
# Restart bot
|
|
64
|
+
{{runPm2RestartCmd}}
|
|
65
|
+
|
|
66
|
+
# Stop bot
|
|
67
|
+
{{runPm2StopCmd}}
|
|
68
|
+
|
|
69
|
+
# Delete from PM2
|
|
70
|
+
{{runPm2DeleteCmd}}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
5. Setup PM2 to start on system boot:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pm2 startup
|
|
77
|
+
pm2 save
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Using Bun directly
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
{{runStartCmd}}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Project Structure
|
|
87
|
+
|
|
88
|
+
- `src/base/` - Base classes for your bot components
|
|
89
|
+
- `src/core/` - Core bot configuration and hooks
|
|
90
|
+
- `src/pages/` - Bot pages/screens
|
|
91
|
+
- `src/guards/` - Route guards and middleware
|
|
92
|
+
- `src/services/` - Business logic services
|
|
93
|
+
- `src/repositories/` - Data access layer
|
|
94
|
+
- `src/templates/` - Message templates
|
|
95
|
+
- `src/utils/` - Utility functions
|
|
96
|
+
- `logs/` - Application logs (created automatically)
|
|
97
|
+
|
|
98
|
+
## Configuration
|
|
99
|
+
|
|
100
|
+
### Environment Variables
|
|
101
|
+
|
|
102
|
+
- `BOT_TOKEN` - Your Telegram bot token (required)
|
|
103
|
+
- `CACHE_SESSION` - Cache type configuration (optional)
|
|
104
|
+
|
|
105
|
+
### PM2 Configuration
|
|
106
|
+
|
|
107
|
+
The `ecosystem.config.js` file contains PM2 configuration:
|
|
108
|
+
|
|
109
|
+
- **instances**: Number of instances (default: 1)
|
|
110
|
+
- **exec_mode**: Execution mode (cluster/fork)
|
|
111
|
+
- **max_memory_restart**: Auto-restart if memory exceeds limit
|
|
112
|
+
- **autorestart**: Auto-restart on crash
|
|
113
|
+
- **error_file/out_file**: Log file locations
|
|
114
|
+
|
|
115
|
+
## Learn More
|
|
116
|
+
|
|
117
|
+
- [Gramstax Documentation](https://github.com/gramstax/gramstax)
|
|
118
|
+
- [Grammy Documentation](https://grammy.dev/)
|
|
119
|
+
- [Telegram Bot API](https://core.telegram.org/bots/api)
|
|
120
|
+
- [PM2 Documentation](https://pm2.keymetrics.io/)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[run]
|
|
1
|
+
[run]
|
|
2
2
|
console.depth = 4
|
|
@@ -1,54 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{projectName}}",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"description": "",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": ""
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": ""
|
|
13
|
-
},
|
|
14
|
-
"homepage": "",
|
|
15
|
-
"author": "",
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"main": "./dist/src/index.js",
|
|
18
|
-
"types": "./dist/src/index.d.ts",
|
|
19
|
-
"exports": {
|
|
20
|
-
".": {
|
|
21
|
-
"types": "./dist/src/index.d.ts",
|
|
22
|
-
"import": "./dist/src/index.js",
|
|
23
|
-
"default": "./dist/src/index.js"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist",
|
|
28
|
-
"src"
|
|
29
|
-
],
|
|
30
|
-
"scripts": {
|
|
31
|
-
"dev": "bun --watch src/index.ts",
|
|
32
|
-
"start": "bun src/index.ts",
|
|
33
|
-
"build": "bun build src/index.ts --outdir dist --target bun",
|
|
34
|
-
"lint": "eslint
|
|
35
|
-
"lint:fix": "eslint
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@types/bun": "latest",
|
|
52
|
-
"pm2": "^5.3.0"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": ""
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": ""
|
|
13
|
+
},
|
|
14
|
+
"homepage": "",
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"main": "./dist/src/index.js",
|
|
18
|
+
"types": "./dist/src/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/src/index.d.ts",
|
|
22
|
+
"import": "./dist/src/index.js",
|
|
23
|
+
"default": "./dist/src/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"src"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"dev": "bun --watch src/index.ts",
|
|
32
|
+
"start": "bun src/index.ts",
|
|
33
|
+
"build": "bun build src/index.ts --outdir dist --target bun",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"lint:fix": "eslint . --fix"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"logging-pretty": "^3.0.0",
|
|
39
|
+
"gramstax": "^0.1.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"typescript": "5.9.3"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/bun": "latest",
|
|
46
|
+
"pm2": "^5.3.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CtxCore } from "~/core
|
|
2
|
-
|
|
3
|
-
export abstract class GuardBase extends CtxCore {
|
|
4
|
-
public constructor(ctx: CtxCore) {
|
|
5
|
-
super(ctx)
|
|
6
|
-
if (ctx?.data) {
|
|
7
|
-
// save as temporary because guard should not save this.data or class.data because it is intended for Page only.
|
|
8
|
-
this.temp.data = ctx.data
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
import { CtxCore } from "~/core"
|
|
2
|
+
|
|
3
|
+
export abstract class GuardBase extends CtxCore {
|
|
4
|
+
public constructor(ctx: CtxCore) {
|
|
5
|
+
super(ctx)
|
|
6
|
+
if (ctx?.data) {
|
|
7
|
+
// save as temporary because guard should not save this.data or class.data because it is intended for Page only.
|
|
8
|
+
this.temp.data = ctx.data
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CtxCore } from "~/core
|
|
2
|
-
|
|
3
|
-
export abstract class PageBase extends CtxCore {}
|
|
1
|
+
import { CtxCore } from "~/core"
|
|
2
|
+
|
|
3
|
+
export abstract class PageBase extends CtxCore {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export abstract class RepositoryBase {}
|
|
1
|
+
export abstract class RepositoryBase {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export abstract class ServiceBase {}
|
|
1
|
+
export abstract class ServiceBase {}
|