From 04377c65fef09880d273bf12b0a0f30a0374ea3a Mon Sep 17 00:00:00 2001 From: "S. MohammadMahdi Zamanian" Date: Sat, 19 Oct 2024 12:44:31 +0330 Subject: [PATCH] force --- packages/common/database/src/index.ts | 1 + packages/common/schemas/src/group.ts | 2 +- packages/common/schemas/src/session.ts | 2 +- packages/services/users/package.json | 2 +- packages/services/users/src/core.ts | 11 +++++---- packages/services/users/src/index.ts | 32 ++++++++++++++++++-------- 6 files changed, 33 insertions(+), 17 deletions(-) diff --git a/packages/common/database/src/index.ts b/packages/common/database/src/index.ts index f17c2bb..18c86dd 100644 --- a/packages/common/database/src/index.ts +++ b/packages/common/database/src/index.ts @@ -74,6 +74,7 @@ export class Database { lastName: 'زمانیان', phoneNumber: '09155595488', email: 'dev@mm25zamanian.ir', + }), ]); diff --git a/packages/common/schemas/src/group.ts b/packages/common/schemas/src/group.ts index 3164270..b7c72d1 100644 --- a/packages/common/schemas/src/group.ts +++ b/packages/common/schemas/src/group.ts @@ -1,4 +1,4 @@ -import { uid } from '@gecut/utilities/uid'; +import { uid } from '@gecut/utilities/uid.js'; import { Schema, Types } from 'mongoose'; import type { diff --git a/packages/common/schemas/src/session.ts b/packages/common/schemas/src/session.ts index 63de21d..5723874 100644 --- a/packages/common/schemas/src/session.ts +++ b/packages/common/schemas/src/session.ts @@ -1,4 +1,4 @@ -import { uid } from '@gecut/utilities/uid'; +import { uid } from '@gecut/utilities/uid.js'; import { Schema, Types } from 'mongoose'; import type { diff --git a/packages/services/users/package.json b/packages/services/users/package.json index eb569a6..da7b287 100644 --- a/packages/services/users/package.json +++ b/packages/services/users/package.json @@ -1,7 +1,7 @@ { "name": "users", "scripts": { - "dev": "bun run --hot src/index.ts", + "dev": "DEBUG=1 bun run --hot src/index.ts", "build": "bun build ./src/index.ts", "build:all": "bun build ./src/**.ts" }, diff --git a/packages/services/users/src/core.ts b/packages/services/users/src/core.ts index c7e3f20..f0878a6 100644 --- a/packages/services/users/src/core.ts +++ b/packages/services/users/src/core.ts @@ -1,16 +1,19 @@ +import { GecutLogger } from '@gecut/logger'; import { env } from '@gecut/utilities/env.js'; import { Database } from '@promeet/database'; import { Hono } from 'hono'; import { bearerAuth } from 'hono/bearer-auth'; -import { logger } from 'hono/logger'; +import { logger as honoLogger } from 'hono/logger'; import type { UserData } from '@promeet/types'; +export const logger = new GecutLogger('users.service'); export const $exHono = new Hono<{ Variables: { user: UserData } }>(); +export const $inHonoLogger = logger.sub('internal'); export const $inHono = new Hono(); export const db = new Database( 'mongodb://root:m9zpx6DSV8Y1jNJFOlOaJuQHbAK63BTL@3c9eb54a-69d7-43bd-a87d-3478585093bc.hsvc.ir:30242/', - undefined, + logger.sub('db'), { appName: 'users-services', }, @@ -27,8 +30,8 @@ export const config = { }, }; -$exHono.use(logger()); -$inHono.use(logger()); +$exHono.use(honoLogger(logger.property)); +$inHono.use(honoLogger($inHonoLogger.property)); $inHono.use('/secrets/*', bearerAuth({ token: config.secret.token })); diff --git a/packages/services/users/src/index.ts b/packages/services/users/src/index.ts index 2177355..05af898 100644 --- a/packages/services/users/src/index.ts +++ b/packages/services/users/src/index.ts @@ -1,4 +1,4 @@ -import { $exHono, $inHono, config, db } from './core'; +import { $exHono, $inHono, config, db, logger, $inHonoLogger } from './core'; import './routes/auth/user'; import './routes/secrets/get-all-users'; @@ -11,19 +11,31 @@ db.connect() hostname: config.host, }); + logger.methodFull?.( + 'server', + { port: config.port, hostname: config.host }, + { + id: externalServer.id, + hostname: externalServer.hostname, + port: externalServer.port, + url: externalServer.url.href, + }, + ); + const internalServer = Bun.serve({ fetch: $inHono.fetch, port: config.secret.port, hostname: config.secret.host, }); - // eslint-disable-next-line no-console - console.log('externalServer', { - url: externalServer.url.toString(), - }); - - // eslint-disable-next-line no-console - console.log('internalServer', { - url: internalServer.url.toString(), - }); + $inHonoLogger.methodFull?.( + 'server', + { port: config.secret.port, hostname: config.secret.host }, + { + id: internalServer.id, + hostname: internalServer.hostname, + port: internalServer.port, + url: internalServer.url.href, + }, + ); });