create-tezx-app 2.0.10 → 4.0.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 (3) hide show
  1. package/README.md +0 -0
  2. package/bin +201 -131
  3. package/package.json +1 -1
package/README.md CHANGED
File without changes
package/bin CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{execSync as K}from"node:child_process";import{mkdirSync as j,writeFileSync as Y}from"node:fs";import E,{join as q,resolve as Q}from"node:path";import P from"node:readline";var p=(n,s)=>({version:s,npm:["npm install",n],bun:["bun add",n],yarn:["yarn add",n],pnpm:["pnpm add",n]});var I={readme:`
2
+ import{execSync as B}from"node:child_process";import{mkdirSync as S,writeFileSync as q}from"node:fs";import k,{join as V,resolve as J}from"node:path";import W from"node:readline";var p=(n,s)=>({version:s,npm:["npm install",n],bun:["bun add",n],yarn:["yarn add",n],pnpm:["pnpm add",n]});var $={readme:`
3
3
  # \u{1F510} GitHub OAuth2 Example for TezX
4
4
 
5
5
  This example demonstrates how to implement GitHub OAuth2 login using \`@tezx/github-oauth2\`.
@@ -20,7 +20,7 @@ This example demonstrates how to implement GitHub OAuth2 login using \`@tezx/git
20
20
  ### 1. Install the required package
21
21
 
22
22
  \`\`\`bash
23
- ${Object.values(p("@tezx/github-oauth2","^1.0.3"))?.filter(n=>typeof n!="string")?.join(`
23
+ ${Object.values(p("@tezx/github-oauth2","^1.0.9"))?.filter(n=>typeof n!="string")?.join(`
24
24
  #or
25
25
  `)}
26
26
  \`\`\`
@@ -50,7 +50,7 @@ Use callback URL:
50
50
  app.get('/github', getGithubOAuthURL({
51
51
  authClient: client,
52
52
  }), (ctx) => {
53
- return ctx.redirect(ctx.state.get('github_oauth_url'));
53
+ return ctx.redirect(ctx.github.oauth_url);
54
54
  });
55
55
  \`\`\`
56
56
 
@@ -103,7 +103,7 @@ const client = GitHubOauthClient({
103
103
  app.get('/github', getGithubOAuthURL({
104
104
  authClient: client,
105
105
  }), (ctx) => {
106
- return ctx.redirect(ctx.state.get('github_oauth_url'));
106
+ return ctx.redirect(ctx.github.oauth_url);
107
107
  });
108
108
 
109
109
  // Step 2: Verify GitHub token and handle user session
@@ -122,7 +122,7 @@ app.get('/github/callback', verifyGithubToken({
122
122
  return ctx.json({ success: true });
123
123
  });
124
124
  `.trim(),files:[{content:`GITHUB_CLIENT_ID=12323
125
- GITHUB_CLIENT_SECRET=234234`,path:".env"}],import:["import { GitHubOauthClient, getGithubOAuthURL, verifyGithubToken } from '@tezx/github-oauth2';"],package:[p("@tezx/github-oauth2","^1.0.3")]};var G={readme:`
125
+ GITHUB_CLIENT_SECRET=234234`,path:".env"}],import:["import { GitHubOauthClient, getGithubOAuthURL, verifyGithubToken } from '@tezx/github-oauth2';"],package:[p("@tezx/github-oauth2","^1.0.9")]};var C={readme:`
126
126
  # \u{1F510} Google OAuth2 Example for TezX
127
127
 
128
128
  This example demonstrates how to use \`@tezx/google-oauth2\` to implement Google OAuth2 login in your TezX app.
@@ -145,7 +145,7 @@ This example demonstrates how to use \`@tezx/google-oauth2\` to implement Google
145
145
  Choose your package manager and install:
146
146
 
147
147
  \`\`\`bash
148
- ${Object.values(p("@tezx/google-oauth2","^1.0.9")).filter(n=>typeof n!="string").join(`
148
+ ${Object.values(p("@tezx/google-oauth2","^1.0.13")).filter(n=>typeof n!="string").join(`
149
149
  # or
150
150
  `)}
151
151
 
@@ -178,7 +178,7 @@ app.get('/auth/google', getGoogleOAuthURL({
178
178
  authClient: client,
179
179
  scopes: ['openid', 'email', 'profile'],
180
180
  }), (ctx) => {
181
- return ctx.redirect(ctx.state.get('google_oauth_url'));
181
+ return ctx.redirect(ctx.google?.oauth_url);
182
182
  });
183
183
  \`\`\`
184
184
 
@@ -244,7 +244,7 @@ app.get('/auth/google', getGoogleOAuthURL({
244
244
  authClient: client,
245
245
  scopes: ['openid','email','profile'],
246
246
  }), (ctx) => {
247
- return ctx.redirect(ctx.state.get('google_oauth_url'));
247
+ return ctx.redirect(ctx.google?.oauth_url);
248
248
  });
249
249
 
250
250
  // 3. Callback route, verify token and establish session
@@ -281,7 +281,7 @@ app.get('/auth/callback', verifyGoogleToken({
281
281
  });
282
282
  `.trim(),files:[{content:`GOOGLE_CLIENT_ID=12323
283
283
  GOOGLE_CLIENT_SECRET=234234
284
- `,path:".env"}],import:['import { GoogleOauthClient, getGoogleOAuthURL, verifyGoogleToken } from "@tezx/google-oauth2";'],package:[p("@tezx/google-oauth2","^1.0.9"),p("@googleapis/oauth2","^2.0.1")]};var R={readme:`
284
+ `,path:".env"}],import:['import { GoogleOauthClient, getGoogleOAuthURL, verifyGoogleToken } from "@tezx/google-oauth2";'],package:[p("@tezx/google-oauth2","^1.0.13"),p("@googleapis/oauth2","^2.0.1")]};var O={readme:`
285
285
  # TezX View Engine Example
286
286
 
287
287
  This example demonstrates how to use the \`@tezx/view-engine\` package to render server-side views using template engines such as **EJS**, **Pug**, **Handlebars**, **Mustache**, or **Nunjucks**.
@@ -357,7 +357,7 @@ app.get("engine", async (ctx) => {
357
357
  <p>Hello, <%= user.name %> \u{1F44B}</p>
358
358
  </body>
359
359
  </html>
360
- `.trim(),path:"views/home.ejs"}],import:['import { ViewEngine } from "@tezx/view-engine";'],package:[p("@tezx/view-engine","^1.0.3"),p("ejs","^3.1.10")]};var F=`
360
+ `.trim(),path:"views/home.ejs"}],import:['import { ViewEngine } from "@tezx/view-engine";'],package:[p("@tezx/view-engine","^1.0.3"),p("ejs","^3.1.10")]};var L=`
361
361
  <!DOCTYPE html>
362
362
  <html lang="en">
363
363
  <head>
@@ -525,7 +525,7 @@ app.get("engine", async (ctx) => {
525
525
  </script>
526
526
  </body>
527
527
  </html>
528
- `,_={readme:`
528
+ `,j={readme:`
529
529
  # \u{1F50C} TezX WebSocket Example
530
530
 
531
531
  This example demonstrates how to set up a WebSocket server using \`upgradeWebSocket\` from \`tezx/ws\`.
@@ -640,181 +640,254 @@ app.get(
640
640
  return ctx.sendFile("public/ws.html");
641
641
  },
642
642
  );
643
- `.trim(),files:[{content:F,path:"public/ws.html"}],import:['import { upgradeWebSocket } from "tezx/ws";']};var z={minimal:{readme:"",content:"",files:[],import:[],package:[]},ws:_,"github-oauth2":I,"google-oauth2":G,"view-engine":R};import B from"node:readline";async function C(n,s,t){return new Promise(r=>{let o=0;B.emitKeypressEvents(process.stdin,n),process.stdin.isTTY&&process.stdin.setRawMode(!0);let a=()=>{process.stdout.write("\x1B[2J\x1B[0f"),console.log(s+` (Use \u2191 \u2193 arrows, Enter to confirm)
644
- `),t.forEach((l,i)=>{console.log(`${i===o?"\u{1F449}":" "} ${i===o?"\x1B[36m":"\x1B[0m"}${l}\x1B[0m`)})},c=(l,i)=>{if(i.name==="up")o=(o-1+t.length)%t.length,a();else if(i.name==="down")o=(o+1)%t.length,a();else if(i.name==="return")return r(t[o])};a(),process.stdin.on("keypress",c)})}var A={reset:"\x1B[0m",bold:"\x1B[1m",underline:"\x1B[4m",gray:"\x1B[90m",white:"\x1B[97m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",orange:"\x1B[38;2;255;88;30m",bgOrange:"\x1B[48;2;255;88;30m"};function e(n,s){return`${A[s]}${n}${A.reset}`}import{mkdirSync as V,writeFileSync as y}from"node:fs";import{join as h}from"node:path";var g="2.0.8";var J=`
645
- # \u{1F680} TezX Starter Template
643
+ `.trim(),files:[{content:L,path:"public/ws.html"}],import:['import { upgradeWebSocket } from "tezx/ws";']};var T={minimal:{readme:"",content:"",files:[],import:[],package:[]},ws:j,"github-oauth2":$,"google-oauth2":C,"view-engine":O};import M from"node:readline";async function R(n,s,t){return new Promise(a=>{let o=0;M.emitKeypressEvents(process.stdin,n),process.stdin.isTTY&&process.stdin.setRawMode(!0);let l=()=>{process.stdout.write("\x1B[2J\x1B[0f"),console.log(s+` (Use \u2191 \u2193 arrows, Enter to confirm)
644
+ `),t.forEach((c,r)=>{console.log(`${r===o?"\u{1F449}":" "} ${r===o?"\x1B[36m":"\x1B[0m"}${c}\x1B[0m`)})},i=(c,r)=>{if(r.name==="up")o=(o-1+t.length)%t.length,l();else if(r.name==="down")o=(o+1)%t.length,l();else if(r.name==="return")return a(t[o])};l(),process.stdin.on("keypress",i)})}var I={reset:"\x1B[0m",bold:"\x1B[1m",underline:"\x1B[4m",gray:"\x1B[90m",white:"\x1B[97m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",orange:"\x1B[38;2;255;88;30m",bgOrange:"\x1B[48;2;255;88;30m"};function e(n,s){return`${I[s]}${n}${I.reset}`}import{mkdirSync as D,writeFileSync as y}from"node:fs";import{join as d}from"node:path";var g="4.0.1";var U=`
645
+ # \u26A1 TezX \u2013 High-Performance JavaScript Framework for **Bun**
646
646
 
647
- Welcome to the **TezX Starter Template** \u2014 a blazing-fast, full-featured backend template built on [TezX](https://github.com/tezxjs/tezx), the lightweight web framework inspired by the best of Express, Hono, and Bun.
647
+ **TezX** is a modern, ultra-fast, and lightweight JavaScript framework built specifically for **Bun**.
648
+ With a clean API, powerful routing, WebSocket support, middleware stacking, and native static file serving \u2014 TezX helps you build scalable applications with unmatched speed.
648
649
 
649
- This starter is designed to help you spin up production-ready APIs or SSR apps in seconds.
650
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/tezxjs/TezX)
650
651
 
651
652
  ---
652
653
 
653
- ## \u2728 Features
654
+ ## \u{1F680} Why TezX (Built for Bun)?
654
655
 
655
- - \u26A1\uFE0F Ultra-fast routing & middleware
656
- - \u{1F512} Built-in WebSocket & OAuth2-ready
657
- - \u{1F527} Plug-and-play \`ViewEngine\` for SSR
658
- - \u{1F331} Environment-based config support
659
- - \u{1F9EA} Minimal, testable, and extendable codebase
656
+ * \u26A1 **Blazing Fast** \u2014 Fully optimized for Bun\u2019s event loop & native performance.
657
+ * \u{1F9E9} **Minimal, Clean API** \u2014 Developer-friendly and intuitive.
658
+ * \u{1F5C2} **Native Static Serving** \u2014 No external dependencies needed.
659
+ * \u{1F50C} **Powerful Middleware Engine** \u2014 Compose any logic effortlessly.
660
+ * \u{1F9ED} **Advanced Routing** \u2014 Dynamic, nested, and pattern-based.
661
+ * \u{1F510} **Secure by Default** \u2014 Built-in safe context handling.
662
+ * \u{1F4E1} **WebSocket Support** \u2014 Real-time apps made easy with \`wsHandlers\`.
663
+ * \u267B\uFE0F **Multi-Process Ready** \u2014 Via Bun\u2019s \`reusePort\`.
660
664
 
661
665
  ---
662
666
 
663
- ## \u{1F4E6} Tech Stack
667
+ ## \u{1F4E6} Installation
664
668
 
665
- - **Framework:** [TezX](https://github.com/tezxjs/tezx)
666
- - **Language:** TypeScript / JavaScript
667
- - **Template Engine (optional):** \`ejs\`, \`pug\`, \`hbs\`, \`mustache\`, or \`nunjucks\`
668
- - **Runtime Support:** Node.js, Bun, Deno (via compatibility)
669
+ \`\`\`bash
670
+ bun add tezx
671
+ # or
672
+ npm install tezx
673
+ \`\`\`
669
674
 
670
675
  ---
671
676
 
672
- ## \u{1F6E0}\uFE0F Getting Started
677
+ ## \u26A1 Quick Start (Bun)
673
678
 
674
- ### 1. Install Dependencies
679
+ \`\`\`ts
680
+ import { TezX } from "tezx";
681
+ import { logger } from "tezx/middleware";
682
+ import { serveStatic } from "tezx/static";
683
+ import { wsHandlers } from "tezx/ws";
675
684
 
676
- \`\`\`bash
677
- npm install
678
- # or
679
- bun install
680
- \`\`\`\`
685
+ const app = new TezX();
681
686
 
682
- ### 2. Start Development Server
687
+ // Middlewares
688
+ app.use(logger());
683
689
 
684
- \`\`\`bash
685
- npm run dev
686
- # or
687
- bun run dev
690
+ // Static files
691
+ app.static(serveStatic("/", "./static"));
692
+
693
+ // Route
694
+ app.get("/", (ctx) =>
695
+ ctx.html(\`
696
+ <h1>Welcome to TezX</h1>
697
+ <p>High-performance JavaScript framework optimized for Bun.</p>
698
+ \`)
699
+ );
700
+
701
+ // Server
702
+ const port = Number(process.env.PORT) || 3001;
703
+
704
+ Bun.serve({
705
+ port,
706
+ reusePort: true,
707
+ fetch(req, server) {
708
+ return app.serve(req, server);
709
+ },
710
+ websocket: wsHandlers({
711
+ // Optional WebSocket config
712
+ }),
713
+ });
714
+
715
+ console.log(\`\u{1F680} TezX server running at http://localhost:\${port}\`);
688
716
  \`\`\`
689
717
 
690
- ### 3. Open in Browser
718
+ ---
719
+
720
+ ## \u25B6 Run the Server
691
721
 
692
722
  \`\`\`bash
693
- http://localhost:3000
723
+ bun run server.ts
724
+ \`\`\`
725
+
726
+ ---
727
+
728
+ ## \u{1F50C} Middleware Example
729
+
730
+ \`\`\`ts
731
+ app.use((ctx, next) => {
732
+ console.log("\u27A1 Request:", ctx.req.url);
733
+ return next();
734
+ });
694
735
  \`\`\`
695
736
 
696
737
  ---
697
738
 
698
- ## \u{1F510} Environment Variables
739
+ ## \u{1F5C2} Static File Serving
699
740
 
700
- Create a \`.env\` file at the project root:
741
+ \`\`\`ts
742
+ import { serveStatic } from "tezx/static";
701
743
 
702
- \`\`\`bash
703
- PORT=3000
704
- NODE_ENV=development
744
+ app.static(serveStatic("/assets", "./assets"));
745
+ \`\`\`
746
+
747
+ Access via:
705
748
 
706
- # For OAuth2 templates
707
- GOOGLE_CLIENT_ID=your-client-id
708
- GOOGLE_CLIENT_SECRET=your-secret
749
+ \`\`\`bash
750
+ http://localhost:3001/assets/your-file.ext
709
751
  \`\`\`
710
752
 
711
753
  ---
712
754
 
713
- ## \u{1F4C1} Project Structure
755
+ ## \u{1F9ED} Routing
714
756
 
757
+ \`\`\`ts
758
+ app.get("/about", (ctx) => ctx.html("<h1>About TezX</h1>"));
759
+
760
+ app.post("/contact", async (ctx) => {
761
+ const body = await ctx.json();
762
+ return ctx.json({ received: body });
763
+ });
715
764
  \`\`\`
716
- .
717
- \u251C\u2500\u2500 public/ # Static files (images, js, css)
718
- \u251C\u2500\u2500 views/ # SSR templates (optional)
719
- \u251C\u2500\u2500 src/
720
- \u2502 \u251C\u2500\u2500 index.ts # Entry point
721
- \u2502 \u2514\u2500\u2500 routes/ # Route modules
722
- \u251C\u2500\u2500 .env
723
- \u251C\u2500\u2500 .gitignore
724
- \u2514\u2500\u2500 package.json
765
+
766
+ ---
767
+
768
+ ## \u26A0\uFE0F Error Handling
769
+
770
+ \`\`\`ts
771
+ app.onError((err, ctx) => {
772
+ return ctx.status(500).json({
773
+ error: "Internal Server Error",
774
+ message: err.message,
775
+ });
776
+ });
725
777
  \`\`\`
726
778
 
727
779
  ---
728
780
 
729
- ## \u{1F9EA} Example Commands
781
+ ## \u{1F9EA} Development Setup
730
782
 
731
- \`\`\`bash
732
- # Build the app
733
- bun run build
783
+ ### \`dev\` script for Bun
734
784
 
735
- # Start the server in production
736
- bun start
785
+ **package.json**
737
786
 
738
- # Run a TezX test (if added)
739
- bun test
787
+ \`\`\`json
788
+ {
789
+ "scripts": {
790
+ "dev": "bun run --hot --watch src/index.ts"
791
+ }
792
+ }
740
793
  \`\`\`
741
794
 
742
- ---
795
+ ### Example: \`src / index.ts\`
743
796
 
744
- ## \u{1F91D} Contributing
797
+ \`\`\`ts
798
+ import app from "./app";
745
799
 
746
- Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
800
+ Bun.serve({
801
+ port: 3001,
802
+ reusePort: true,
803
+ fetch(req, server) {
804
+ return app.serve(req, server);
805
+ },
806
+ });
807
+ \`\`\`
747
808
 
748
809
  ---
749
810
 
750
- ## \u{1F4C4} License
811
+ ## \u{1F91D} Contributing
812
+
813
+ We welcome contributions!
751
814
 
752
- MIT \xA9 [SRAKIB17](https://github.com/SRAKIB17)
815
+ 1. Fork the repo
816
+ 2. Create a new branch
817
+ 3. Commit your changes
818
+ 4. Open a pull request
819
+
820
+ \u{1F449} GitHub: **[https://github.com/tezxjs](https://github.com/tezxjs)**
753
821
 
754
822
  ---
755
823
 
756
- ## \u{1F49A} Powered by
824
+ ## \u{1F496} Support TezX
825
+
826
+ If TezX helps you, consider supporting:
757
827
 
758
- [TezX Framework](https://github.com/tezxjs/TezX) \xB7 Made with performance in mind
828
+ * \u2B50 Star on GitHub
829
+ * \u{1F4B8} Sponsor on GitHub: [https://github.com/sponsors/srakib17](https://github.com/sponsors/srakib17)
830
+
831
+ Your support helps improve the framework.
759
832
 
760
833
  ---
761
834
 
762
- `,L=({ts:n,template:s,root:t,env:r,useStatic:o=!1,staticFolder:a})=>{let c=h(t,n?"src/index.ts":"src/index.js");V(h(t,"src"),{recursive:!0});let l=`
835
+ `,G=({ts:n,template:s,root:t,useStatic:a=!1,staticFolder:o})=>{let l=d(t,n?"src/index.ts":"src/index.js");D(d(t,"src"),{recursive:!0});let i="";s?.import?.push('import { wsHandlers } from "tezx/ws";'),i=`
836
+ let PORT = Number(process.env.PORT) || 3000;
837
+ Bun.serve({
838
+ port: PORT,
839
+ reusePort: true, // Enables multi-process clustering
840
+ fetch(req, server) {
841
+ return app.serve(req, server); // Handle requests via TezX
842
+ },
843
+ websocket: wsHandlers({
844
+ // Optional WebSocket configure
845
+ })
846
+ });
847
+ console.log(\`\u{1F680} TezX is running at http://localhost:\${PORT}\`);
848
+ `;let c=`
763
849
  import { TezX } from "tezx";
764
- import { ${r}Adapter ,loadEnv} from "tezx/${r}";
850
+ import { serveStatic } from "tezx/static";
765
851
  import { logger } from "tezx/middleware";
766
852
  ${s?.import?.join(`
767
853
  `)}
768
854
  const app = new TezX({
769
- env: loadEnv(),
770
855
  debugMode: true,
771
856
  // Additional options
772
857
  });
773
858
  app.use([logger()]);
774
859
 
775
- app.get("/", (ctx) => ctx.text("Hello from TezX (${r})"));
860
+ app.get("/", (ctx) => ctx.text("Hello from TezX"));
776
861
 
777
- ${o?`app.static("${a||"public"}");`:""}
862
+ ${a?`app.static(serveStatic("${o||"public"}"));`:""}
778
863
  ${s?.content?`
779
864
  ${s?.content?.trim()}
780
865
  `:""}
781
- ${r}Adapter(app).listen(3000, () => {
782
- console.log("\u{1F680} TezX running on http://localhost:3000");
783
- });
784
- `;if(n){let i=`
866
+ ${i}
867
+ `;if(n){let r=`
785
868
  {
786
869
  "compilerOptions": {
787
- "outDir": "./dist",
788
- "module": "CommonJS",
789
- "target": "ESNext",
790
- "moduleResolution": "node",
791
- "skipLibCheck": true,
792
- "removeComments": false,
793
- "esModuleInterop": true,
794
- "resolveJsonModule": true,
870
+ "module": "esnext",
871
+ "target": "esnext",
872
+ "moduleResolution": "bundler",
795
873
  "strict": true,
874
+ "skipLibCheck": true,
875
+ "allowImportingTsExtensions": true,
876
+ "noEmit": true
796
877
  },
797
- "include": [
798
- "src",
799
- ],
800
- "exclude": [
801
- "node_modules",
802
- "dist",
803
- "tests"
804
- ]
878
+ "include": ["src"],
879
+ "exclude": ["node_modules", "dist"]
805
880
  }
806
- `.trim();y(h(t,"tsconfig.json"),i)}y(c,l.trim())},N=({template:n,root:s,projectName:t,env:r,ts:o,useWS:a,choiceStep:c})=>{let l=[];Array.isArray(n?.package)&&n?.package?.forEach(m=>{let{version:v,npm:T}=m||{};l.push(`"${T?.[1]}": "${v}"`)});let i={bun:{start:"bun dist/index.js",dev:"bun run --hot --watch src/index.ts"},deno:{start:"deno run --allow-all dist/index.js",dev:"deno run --watch --allow-all --unstable-sloppy-imports src/index.ts"},node:{start:"node dist/index.js",dev:"tsx watch src/index.ts"}},u=`
881
+ `.trim();y(d(t,"tsconfig.json"),r)}y(l,c.trim())},A=({template:n,root:s,projectName:t,ts:a,useWS:o,choiceStep:l})=>{let i=[];Array.isArray(n?.package)&&n?.package?.forEach(h=>{let{version:b,npm:m}=h||{};i.push(`"${m?.[1]}": "${b}"`)});let c=['"@types/bun": "^1.3.1"'];a&&(c.push('"typescript": "^5.8.2"'),c.push('"@types/node": "^22.13.14"'));let r=`
807
882
  {
808
883
  "name": "${t||"tezx-app-example"}",
809
884
  "version": "1.0.0",
810
885
  "type": "module",
811
- "description": "TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, and Bun.",
812
- "scripts": { ${o?`
813
- "build:esm": "tsc --module ESNext --outDir dist --removeComments",
814
- "build:dts": "tsc --module ESNext --outDir dist --declaration --emitDeclarationOnly",
815
- "build": "${c?.build}",`:""}
816
- "start": "${i?.[r]?.start}",
817
- "dev": "${i?.[r]?.dev}"
886
+ "description": "TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration.",
887
+ "scripts": {
888
+ "start": "bun src/index${a?".ts":".js"}",
889
+ "dev": "bun --hot --watch src/index${a?".ts":".js"}",
890
+ "type-check": ${a?'"tsc --noEmit"':`"echo 'No TypeScript configured'"`}
818
891
  },
819
892
  "repository": {
820
893
  "type": "git",
@@ -828,17 +901,16 @@ ${r}Adapter(app).listen(3000, () => {
828
901
  },
829
902
  "homepage": "https://github.com/tezxjs/tezx-app-example",
830
903
  "dependencies": {
831
- ${o?'"typescript": "^5.8.2",':""}
832
- "tezx": "^${g}"${r=="node"?`,
833
- "tsx": "^4.19.2"`:""}${a&&r=="node"?`,
834
- "ws": "^8.18.1"`:""}${l.length?`,
835
- ${l?.join(`,
836
- `)}`:""}
904
+ "tezx": "^${g}"${i.length?`,
905
+ ${i.join(`,
906
+ `)}`:""}
837
907
  },
838
908
  "devDependencies": {
839
- "@types/node": "^22.13.14"
909
+ ${c.join(`,
910
+ `)}
840
911
  }
841
- }`.trim();y(h(s,"package.json"),u)},D=({root:n})=>{let s=`
912
+ }
913
+ `.trim();y(d(s,"package.json"),r)},H=({root:n})=>{let s=`
842
914
  # Node dependencies
843
915
  node_modules/
844
916
  .env
@@ -908,33 +980,31 @@ Thumbs.db
908
980
  .vscode/
909
981
  .idea/
910
982
  *.swp
911
- `.trim();y(h(n,".gitignore"),s,{encoding:"utf8"})},M=({root:n,readme:s})=>{let t=typeof s=="string"&&s?s?.trim():J.trim();y(h(n,"README.md"),t,{encoding:"utf8"})};var x=["npm","bun","yarn","pnpm"],w=["node","bun","deno"];function Z(n){let s=0,t=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],r=setInterval(()=>{process.stdout.write(`\r${t[s=++s%t.length]} ${n}`)},80);return()=>{clearInterval(r),process.stdout.write(`\r\u2705 Done!
912
- `)}}var $=P.createInterface({input:process.stdin,output:process.stdout});P.emitKeypressEvents(process.stdin);process.stdin.isTTY&&process.stdin.setRawMode(!0);var f=(n,s="")=>new Promise(t=>{$.question(s?`${n} (${s}): `:n,r=>{t(r.trim()||s)})});async function W(n){let s=n?.directory,t=n?.options;console.log(e(`
913
- \u26A1 TezX App Creator(v${g})`,"orange")),s||(s=await f(e("\u{1F4E6} Project name: ","magenta")),s||(console.log(e("\u274C Project name required.","red")),process.exit(0)));let r=E.basename(s),o=Q(process.cwd(),s),a=!!t?.ts,c=t?.env||t?.runtime,l=w?.includes(c)?c:await C($,"\u{1F4BB} Runtime?",w),i=t?.staticFolder||"public",u=!0,m={content:"",import:[],readme:"",files:[]};if(t?.t||t?.template){let d=t.t||t.template,S=z?.[d];S||(console.error(`\u274C Unknown template: "${d}"`),console.error(`\u2139\uFE0F Available templates: ${Object.keys(z).join(", ")}`),process.exit(0)),m=S}else a=!!(t?.ts||(await f("\u{1F7E6} Use TypeScript? (y/N): ")).toLowerCase()==="y"),u=!!t?.useStatic||(await f("\u{1F4C1} Use static folder? (y/N): ")).toLowerCase()==="y",i=u?t?.staticFolder||await f("\u{1F4C2} Static folder name? (default: public): "):"";let v=t?.pm||t?.p,T=x?.includes(v)?v:await C($,"\u{1F4E6} Choose your package manager",x),k=t?.i==="true"||t?.install==="true"||(await f("\u{1F4E5} Install dependencies now? (y/N): ")).toLowerCase()==="y";console.log(`
914
- \u{1F4C1} Creating project: ${r}...
915
- `);let U=Z("Creating Project");if(j(o,{recursive:!0}),u){let d=q(o,i||"public");j(d,{recursive:!0})}let b={bun:{cd:"cd "+s,install:"bun install",dev:"bun dev",build:"bun build:esm && bun build:dts"},npm:{cd:"cd "+s,install:"npm install",dev:"npm run dev",build:"npm run build:esm && npm run build:dts"},yarn:{cd:"cd "+s,install:"yarn",dev:"yarn dev",build:"yarn build:esm && yarn build:dts"},pnpm:{cd:"cd "+s,install:"pnpm install",dev:"pnpm run dev",build:"pnpm run build:esm && pnpm run build:dts"}}[T];L({template:m,root:o,ts:!!a,env:l,staticFolder:i,useStatic:u}),N({projectName:r,env:l,root:o,ts:!!a,template:m,choiceStep:b}),D({root:o}),M({root:o,readme:m?.readme}),$.close(),m?.files?.forEach(d=>{let S=E.join(o,E.dirname(d?.path));j(S,{recursive:!0}),Y(E.join(o,d?.path),d?.content)}),k&&K(b?.install,{cwd:o,stdio:"inherit"}),console.log(e(`
916
- \u2705 TezX project "${r}" is ready!
917
- `,"green")),console.log(e("\u{1F9F0} Summary of your configuration:","cyan")),console.log(`\u{1F4C1} Project Name: ${e(r,"yellow")}`);let O=t?.t||t?.template;O&&console.log(`\u{1F4C1} Template Name: ${e(O,"orange")}`),console.log(`\u{1F7E6} TypeScript: ${e(a?"Yes":"No",a?"green":"gray")}`),console.log(`\u{1F4BB} Runtime: ${e(l,"blue")}`),console.log(`\u{1F4C1} Static Folder: ${e(u?i||"public":"Not Used",u?"green":"gray")}`),console.log(`\u{1F4E6} Package Manager: ${e(T,"magenta")}`),console.log(`\u{1F4E5} Dependencies Installed: ${e(k?"Yes":"No",k?"green":"red")}
918
- `),console.log(e("\u{1F449} Next Steps:","cyan")),console.log(e(` ${b?.cd}`,"white")),k||console.log(e(` ${b?.install}`,"white")),console.log(e(` ${b?.dev}`,"white")),console.log(""),U(),process.exit(0)}function X(){console.log(`
919
- ${e("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E","gray")}
920
- ${e("\u2502","gray")} ${e("\u26A1 Create TezX","yellow")} - Scaffold your next backend app ${e("\u2502","gray")}
921
- ${e("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F","gray")}
983
+ `.trim();y(d(n,".gitignore"),s,{encoding:"utf8"})},P=({root:n,readme:s})=>{let t=typeof s=="string"&&s?s?.trim():U.trim();y(d(n,"README.md"),t,{encoding:"utf8"})};var w=["npm","bun","yarn","pnpm"];function Y(n){let s=0,t=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],a=setInterval(()=>{process.stdout.write(`\r${t[s=++s%t.length]} ${n}`)},80);return()=>{clearInterval(a),process.stdout.write(`\r\u2705 Done!
984
+ `)}}var z=W.createInterface({input:process.stdin,output:process.stdout});W.emitKeypressEvents(process.stdin);process.stdin.isTTY&&process.stdin.setRawMode(!0);var x=(n,s="")=>new Promise(t=>{z.question(s?`${n} (${s}): `:n,a=>{t(a.trim()||s)})});async function _(n){let s=n?.directory,t=n?.options;console.log(e(`
985
+ \u26A1 TezX App Creator(v${g})`,"orange")),s||(s=await x(e("\u{1F4E6} Project name: ","magenta")),s||(console.log(e("\u274C Project name required.","red")),process.exit(0)));let a=k.basename(s),o=J(process.cwd(),s),l=!!t?.ts,i=t?.staticFolder||"public",c=!0,r={content:"",import:[],readme:"",files:[]};if(t?.t||t?.template){let u=t.t||t.template,v=T?.[u];v||(console.error(`\u274C Unknown template: "${u}"`),console.error(`\u2139\uFE0F Available templates: ${Object.keys(T).join(", ")}`),process.exit(0)),r=v}else l=!!(t?.ts||(await x("\u{1F7E6} Use TypeScript? (y/N): ")).toLowerCase()==="y"),c=!!t?.useStatic||(await x("\u{1F4C1} Use static folder? (y/N): ")).toLowerCase()==="y",i=c?t?.staticFolder||await x("\u{1F4C2} Static folder name? (default: public): "):"";let h=t?.pm||t?.p,b=w?.includes(h)?h:await R(z,"\u{1F4E6} Choose your package manager",w),m=t?.i==="true"||t?.install==="true"||(await x("\u{1F4E5} Install dependencies now? (y/N): ")).toLowerCase()==="y";console.log(`
986
+ \u{1F4C1} Creating project: ${a}...
987
+ `);let X=Y("Creating Project");if(S(o,{recursive:!0}),c){let u=V(o,i||"public");S(u,{recursive:!0})}let f={bun:{cd:"cd "+s,install:"bun install",dev:"bun dev",build:"bun build:esm && bun build:dts"},npm:{cd:"cd "+s,install:"npm install",dev:"npm run dev",build:"npm run build:esm && npm run build:dts"},yarn:{cd:"cd "+s,install:"yarn",dev:"yarn dev",build:"yarn build:esm && yarn build:dts"},pnpm:{cd:"cd "+s,install:"pnpm install",dev:"pnpm run dev",build:"pnpm run build:esm && pnpm run build:dts"}}[b];G({template:r,root:o,ts:!!l,staticFolder:i,useStatic:c}),A({projectName:a,root:o,ts:!!l,template:r,choiceStep:f}),H({root:o}),P({root:o,readme:r?.readme}),z.close(),r?.files?.forEach(u=>{let v=k.join(o,k.dirname(u?.path));S(v,{recursive:!0}),q(k.join(o,u?.path),u?.content)}),m&&B(f?.install,{cwd:o,stdio:"inherit"}),console.log(e(`
988
+ \u2705 TezX project "${a}" is ready!
989
+ `,"green")),console.log(e("\u{1F9F0} Summary of your configuration:","cyan")),console.log(`\u{1F4C1} Project Name: ${e(a,"yellow")}`);let E=t?.t||t?.template;E&&console.log(`\u{1F4C1} Template Name: ${e(E,"orange")}`),console.log(`\u{1F7E6} TypeScript: ${e(l?"Yes":"No",l?"green":"gray")}`),console.log(`\u{1F4C1} Static Folder: ${e(c?i||"public":"Not Used",c?"green":"gray")}`),console.log(`\u{1F4E6} Package Manager: ${e(b,"magenta")}`),console.log(`\u{1F4E5} Dependencies Installed: ${e(m?"Yes":"No",m?"green":"red")}
990
+ `),console.log(e("\u{1F449} Next Steps:","cyan")),console.log(e(` ${f?.cd}`,"white")),m||console.log(e(` ${f?.install}`,"white")),console.log(e(` ${f?.dev}`,"white")),console.log(""),X(),process.exit(0)}function F(){console.log(`
991
+ ${e("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E","gray")}
992
+ ${e("\u2502","gray")}${e(" \u26A1 Create TezX","yellow")} - Scaffold your next backend app ${e("\u2502","gray")}
993
+ ${e("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F","gray")}
922
994
 
923
995
  ${e("\u{1F4E6} Usage:","cyan")}
924
- ${e("create-tezx","green")} ${e("[directory] [...options]","gray")}
996
+ ${e("create-tezx","green")} ${e("[directory] [...options]","gray")}
925
997
 
926
998
  ${e("\u{1F680} Quick Start:","cyan")}
927
999
  ${e("npm","magenta")} create tezx@latest
928
1000
  ${e("yarn","magenta")} create tezx
929
1001
  ${e("pnpm","magenta")} create tezx@latest
930
1002
  ${e("bun","magenta")} create tezx@latest
931
- ${e("deno","magenta")} run -A npm:create-tezx@latest
932
1003
 
933
1004
  ${e("\u{1F39B}\uFE0F Options:","cyan")}
934
1005
 
935
1006
  ${e("-t, --template <name>","green")} Use a specific starter template
936
1007
  ${e("--ts, -ts","green")} Enable TypeScript setup
937
- ${e("--env, --runtime <env>","green")} Set runtime: node | bun | deno
938
1008
  ${e("-p, --pm <manager>","green")} Package manager: npm | bun | yarn | pnpm
939
1009
  ${e("-i, --install","green")} Automatically install dependencies
940
1010
  ${e("-y, --yes","green")} Skip prompts using default options
@@ -942,7 +1012,7 @@ Thumbs.db
942
1012
  ${e("-h, --help","green")} Display this help message
943
1013
 
944
1014
  ${e("\u{1F9F0} Examples:","cyan")}
945
- ${e("npm create tezx@latest my-app --template ws --ts --env node","gray")}
1015
+ ${e("npm create tezx@latest my-app --template ws --ts","gray")}
946
1016
  ${e("bun create tezx@latest -- --install --pm bun","gray")}
947
1017
 
948
1018
  ${e("\u{1F4C1} Available Templates:","cyan")}
@@ -955,4 +1025,4 @@ Thumbs.db
955
1025
  ${e("https://github.com/tezxjs/tezx","underline")}
956
1026
 
957
1027
  ${e("\u{1F9D1}\u200D\u{1F4BB} Author:","cyan")}
958
- Rakibul Islam ${e("<https://github.com/srakib17>","blue")}`),process.exit(0)}function H(){console.log(`TezX CLI v${g}`),process.exit(0)}(async()=>{let n=(a,c)=>{c.name==="c"&&c.ctrl&&(process.stdin.off("keypress",n),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.exit(0))};process.stdin.on("keypress",n);let s=process.argv.slice(2),t={},r;for(let a=0;a<s.length;a++){let c=s[a];if(c.startsWith("--")){let l=c.slice(2),i=s[a+1];i&&!i.startsWith("-")?(t[l]=i,a++):t[l]="true"}else if(c.startsWith("-")){let l=c.slice(1),i=s[a+1];i&&!i.startsWith("-")?(t[l]=i,a++):t[l]="true"}else r||(r=c)}let o={directory:r,options:t};if((t.y==="true"||t.yes==="true")&&(o.options.ts="true",o.options.useStatic="true",o.options.staticFolder="public",o.options.pm=x?.includes(o.options?.p||o?.options?.pm)?o.options?.p||o?.options?.pm:"npm",o.options.p=x?.includes(o.options?.p||o?.options?.pm)?o.options?.p||o?.options?.pm:"npm",o.options.env=w?.includes(o.options?.env||o?.options?.runtime)?o.options?.env||o?.options?.runtime:"node",o.options.runtime=w?.includes(o.options?.env||o?.options?.runtime)?o.options?.env||o?.options?.runtime:"node",o.options.install="true"),t.help||t.h){X();return}if(t.v||t.version){H();return}W(o)})();
1028
+ Rakibul Islam ${e("<https://github.com/srakib17>","blue")}`),process.exit(0)}function N(){console.log(`TezX CLI v${g}`),process.exit(0)}(async()=>{let n=(l,i)=>{i.name==="c"&&i.ctrl&&(process.stdin.off("keypress",n),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.exit(0))};process.stdin.on("keypress",n);let s=process.argv.slice(2),t={},a;for(let l=0;l<s.length;l++){let i=s[l];if(i.startsWith("--")){let c=i.slice(2),r=s[l+1];r&&!r.startsWith("-")?(t[c]=r,l++):t[c]="true"}else if(i.startsWith("-")){let c=i.slice(1),r=s[l+1];r&&!r.startsWith("-")?(t[c]=r,l++):t[c]="true"}else a||(a=i)}let o={directory:a,options:t};if((t.y==="true"||t.yes==="true")&&(o.options.ts="true",o.options.useStatic="true",o.options.staticFolder="public",o.options.pm=w?.includes(o.options?.p||o?.options?.pm)?o.options?.p||o?.options?.pm:"npm",o.options.p=w?.includes(o.options?.p||o?.options?.pm)?o.options?.p||o?.options?.pm:"npm",o.options.install="true"),t.help||t.h){F();return}if(t.v||t.version){N();return}_(o)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-tezx-app",
3
- "version": "2.0.10",
3
+ "version": "4.0.1",
4
4
  "type": "module",
5
5
  "description": "TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, and Bun.",
6
6
  "bin": "./bin",