logixlysia 3.4.0 → 3.5.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.5.0](https://github.com/PunGrumpy/logixlysia/compare/v3.4.0...v3.5.0) (2024-07-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * **config:** add option to toggle server start banner display ([c975cd6](https://github.com/PunGrumpy/logixlysia/commit/c975cd6da94e39d055cdf7bc43cc1ed1eec4971e)), closes [#52](https://github.com/PunGrumpy/logixlysia/issues/52)
9
+
3
10
  ## [3.4.0](https://github.com/PunGrumpy/logixlysia/compare/v3.3.2...v3.4.0) (2024-06-17)
4
11
 
5
12
 
package/README.md CHANGED
@@ -21,7 +21,9 @@ const app = new Elysia({
21
21
  }).use(
22
22
  logixlysia({
23
23
  config: {
24
+ showBanner: true,
24
25
  ip: true,
26
+ logFilePath: './logs/example.log',
25
27
  customLogFormat:
26
28
  '🦊 {now} {level} {duration} {method} {pathname} {status} {message} {ip}',
27
29
  logFilter: {
@@ -42,9 +44,11 @@ app.listen(3000)
42
44
 
43
45
  | Option | Type | Description | Default |
44
46
  | ------------------ | --------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------- |
47
+ | `showBanner` | `boolean` | Display the banner on the console | `true` |
45
48
  | `ip` | `boolean` | Display the incoming IP address based on the `X-Forwarded-For` header | `false` |
46
49
  | `customLogMessage` | `string` | Custom log message to display | `🦊 {now} {level} {duration} {method} {pathname} {status} {message} {ip}` |
47
50
  | `logFilter` | `object` | Filter the logs based on the level, method, and status | `null` |
51
+ | `logFilePath` | `string` | Path to the log file | `./logs/elysia.log` |
48
52
 
49
53
  ## `📄` License
50
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "logixlysia",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "🦊 Logixlysia is a logger for Elysia",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
@@ -23,7 +23,7 @@
23
23
  "dev": "bun run --watch example/basic.ts",
24
24
  "prepare": "husky",
25
25
  "lint:staged": "lint-staged",
26
- "prettier": "prettier --write --config .trunk/configs/.prettierrc.yaml .",
26
+ "format": "prettier --write --config .trunk/configs/.prettierrc.yaml .",
27
27
  "trunk:check": "trunk check",
28
28
  "trunk:fmt": "trunk fmt"
29
29
  },
@@ -71,23 +71,23 @@
71
71
  ],
72
72
  "dependencies": {
73
73
  "chalk": "^5.3.0",
74
- "elysia": "^1.0.21"
74
+ "elysia": "^1.0.24"
75
75
  },
76
76
  "devDependencies": {
77
- "@elysiajs/eden": "^1.0.13",
78
- "@eslint/js": "^9.3.0",
77
+ "@elysiajs/eden": "^1.0.14",
78
+ "@eslint/js": "^9.5.0",
79
79
  "@trunkio/launcher": "^1.3.1",
80
- "@typescript-eslint/eslint-plugin": "^7.10.0",
81
- "@typescript-eslint/parser": "^7.10.0",
82
- "bun-types": "^1.1.9",
80
+ "@typescript-eslint/eslint-plugin": "^7.13.1",
81
+ "@typescript-eslint/parser": "^7.13.1",
82
+ "bun-types": "^1.1.13",
83
83
  "commitizen": "^4.3.0",
84
84
  "cz-conventional-changelog": "^3.3.0",
85
85
  "eslint": "9.x",
86
86
  "eslint-plugin-simple-import-sort": "^12.1.0",
87
87
  "husky": "^9.0.11",
88
- "lint-staged": "^15.2.4",
89
- "prettier": "^3.2.5",
90
- "typescript-eslint": "^7.10.0"
88
+ "lint-staged": "^15.2.7",
89
+ "prettier": "^3.3.2",
90
+ "typescript-eslint": "^7.13.1"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "typescript": "^5.0.0"
package/src/index.ts CHANGED
@@ -25,7 +25,7 @@ export default function logixlysia(options?: Options): Elysia {
25
25
  return new Elysia({
26
26
  name: 'Logixlysia'
27
27
  })
28
- .onStart(ctx => startServer(ctx.server as Server))
28
+ .onStart(ctx => startServer(ctx.server as Server, options))
29
29
  .onRequest(ctx => {
30
30
  ctx.store = { beforeTime: process.hrtime.bigint() }
31
31
  })
package/src/types.ts CHANGED
@@ -54,6 +54,7 @@ interface Options {
54
54
  method?: string | string[]
55
55
  status?: number | number[]
56
56
  } | null
57
+ showBanner?: boolean
57
58
  }
58
59
  }
59
60
 
@@ -1,4 +1,4 @@
1
- import { Server } from '~/types'
1
+ import { Options, Server } from '~/types'
2
2
 
3
3
  /**
4
4
  * Creates a box text.
@@ -19,15 +19,18 @@ function createBoxText(text: string, width: number): string {
19
19
  * @param {Server} config The server configuration.
20
20
  * @returns {void} The server string.
21
21
  */
22
- function startServer(config: Server): void {
22
+ function startServer(config: Server, options?: Options): void {
23
23
  const { hostname, port, protocol } = config
24
- const ELYSIA_VERSION = import.meta.require('elysia/package.json').version
25
- const title = `Elysia v${ELYSIA_VERSION}`
26
- const message = `🦊 Elysia is running at ${protocol}://${hostname}:${port}`
27
- const boxWidth = Math.max(title.length, message.length) + 4
28
- const border = '─'.repeat(boxWidth)
24
+ const showBanner = options?.config?.showBanner ?? true
29
25
 
30
- console.log(`
26
+ if (showBanner) {
27
+ const ELYSIA_VERSION = import.meta.require('elysia/package.json').version
28
+ const title = `Elysia v${ELYSIA_VERSION}`
29
+ const message = `🦊 Elysia is running at ${protocol}://${hostname}:${port}`
30
+ const boxWidth = Math.max(title.length, message.length) + 4
31
+ const border = '─'.repeat(boxWidth)
32
+
33
+ console.log(`
31
34
  ┌${border}┐
32
35
  │${createBoxText('', boxWidth)}│
33
36
  │${createBoxText(title, boxWidth)}│
@@ -36,6 +39,9 @@ function startServer(config: Server): void {
36
39
  │${createBoxText('', boxWidth)}│
37
40
  └${border}┘
38
41
  `)
42
+ } else {
43
+ console.log(`🦊 Elysia is running at ${protocol}://${hostname}:${port}`)
44
+ }
39
45
  }
40
46
 
41
47
  export default startServer