Skip to content

Conversation

@hejkerooo
Copy link
Collaborator

@hejkerooo hejkerooo commented Dec 4, 2025

Total scope:

  • Reduce amount of RPC calls,
  • Update project structure,
  • Enforce BASE_URLS in most places of the projects with fallback with cache manager,
  • Add more detailed errors, add more logs,
  • Add new endpoint GET /token to return access token from pallet auth server,
  • Enforce strict npm engine,
  • Endpoint /config returns base urls details and app version/git sha

Docker tag: feat-auth-0.1

@hejkerooo hejkerooo requested a review from KaamilW as a code owner December 4, 2025 09:21
@hejkerooo hejkerooo marked this pull request as draft December 4, 2025 09:21
@hejkerooo hejkerooo requested a review from soanvig December 4, 2025 10:12
@hejkerooo hejkerooo marked this pull request as ready for review December 4, 2025 10:14
translateTime: 'SYS:HH:MM:ss',
},
const loggerOptions = typeof options === 'string' ? { name: options } : options;
const defaultLevel = loggerOptions.level ?? 'info';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's good opportunity to introduce log level

src/config.ts Outdated
LOG_FILE_PATH: z
.string()
.optional()
.describe('Full path to log file (e.g., /var/log/app.log or ./logs/app.log)'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add information if no value is provided then file logging is disabled

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

{ level: defaultLevel, stream: prettyTransport },
];

return pino({ ...loggerOptions, level: defaultLevel }, pino.multistream(streams));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this log going to include PID in each log? I would say it's necessary so we can distinguish it for each deployment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default already had pid

// Cache for transport instances to prevent duplicate worker processes
const transportCache = new Map<string, ReturnType<typeof pino.transport>>();

export const createLogger = (options: string | LoggerOptions): Logger => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function became too big, can you split it into smaller ones so it's more readable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also what I'm thinking you should add logs to some buffer while you createLogger and later print logger configuration (paths etc.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

// If path ends with / or \, append default filename
if (logFilePath.endsWith('/') || logFilePath.endsWith('\\')) {
logFilePath = path.join(logFilePath, 'app.log');
} else if (path.extname(logFilePath) === '') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use .length === 0 or ideally .trim().length === 0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


// Parse path for pino-roll configuration
const parsedPath = path.parse(logFilePath);
const baseFileName = parsedPath.name; // filename without extension
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to reassign here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

// Parse path for pino-roll configuration
const parsedPath = path.parse(logFilePath);
const baseFileName = parsedPath.name; // filename without extension
const extension = parsedPath.ext !== '' ? parsedPath.ext : '.log';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above comment about length

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

});

// Perform graceful shutdown after response is sent
setTimeout(() => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to just send SIGTERM and add event listener on it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


// Send response immediately before shutdown
res.status(200).json({
success: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

200 indicates that request was successful

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but IMO it's incorrect - we don't know if shutdown was successful

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WNA had query check server are up/down.

}, 100); // Small delay to ensure response is sent
} catch (error) {
adminLogger.error({ error }, 'error initiating shutdown');
res.status(500).json({
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will lead to error where response is sent twice

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had checking in shutdown.ts.

if (isShuttingDown) { logger.warn('shutdown already in progress'); return; }

src/shutdown.ts Outdated
// 5. Clear timeout and complete
clearTimeout(shutdownTimeout);
logger.info('graceful shutdown completed');
process.exit(0);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to drain also fastq queues

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Collaborator Author

@hejkerooo hejkerooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

health module should not be responsible for any of this

const solutionInfos: SolutionInfo[] = solutions.map((solution) => {
// Extract name from solutionId (format: "name.uuid")
// Example: "newTestGPSaaS.1348d595-ccc4-4a38-85ad-f0e31cc7f410" -> "newTestGPSaaS"
const name = solution.solutionId.includes('.')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this functionality? what is the purpose? It's not deterministic

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that get solution name only for UI display

};
};

const getOperatorInfo = async (timeoutMs: number = 5000): Promise<OperatorInfo | undefined> => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to some different place and export it as public function.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any place that suitable. try not create new file for this

@azam-ismail azam-ismail force-pushed the feat/auth branch 3 times, most recently from 4d7c708 to f6df7bc Compare January 15, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants