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.
Files changed (39) hide show
  1. package/LICENSE +25 -25
  2. package/dist/src/index.cjs +2 -2
  3. package/dist/src/index.js +2 -2
  4. package/dist/src/templates/.env.example +15 -18
  5. package/dist/src/templates/.prettierrc +23 -23
  6. package/dist/src/templates/README.md +120 -121
  7. package/dist/src/templates/bunfig.toml +1 -1
  8. package/dist/src/templates/package.json +48 -54
  9. package/dist/src/templates/src/base/guard.ts +11 -11
  10. package/dist/src/templates/src/base/index.ts +4 -0
  11. package/dist/src/templates/src/base/page.ts +3 -3
  12. package/dist/src/templates/src/base/repository.ts +1 -1
  13. package/dist/src/templates/src/base/service.ts +1 -1
  14. package/dist/src/templates/src/core/bot.ts +23 -23
  15. package/dist/src/templates/src/core/ctx.ts +3 -3
  16. package/dist/src/templates/src/core/index.ts +2 -0
  17. package/dist/src/templates/src/db/index.ts +1 -3
  18. package/dist/src/templates/src/env.ts +5 -6
  19. package/dist/src/templates/src/guards/index.ts +1 -0
  20. package/dist/src/templates/src/guards/user.ts +19 -19
  21. package/dist/src/templates/src/index.ts +15 -15
  22. package/dist/src/templates/src/pages/general-error-input-notfound.ts +28 -39
  23. package/dist/src/templates/src/pages/general-error.ts +60 -59
  24. package/dist/src/templates/src/pages/help.ts +49 -61
  25. package/dist/src/templates/src/pages/start.ts +69 -70
  26. package/dist/src/templates/src/pages/username-notfound.ts +33 -46
  27. package/dist/src/templates/src/repositories/example.ts +3 -5
  28. package/dist/src/templates/src/repositories/index.ts +1 -0
  29. package/dist/src/templates/src/services/example.ts +3 -4
  30. package/dist/src/templates/src/services/index.ts +1 -0
  31. package/dist/src/templates/src/threads/index.ts +1 -0
  32. package/dist/src/templates/src/threads/main.ts +9 -9
  33. package/dist/src/templates/src/utils/index.ts +1 -0
  34. package/dist/src/templates/src/utils/log.ts +2 -3
  35. package/dist/src/templates/tsconfig.json +37 -37
  36. package/package.json +8 -2
  37. package/dist/src/templates/.prettierignore +0 -1
  38. package/dist/src/templates/ecosystem.config.js +0 -26
  39. 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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var x=Object.create;var u=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var g=(m,e)=>u(m,"name",{value:e,configurable:!0});var N=(m,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!E.call(m,i)&&i!==n&&u(m,i,{get:()=>e[i],enumerable:!(t=M(e,i))||t.enumerable});return m};var f=(m,e,n)=>(n=m!=null?x(F(m)):{},N(e||!m||!m.__esModule?u(n,"default",{value:m,enumerable:!0}):n,m));var j=require("logging-pretty"),r=new j.LoggingPretty;var a=f(require("fs"),1),p=f(require("path"),1),v=require("url");var d=require("child_process"),y=f(require("enquirer"),1),T={};var R=(0,v.fileURLToPath)(T.url),L=p.dirname(R),l=class{constructor(e){this.projectDirectory=e}static{g(this,"Create")}config;printBanner(){console.log(`
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","pm2:start":"bun run pm2:start","pm2:stop":"bun run pm2:stop","pm2:restart":"bun run pm2:restart","pm2:delete":"bun run pm2:delete","pm2:logs":"bun run pm2:logs","pm2:monit":"bun run pm2:monit"},npm:{install:"npm install",dev:"npm run dev",start:"npm start","pm2:start":"npm run pm2:start","pm2:stop":"npm run pm2:stop","pm2:restart":"npm run pm2:restart","pm2:delete":"npm run pm2:delete","pm2:logs":"npm run pm2:logs","pm2:monit":"npm run pm2:monit"},pnpm:{install:"pnpm install",dev:"pnpm dev",start:"pnpm start","pm2:start":"pnpm pm2:start","pm2:stop":"pnpm pm2:stop","pm2:restart":"pnpm pm2:restart","pm2:delete":"pnpm pm2:delete","pm2:logs":"pnpm pm2:logs","pm2:monit":"pnpm pm2:monit"},yarn:{install:"yarn install",dev:"yarn dev",start:"yarn start","pm2:start":"yarn pm2:start","pm2:stop":"yarn pm2:stop","pm2:restart":"yarn pm2:restart","pm2:delete":"yarn pm2:delete","pm2:logs":"yarn pm2:logs","pm2:monit":"yarn pm2:monit"}}[e]}copyDirectorySync(e,n,t={}){a.existsSync(n)||a.mkdirSync(n,{recursive:!0});let i=a.readdirSync(e,{withFileTypes:!0});for(let o of i){let $=p.join(e,o.name),c=p.join(n,o.name);if(o.isDirectory())this.copyDirectorySync($,c,t);else if(o.isFile()){let s=a.readFileSync($,"utf-8");s=this.replaceTemplateVariables(s,t),a.writeFileSync(c,s)}}}replaceTemplateVariables(e,n){let t=e;for(let[i,o]of Object.entries(n))t=t.replace(new RegExp(`{{${i}}}`,"g"),o);return t}async promptForProjectName(){return(await y.default.prompt({type:"input",name:"projectName",message:"What is your project named?",initial:"",validate:g(n=>n===""||/^[a-z0-9-_]+$/i.test(n)?!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 n=await y.default.prompt(e);return{packageManager:n.packageManager,runtime:n.runtime,eslint:n.eslint}}async installDependencies(e,n){return await new Promise((t,i)=>{let c=(0,d.spawn)(n,["install"],{cwd:e,stdio:"inherit",shell:!0});c.on("close",s=>{s===0?t(!0):(r.fail("Dependencies installation failed"),t(!1))}),c.on("error",s=>{r.fail(`Dependencies installation failed: ${s.message}`),t(!1)})})}async gatherProjectConfig(){this.printBanner();let e=this.projectDirectory,n,t=!1;e?(n=p.resolve(process.cwd(),e),t=!1):(e=await this.promptForProjectName(),e===""?(e=p.basename(process.cwd()),n=process.cwd(),t=!0):(n=p.resolve(process.cwd(),e),t=!1));let i=await this.promptForConfiguration(),o=i.packageManager,$=i.runtime,c=i.eslint;return r.info(`Project: ${e}`),r.info(`Location: ${n}`),r.info(`Package Manager: ${o}`),r.info(`Runtime: ${$}`),r.info(`ESLint: ${c?"Yes":"No"}`),t?a.readdirSync(n).length>0&&(r.error("Current directory is not empty!"),process.exit(1)):a.existsSync(n)&&(r.error(`Directory "${e}" already exists!`),process.exit(1)),{projectName:e,projectPath:n,packageManager:o,runtime:$,setupEslint:c}}async executeProjectGeneration(e){let{projectName:n,projectPath:t,packageManager:i,runtime:o,setupEslint:$}=e;r.info("Creating project directory.."),a.existsSync(t)||a.mkdirSync(t,{recursive:!0}),r.info("Copying template files..");let c=p.join(L,"templates"),s=this.getPackageManagerCommands(i),C={projectName:n,installCmd:s.install,runDevCmd:s.dev,runStartCmd:s.start,runPm2StartCmd:s["pm2:start"],runPm2StopCmd:s["pm2:stop"],runPm2RestartCmd:s["pm2:restart"],runPm2DeleteCmd:s["pm2:delete"],runPm2LogsCmd:s["pm2:logs"],runPm2MonitCmd:s["pm2:monit"]};this.copyDirectorySync(c,t,C),r.info("Creating logs directory.."),a.mkdirSync(p.join(t,"logs"),{recursive:!0}),a.writeFileSync(p.join(t,"logs/.gitkeep"),"");let S=p.join(t,".env"),_=p.join(t,".env.example");if(a.existsSync(_)&&(r.info("Creating .env file.."),a.renameSync(_,S)),o!=="bun"){r.info("Removing bunfig.toml for Node.js runtime..");let P=p.join(t,"bunfig.toml");a.existsSync(P)&&a.unlinkSync(P)}let h=p.join(t,"tsconfig.json"),k=a.readFileSync(h,{encoding:"utf8"}).replace("//{{types}}",o=="bun"?'"bun-types"':"");if(a.writeFileSync(h,k,{encoding:"utf8"}),r.info("Installing dependencies.."),!await this.installDependencies(t,i))return r.fail("Project created failed!"),process.exit();$&&(r.info("Setting up ESLint.."),await this.setupEslintConfig(t,i)),r.info("Project created successfully!"),r.info(`Next steps: ${e.projectPath!==process.cwd()?`cd ${n} && `:" "}${s.install} && ${s.dev}`),r.info(`For production: ${s["pm2:start"]}`),r.info("Done..")}async setupEslintConfig(e,n){return new Promise(t=>{let i=(0,d.spawn)("npm",["init","@eslint/config@latest"],{cwd:e,stdio:"inherit",shell:!0});i.on("close",o=>{o===0||r.fail("ESLint setup failed. You can set it up later with: npm init @eslint/config"),t()}),i.on("error",o=>{r.fail(`ESLint setup failed: ${o.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"),B="0.0.0",w=new b.Command;w.name("create-gramstax").description("CLI to create a new Gramstax Telegram bot project").version(B).argument("[project-directory]","Directory to create the project in").action(async m=>{try{await new l(m).createProject()}catch(e){r.error(`Failed to create project: ${String(e)}`),process.exit(1)}});w.parse();
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 b=Object.defineProperty;var u=($,e)=>b($,"name",{value:e,configurable:!0});import{LoggingPretty as w}from"logging-pretty";var n=new w;import*as a from"fs";import*as o from"path";import{fileURLToPath as C}from"url";import{spawn as y}from"child_process";import _ from"enquirer";var S=C(import.meta.url),k=o.dirname(S),l=class{constructor(e){this.projectDirectory=e}static{u(this,"Create")}config;printBanner(){console.log(`
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","pm2:start":"bun run pm2:start","pm2:stop":"bun run pm2:stop","pm2:restart":"bun run pm2:restart","pm2:delete":"bun run pm2:delete","pm2:logs":"bun run pm2:logs","pm2:monit":"bun run pm2:monit"},npm:{install:"npm install",dev:"npm run dev",start:"npm start","pm2:start":"npm run pm2:start","pm2:stop":"npm run pm2:stop","pm2:restart":"npm run pm2:restart","pm2:delete":"npm run pm2:delete","pm2:logs":"npm run pm2:logs","pm2:monit":"npm run pm2:monit"},pnpm:{install:"pnpm install",dev:"pnpm dev",start:"pnpm start","pm2:start":"pnpm pm2:start","pm2:stop":"pnpm pm2:stop","pm2:restart":"pnpm pm2:restart","pm2:delete":"pnpm pm2:delete","pm2:logs":"pnpm pm2:logs","pm2:monit":"pnpm pm2:monit"},yarn:{install:"yarn install",dev:"yarn dev",start:"yarn start","pm2:start":"yarn pm2:start","pm2:stop":"yarn pm2:stop","pm2:restart":"yarn pm2:restart","pm2:delete":"yarn pm2:delete","pm2:logs":"yarn pm2:logs","pm2:monit":"yarn pm2:monit"}}[e]}copyDirectorySync(e,r,t={}){a.existsSync(r)||a.mkdirSync(r,{recursive:!0});let p=a.readdirSync(e,{withFileTypes:!0});for(let s of p){let c=o.join(e,s.name),m=o.join(r,s.name);if(s.isDirectory())this.copyDirectorySync(c,m,t);else if(s.isFile()){let i=a.readFileSync(c,"utf-8");i=this.replaceTemplateVariables(i,t),a.writeFileSync(m,i)}}}replaceTemplateVariables(e,r){let t=e;for(let[p,s]of Object.entries(r))t=t.replace(new RegExp(`{{${p}}}`,"g"),s);return t}async promptForProjectName(){return(await _.prompt({type:"input",name:"projectName",message:"What is your project named?",initial:"",validate:u(r=>r===""||/^[a-z0-9-_]+$/i.test(r)?!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 r=await _.prompt(e);return{packageManager:r.packageManager,runtime:r.runtime,eslint:r.eslint}}async installDependencies(e,r){return await new Promise((t,p)=>{let m=y(r,["install"],{cwd:e,stdio:"inherit",shell:!0});m.on("close",i=>{i===0?t(!0):(n.fail("Dependencies installation failed"),t(!1))}),m.on("error",i=>{n.fail(`Dependencies installation failed: ${i.message}`),t(!1)})})}async gatherProjectConfig(){this.printBanner();let e=this.projectDirectory,r,t=!1;e?(r=o.resolve(process.cwd(),e),t=!1):(e=await this.promptForProjectName(),e===""?(e=o.basename(process.cwd()),r=process.cwd(),t=!0):(r=o.resolve(process.cwd(),e),t=!1));let p=await this.promptForConfiguration(),s=p.packageManager,c=p.runtime,m=p.eslint;return n.info(`Project: ${e}`),n.info(`Location: ${r}`),n.info(`Package Manager: ${s}`),n.info(`Runtime: ${c}`),n.info(`ESLint: ${m?"Yes":"No"}`),t?a.readdirSync(r).length>0&&(n.error("Current directory is not empty!"),process.exit(1)):a.existsSync(r)&&(n.error(`Directory "${e}" already exists!`),process.exit(1)),{projectName:e,projectPath:r,packageManager:s,runtime:c,setupEslint:m}}async executeProjectGeneration(e){let{projectName:r,projectPath:t,packageManager:p,runtime:s,setupEslint:c}=e;n.info("Creating project directory.."),a.existsSync(t)||a.mkdirSync(t,{recursive:!0}),n.info("Copying template files..");let m=o.join(k,"templates"),i=this.getPackageManagerCommands(p),P={projectName:r,installCmd:i.install,runDevCmd:i.dev,runStartCmd:i.start,runPm2StartCmd:i["pm2:start"],runPm2StopCmd:i["pm2:stop"],runPm2RestartCmd:i["pm2:restart"],runPm2DeleteCmd:i["pm2:delete"],runPm2LogsCmd:i["pm2:logs"],runPm2MonitCmd:i["pm2:monit"]};this.copyDirectorySync(m,t,P),n.info("Creating logs directory.."),a.mkdirSync(o.join(t,"logs"),{recursive:!0}),a.writeFileSync(o.join(t,"logs/.gitkeep"),"");let j=o.join(t,".env"),g=o.join(t,".env.example");if(a.existsSync(g)&&(n.info("Creating .env file.."),a.renameSync(g,j)),s!=="bun"){n.info("Removing bunfig.toml for Node.js runtime..");let d=o.join(t,"bunfig.toml");a.existsSync(d)&&a.unlinkSync(d)}let f=o.join(t,"tsconfig.json"),v=a.readFileSync(f,{encoding:"utf8"}).replace("//{{types}}",s=="bun"?'"bun-types"':"");if(a.writeFileSync(f,v,{encoding:"utf8"}),n.info("Installing dependencies.."),!await this.installDependencies(t,p))return n.fail("Project created failed!"),process.exit();c&&(n.info("Setting up ESLint.."),await this.setupEslintConfig(t,p)),n.info("Project created successfully!"),n.info(`Next steps: ${e.projectPath!==process.cwd()?`cd ${r} && `:" "}${i.install} && ${i.dev}`),n.info(`For production: ${i["pm2:start"]}`),n.info("Done..")}async setupEslintConfig(e,r){return new Promise(t=>{let p=y("npm",["init","@eslint/config@latest"],{cwd:e,stdio:"inherit",shell:!0});p.on("close",s=>{s===0||n.fail("ESLint setup failed. You can set it up later with: npm init @eslint/config"),t()}),p.on("error",s=>{n.fail(`ESLint setup failed: ${s.message}`),n.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?n.error(`Failed to create project: ${e.message}`):n.error(`Failed to create project: ${String(e)}`),process.exit(1)}}};import{Command as x}from"commander";var M="0.0.0",h=new x;h.name("create-gramstax").description("CLI to create a new Gramstax Telegram bot project").version(M).argument("[project-directory]","Directory to create the project in").action(async $=>{try{await new l($).createProject()}catch(e){n.error(`Failed to create project: ${String(e)}`),process.exit(1)}});h.parse();
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 (dynamic value = url public)
8
- # - serverless:std/http (dynamic value = adapter)
9
- BOT_DEPLOY=polling
10
-
11
- # Environment
12
- NODE_ENV=development
13
-
14
- # Cache configuration for session
15
- # Options:
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
- - `NODE_ENV` - Environment mode (development/production)
104
- - `CACHE_SESSION` - Cache type configuration (optional)
105
-
106
- ### PM2 Configuration
107
-
108
- The `ecosystem.config.js` file contains PM2 configuration:
109
-
110
- - **instances**: Number of instances (default: 1)
111
- - **exec_mode**: Execution mode (cluster/fork)
112
- - **max_memory_restart**: Auto-restart if memory exceeds limit
113
- - **autorestart**: Auto-restart on crash
114
- - **error_file/out_file**: Log file locations
115
-
116
- ## Learn More
117
-
118
- - [Gramstax Documentation](https://github.com/gramstax/gramstax)
119
- - [Grammy Documentation](https://grammy.dev/)
120
- - [Telegram Bot API](https://core.telegram.org/bots/api)
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 '**/*.ts'",
35
- "lint:fix": "eslint '**/*.ts' --fix",
36
- "pm2:start": "pm2 start ecosystem.config.js",
37
- "pm2:stop": "pm2 stop ecosystem.config.js",
38
- "pm2:restart": "pm2 restart ecosystem.config.js",
39
- "pm2:delete": "pm2 delete ecosystem.config.js",
40
- "pm2:logs": "pm2 logs",
41
- "pm2:monit": "pm2 monit"
42
- },
43
- "dependencies": {
44
- "gramstax": "latest",
45
- "logging-pretty": "^3.0.0"
46
- },
47
- "peerDependencies": {
48
- "typescript": "latest"
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/ctx"
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
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./guard"
2
+ export * from "./page"
3
+ export * from "./repository"
4
+ export * from "./service"
@@ -1,3 +1,3 @@
1
- import { CtxCore } from "~/core/ctx"
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 {}