Skip to content

Commit f73814b

Browse files
author
hirsch88
committed
Add test env
1 parent bc63608 commit f73814b

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

.env.test

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# APPLICATION
3+
#
4+
APP_NAME="express-typescript-boilerplate"
5+
APP_ROUTE="http://localhost:3000"
6+
APP_ROUTE_PREFIX="/api"
7+
APP_BANNER=false
8+
9+
#
10+
# LOGGING
11+
#
12+
LOG_LEVEL="none"
13+
LOG_JSON=false
14+
LOG_OUTPUT="dev"
15+
16+
#
17+
# AUTHORIZATION
18+
#
19+
AUTH_ROUTE="http://localhost:3333/tokeninfo"
20+
21+
#
22+
# DATABASE
23+
#
24+
DB_TYPE="mysql"
25+
DB_HOST="localhost"
26+
DB_PORT=3306
27+
DB_USERNAME="root"
28+
DB_PASSWORD=""
29+
DB_DATABASE="my_database"
30+
DB_SYNCHRONIZE=false
31+
DB_LOGGING=false
32+
33+
#
34+
# Swagger
35+
#
36+
SWAGGER_ENABLED=true
37+
SWAGGER_ROUTE="/swagger"
38+
SWAGGER_FILE="api/swagger.json"
39+
SWAGGER_USERNAME="admin"
40+
SWAGGER_PASSWORD="1234"
41+
42+
#
43+
# Status Monitor
44+
#
45+
MONITOR_ENABLED=true
46+
MONITOR_ROUTE="/monitor"
47+
MONITOR_USERNAME="admin"
48+
MONITOR_PASSWORD="1234"

src/core/env.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import * as path from 'path';
2-
import * as pkg from '../../package.json';
32
import * as dotenv from 'dotenv';
4-
dotenv.config();
3+
import * as pkg from '../../package.json';
54

5+
/**
6+
* Load .env file or for tests the .env.test file.
7+
*/
8+
dotenv.config({ path: path.join(process.cwd(), `.env${((process.env.NODE_ENV === 'test') ? '.test' : '')}`) });
69

710
/**
811
* Environment variables
@@ -22,7 +25,7 @@ export const env = {
2225
migrations: [path.join(__dirname, '..', 'database/migrations/*.ts')],
2326
migrationsDir: path.join(__dirname, '..', 'database/migrations'),
2427
entities: [path.join(__dirname, '..', 'api/**/models/*{.js,.ts}')],
25-
subscribers: [ path.join(__dirname, '..', 'api/**/*Subscriber{.js,.ts}')],
28+
subscribers: [path.join(__dirname, '..', 'api/**/*Subscriber{.js,.ts}')],
2629
controllers: [path.join(__dirname, '..', 'api/**/*Controller{.js,.ts}')],
2730
middlewares: [path.join(__dirname, '..', 'api/**/*Middleware{.js,.ts}')],
2831
interceptors: [path.join(__dirname, '..', 'api/**/*Interceptor{.js,.ts}')],

0 commit comments

Comments
 (0)