Skip to content

Commit

Permalink
force
Browse files Browse the repository at this point in the history
  • Loading branch information
MM25Zamanian committed Oct 19, 2024
1 parent 6c98846 commit 04377c6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/common/database/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class Database {
lastName: 'زمانیان',
phoneNumber: '09155595488',
email: '[email protected]',

}),
]);

Expand Down
2 changes: 1 addition & 1 deletion packages/common/schemas/src/group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uid } from '@gecut/utilities/uid';
import { uid } from '@gecut/utilities/uid.js';
import { Schema, Types } from 'mongoose';

import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/schemas/src/session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uid } from '@gecut/utilities/uid';
import { uid } from '@gecut/utilities/uid.js';
import { Schema, Types } from 'mongoose';

import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/services/users/package.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down
11 changes: 7 additions & 4 deletions packages/services/users/src/core.ts
Original file line number Diff line number Diff line change
@@ -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',
},
Expand All @@ -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 }));

Expand Down
32 changes: 22 additions & 10 deletions packages/services/users/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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,
},
);
});

0 comments on commit 04377c6

Please sign in to comment.