diff --git a/.env.template b/.env.template index 3a651f11..3ca904b9 100644 --- a/.env.template +++ b/.env.template @@ -1 +1 @@ -API_TOKEN= \ No newline at end of file +API_TOKEN= diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 7c46ea40..15b7b4de 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -1,6 +1,9 @@ name: Deploy to staging -on: push +on: + push: + branches: + - master jobs: test: diff --git a/src/config.ts b/src/config.ts index 2c3f9800..0f7712ef 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,21 +1,3 @@ -export const PORT = process.env.PORT || 8000 - -export const DB_CONFIG = { - dialect: 'postgres', - pool: { - max: 10, - min: 0, - acquire: 10000, - idle: 300000000, - }, - username: process.env.POSTGRES_USER, - password: process.env.POSTGRES_PASSWORD, - port: 5432, - host: process.env.POSTGRES_HOST, - database: process.env.POSTGRES_DATABASE, - logging: false, -} - export const inStaging = process.env.REACT_APP_STAGING === 'true' export const inProduction = !inStaging && process.env.NODE_ENV === 'production' @@ -23,7 +5,3 @@ export const inProduction = !inStaging && process.env.NODE_ENV === 'production' export const inE2EMode = process.env.REACT_APP_E2E === 'true' export const GIT_SHA = process.env.REACT_APP_GIT_SHA || '' - -export const JAMI_URL = inProduction - ? 'https://importer.cs.helsinki.fi/api/auth' - : 'https://toska-staging.cs.helsinki.fi/jami' diff --git a/src/server/db/connection.ts b/src/server/db/connection.ts index 189276da..bc2bec1f 100644 --- a/src/server/db/connection.ts +++ b/src/server/db/connection.ts @@ -2,7 +2,7 @@ import { Sequelize, Options } from 'sequelize' import { Umzug, SequelizeStorage } from 'umzug' import logger from '../util/logger' -import { DB_CONFIG } from '../../config' +import { DB_CONFIG } from '../util/config' const DB_CONNECTION_RETRY_LIMIT = 10 diff --git a/src/server/index.ts b/src/server/index.ts index 0d884d71..b433b379 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -4,7 +4,7 @@ import path from 'path' import { Handlers as SentryHandlers } from '@sentry/node' import initializeSentry from './util/sentry' -import { PORT } from '../config' +import { PORT } from './util/config' import { connectToDatabase } from './db/connection' import logger from './util/logger' import errorHandler from './middeware/errorHandler' diff --git a/src/server/util/config.ts b/src/server/util/config.ts new file mode 100644 index 00000000..99edd3eb --- /dev/null +++ b/src/server/util/config.ts @@ -0,0 +1,29 @@ +import * as dotenv from 'dotenv' + +import { inProduction } from '../../config' + +dotenv.config() + +export const PORT = process.env.PORT || 8000 + +export const { API_TOKEN } = process.env + +export const DB_CONFIG = { + dialect: 'postgres', + pool: { + max: 10, + min: 0, + acquire: 10000, + idle: 300000000, + }, + username: process.env.POSTGRES_USER, + password: process.env.POSTGRES_PASSWORD, + port: 5432, + host: process.env.POSTGRES_HOST, + database: process.env.POSTGRES_DATABASE, + logging: false, +} + +export const JAMI_URL = inProduction + ? 'https://importer.cs.helsinki.fi/api/auth' + : 'https://toska-staging.cs.helsinki.fi/jami' diff --git a/src/server/util/jami.ts b/src/server/util/jami.ts index 95fe1c38..df5a0127 100644 --- a/src/server/util/jami.ts +++ b/src/server/util/jami.ts @@ -1,14 +1,11 @@ import axios from 'axios' -import { JAMI_URL, inProduction } from '../../config' +import { JAMI_URL, API_TOKEN } from './config' import { OrganisationData } from '../types' -const API_TOKEN = process.env - export const jamiClient = axios.create({ baseURL: JAMI_URL, params: { token: API_TOKEN, - noLogging: !inProduction, }, })