Provide Sentry token to Sentry API through env variable
This commit is contained in:
@@ -22,7 +22,12 @@ export async function createRouter(
|
||||
rootLogger: Logger,
|
||||
): Promise<express.Router> {
|
||||
const router = Router();
|
||||
const sentryForwarder = new SentryApiForwarder('');
|
||||
const SENTRY_TOKEN = process.env.SENTRY_TOKEN;
|
||||
if (!SENTRY_TOKEN) {
|
||||
console.error('Sentry token must be provided in env to start the API.');
|
||||
process.exit(1);
|
||||
}
|
||||
const sentryForwarder = new SentryApiForwarder(SENTRY_TOKEN);
|
||||
const logger = rootLogger.child({ plugin: 'sentry' });
|
||||
|
||||
router.get('*', (req, res) => sentryForwarder.fowardRequest(req, res));
|
||||
|
||||
@@ -18,8 +18,6 @@ import { Server } from 'http';
|
||||
import { Logger } from 'winston';
|
||||
import { createStandaloneApplication } from './standaloneApplication';
|
||||
|
||||
const PORT = 5009;
|
||||
|
||||
export async function startStandaloneServer(
|
||||
parentLogger: Logger,
|
||||
): Promise<Server> {
|
||||
@@ -29,6 +27,7 @@ export async function startStandaloneServer(
|
||||
const app = await createStandaloneApplication(logger);
|
||||
|
||||
logger.debug('Starting application server...');
|
||||
const PORT = parseInt(process.env.PORT || '5001', 10);
|
||||
return await new Promise((resolve, reject) => {
|
||||
const server = app.listen(PORT, (err?: Error) => {
|
||||
if (err) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import { MockSentryApi } from './mock-api';
|
||||
import { ProductionSentryApi } from './production-api';
|
||||
|
||||
export function sentryApiFactory(organization: string): SentryApi {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
return new ProductionSentryApi(organization);
|
||||
}
|
||||
return new MockSentryApi();
|
||||
|
||||
Reference in New Issue
Block a user