bro-framework 2.0.0 → 2.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.
package/README.md CHANGED
@@ -25,6 +25,7 @@
25
25
 
26
26
  ## Table of Contents
27
27
 
28
+ - [Getting Started](#getting-started)
28
29
  - [The Core Experience](#the-core-experience)
29
30
  - [Deep-Dive Features](#deep-dive-features)
30
31
  - [Architecture & Request Lifecycle](#architecture--request-lifecycle)
@@ -34,6 +35,20 @@
34
35
 
35
36
  ---
36
37
 
38
+ ## Getting Started
39
+
40
+ Bootstrapping a new `bro.js` project is incredibly simple. We recommend using our official scaffolding tool to set everything up instantly (with your choice of JavaScript or TypeScript):
41
+
42
+ ```bash
43
+ npx create-bro-framework@latest my-api
44
+ cd my-api
45
+ npm run dev
46
+ ```
47
+
48
+ That's it! Your zero-boilerplate backend is now running with hot-reloading enabled.
49
+
50
+ ---
51
+
37
52
  ## The Core Experience
38
53
 
39
54
  In `bro.js`, everything you need is handed to you instantly. No setup, no middleware wrangling, no manual `req/res` handling. You define your route, set your validation, and return an object.
package/bin/bro.js CHANGED
@@ -48,6 +48,13 @@ export default defineConfig({
48
48
  max: 100 // limit each IP to 100 requests per windowMs
49
49
  },
50
50
 
51
+ // WebSockets Setup
52
+ sockets: async (io, db) => {
53
+ io.on('connection', (socket) => {
54
+ console.log('Client connected:', socket.id);
55
+ });
56
+ },
57
+
51
58
  // Database Context Injection
52
59
  // This instance will be injected into every route's ctx.db (if defined)
53
60
  db: async () => {
@@ -67,13 +74,6 @@ export default defineConfig({
67
74
  // return mongoose.connection;
68
75
  // --------------------------
69
76
  return null;
70
- },
71
-
72
- // WebSockets Setup
73
- sockets: async (io, db) => {
74
- io.on('connection', (socket) => {
75
- console.log('Client connected:', socket.id);
76
- });
77
77
  }
78
78
  });
79
79
  `;
@@ -122,10 +122,10 @@ if (command === 'init') {
122
122
 
123
123
  if (['sdk', 'generate-client', 'client'].includes(command)) {
124
124
  generateSDK().then(() => {
125
- console.log(`\n ${colors.green} bro-client.js generated successfully!${colors.reset}\n`);
125
+ console.log(`\n ${colors.green} bro-client.js generated successfully!${colors.reset}\n`);
126
126
  process.exit(0);
127
127
  }).catch(err => {
128
- console.error(`\n ${colors.red} Error generating SDK:${colors.reset}`, err.message);
128
+ console.error(`\n ${colors.red} Error generating SDK:${colors.reset}`, err.message);
129
129
  process.exit(1);
130
130
  });
131
131
  }
@@ -175,7 +175,7 @@ async function bootstrap() {
175
175
  if (globalConfig.env) {
176
176
  const envResult = globalConfig.env.safeParse(process.env);
177
177
  if (!envResult.success) {
178
- console.error(`\n ${colors.red} Environment Validation Failed${colors.reset}`);
178
+ console.error(`\n ${colors.red} Environment Validation Failed${colors.reset}`);
179
179
  envResult.error.errors.forEach(err => {
180
180
  console.error(` ${colors.dim}-${colors.reset} ${colors.bold}${err.path.join('.')}${colors.reset}: ${err.message}`);
181
181
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bro-framework",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "The No-BS Backend Framework for Node.js",
5
5
  "repository": {
6
6
  "type": "git",
package/src/logger.js CHANGED
@@ -25,17 +25,29 @@ export function formatMethod(method) {
25
25
 
26
26
  export function printBanner(port, durationMs) {
27
27
  const time = durationMs.toFixed(0);
28
- const version = "1.0.0";
29
-
28
+ const version = "2.0.1";
29
+ const innerWidth = 47;
30
+
31
+ const stripAnsi = (str) => str.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
32
+
33
+ const formatLine = (content = "") => {
34
+ const visibleLength = stripAnsi(content).length;
35
+ const padding = Math.max(0, innerWidth - visibleLength);
36
+ return `${colors.green}│${colors.reset}${content}${" ".repeat(padding)}${colors.green}│${colors.reset}`;
37
+ };
38
+
39
+ const borderTop = `${colors.green}╭${"─".repeat(innerWidth)}╮${colors.reset}`;
40
+ const borderBottom = `${colors.green}╰${"─".repeat(innerWidth)}╯${colors.reset}`;
41
+
30
42
  console.log("");
31
- console.log(`${colors.green}╭───────────────────────────────────────────────╮${colors.reset}`);
32
- console.log(`${colors.green}│${colors.reset} ${colors.green}│${colors.reset}`);
33
- console.log(`${colors.green}│${colors.reset} ${colors.bold}bro.js${colors.reset} v${version} ${colors.green}│${colors.reset}`);
34
- console.log(`${colors.green}│${colors.reset} ${colors.green}│${colors.reset}`);
35
- console.log(`${colors.green}│${colors.reset} ➜ ${colors.bold}Local:${colors.reset} ${colors.cyan}http://localhost:${port}${colors.reset} ${colors.green}│${colors.reset}`);
36
- console.log(`${colors.green}│${colors.reset} ➜ ${colors.bold}Ready in:${colors.reset} ${colors.yellow}${time}ms${colors.reset} ${colors.green}│${colors.reset}`);
37
- console.log(`${colors.green}│${colors.reset} ${colors.green}│${colors.reset}`);
38
- console.log(`${colors.green}╰───────────────────────────────────────────────╯${colors.reset}`);
43
+ console.log(borderTop);
44
+ console.log(formatLine());
45
+ console.log(formatLine(` ${colors.bold}bro.js${colors.reset} v${version}`));
46
+ console.log(formatLine());
47
+ console.log(formatLine(` ➜ ${colors.bold}Local:${colors.reset} ${colors.cyan}http://localhost:${port}${colors.reset}`));
48
+ console.log(formatLine(` ➜ ${colors.bold}Ready in:${colors.reset} ${colors.yellow}${time}ms${colors.reset}`));
49
+ console.log(formatLine());
50
+ console.log(borderBottom);
39
51
  console.log("");
40
52
  }
41
53