From 507618c730affe34c48b70c9ccaded402e138006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Wed, 23 Nov 2022 18:30:48 +0100 Subject: [PATCH] Fix env config in server --- server/source/config.ts | 4 ++++ server/source/server.ts | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/source/config.ts b/server/source/config.ts index bef5cf569..808cc208b 100644 --- a/server/source/config.ts +++ b/server/source/config.ts @@ -1,5 +1,9 @@ +import dotenv from 'dotenv' + import type { MattermostSendMessage } from './mattermost.js' +dotenv.config() + if (!process.env.MONGO_URL) { throw new Error('Empty MONGO_URL env var') } diff --git a/server/source/server.ts b/server/source/server.ts index 78321324f..7ae592c06 100644 --- a/server/source/server.ts +++ b/server/source/server.ts @@ -1,8 +1,7 @@ import cors from '@koa/cors' import Router from '@koa/router' -import dotenv from 'dotenv' import Koa from 'koa' -import koaBody from 'koa-body' +import { koaBody } from 'koa-body' import { PORT, @@ -17,8 +16,6 @@ import { initMongodb } from './mongodb.js' import { getAccessToken } from './oauth.js' import { snakeToCamelCaseKeys, validateCrispBody } from './utils.js' -dotenv.config() - const mongo = await initMongodb() type KoaState = Koa.DefaultState