From 88205b15111be6d22469f642aca7df21e5b9e311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Wed, 5 Oct 2022 20:05:56 +0200 Subject: [PATCH] Add CLIENT_ID and CLIENT_SECRET env var --- Procfile | 2 +- api/tsconfig.json | 5 +---- standup-mattermost-bot/.env.template | 2 ++ standup-mattermost-bot/source/config.ts | 12 ++++++++++-- standup-mattermost-bot/source/mongodb.ts | 4 ---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Procfile b/Procfile index fbbae9266..17180c664 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: node -v ; yarn -v ; echo "APP_DIR: $APP_DIR" ; echo "PORT: $PORT" ; yarn workspace "$APP_DIR" run start:prod +web: node -v ; yarn -v ; echo "APP_DIR => $APP_DIR" ; echo "PORT => $PORT" ; yarn workspace "$APP_DIR" run start:prod diff --git a/api/tsconfig.json b/api/tsconfig.json index 4026611b5..2c873b5d5 100644 --- a/api/tsconfig.json +++ b/api/tsconfig.json @@ -30,10 +30,7 @@ "resolveJsonModule": true, /* Advanced Options */ - "forceConsistentCasingInFileNames": true, - - // temporary disable lib check waiting a fix for https://github.com/sindresorhus/got/issues/2051 - "skipLibCheck": true + "forceConsistentCasingInFileNames": true }, "ts-node": { "esm": true diff --git a/standup-mattermost-bot/.env.template b/standup-mattermost-bot/.env.template index 6057db199..43f0da7a1 100644 --- a/standup-mattermost-bot/.env.template +++ b/standup-mattermost-bot/.env.template @@ -1,2 +1,4 @@ +CLIENT_ID= +CLIENT_SECRET= MONGO_URL=mongodb://root:example@localhost:27017/ ORIGIN=http://localhost:4000 diff --git a/standup-mattermost-bot/source/config.ts b/standup-mattermost-bot/source/config.ts index 8763e1c81..d601f4b4e 100644 --- a/standup-mattermost-bot/source/config.ts +++ b/standup-mattermost-bot/source/config.ts @@ -1,13 +1,21 @@ import type { MattermostSendMessage } from './mattermost.js' +if (!process.env.MONGO_URL) { + throw new Error('MONGO_URL env var is empty') +} + +if (!process.env.CLIENT_ID || !process.env.CLIENT_SECRET) { + throw new Error('Empty env var CLIENT_ID or CLIENT_SECRET') +} + export const PORT = process.env.PORT || 4000 export const ORIGIN = process.env.ORIGIN || 'http://localhost:4000' export const MONGO_URL = process.env.MONGO_URL export const NODE_ENV = process.env.NODE_ENV export const serverUrl = 'https://mattermost.incubateur.net' -export const clientSecret = 'pgnch7w643yfdkdjnnjcxhpsoe' -export const clientId = 'wbkot91tjbd6byn4fbmrtu8h6o' +export const clientId = process.env.CLIENT_ID +export const clientSecret = process.env.CLIENT_SECRET export const redirectUri = `${ORIGIN}/oauth` const days = [ diff --git a/standup-mattermost-bot/source/mongodb.ts b/standup-mattermost-bot/source/mongodb.ts index 8e33559d2..b0a5cc644 100644 --- a/standup-mattermost-bot/source/mongodb.ts +++ b/standup-mattermost-bot/source/mongodb.ts @@ -10,10 +10,6 @@ interface MemberIds { } export const initMongodb = async () => { - if (!MONGO_URL) { - throw new Error('MONGO_URL env var is empty') - } - const client = new MongoClient(MONGO_URL) await client.connect()