Skip to content

Commit

Permalink
migrate index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharqiewicz committed Jan 6, 2025
1 parent 7b213eb commit 6d57274
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 43 deletions.
43 changes: 0 additions & 43 deletions signer-service/src/index.js

This file was deleted.

44 changes: 44 additions & 0 deletions signer-service/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import dotenv from 'dotenv';

import { config } from './config/vars';
import logger from './config/logger';
import app from './config/express';
import {
FUNDING_SECRET,
PENDULUM_FUNDING_SEED,
MOONBEAM_EXECUTOR_PRIVATE_KEY,
CLIENT_DOMAIN_SECRET,
} from './constants/constants';

const { port, env } = config;

dotenv.config();

// Consider grouping all environment checks into a single function
const validateRequiredEnvVars = () => {
const requiredVars = {
FUNDING_SECRET,
PENDULUM_FUNDING_SEED,
MOONBEAM_EXECUTOR_PRIVATE_KEY,
CLIENT_DOMAIN_SECRET,
};

for (const [key, value] of Object.entries(requiredVars)) {
if (!value) {
logger.error(`${key} not set in the environment variables`);
process.exit(1);
}
}
};

// Validate environment variables before starting the server
validateRequiredEnvVars();

// listen to requests
app.listen(port, () => logger.info(`server started on port ${port} (${env})`));

/**
* Exports express
* @public
*/
export default app;

0 comments on commit 6d57274

Please sign in to comment.