Skip to content

Commit

Permalink
fix(currentenv): trim the currentEnv string before returning
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrazx committed May 4, 2020
1 parent a162fe5 commit c06ab93
Show file tree
Hide file tree
Showing 5 changed files with 536 additions and 417 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 Jason Franz <jfrazx> staringblind at gmail.com
Copyright (c) 2020 Jason Franz <jfrazx> staringblind at gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,21 @@ const env = new Env({ keyToJsProp: true });
interface JwtOptions {
secret: string;
signOptions: {
iss: string;
issuer: string;
algorithm: string;
};
}

function toJwtOptions({ secret, iss, algorithm }: EnvManyResult): JwtOptions {
function toJwtOptions({
secret,
issuer,
algorithm,
}: EnvManyResult): JwtOptions {
return {
secret,
signOptions: {
algorithm,
iss,
issuer,
},
};
}
Expand All @@ -154,12 +158,12 @@ const jwtOptions: JwtOptions = env.provideMany(
{ key: 'JWT_SECRET', keyTo: [() => 'secret'], defaultValue: 'token' },
{
key: 'JWT_ALGORITHM',
keyTo: key => 'algorithm',
keyTo: (key) => 'algorithm',
defaultValue: 'RSA',
},
{
key: 'JWT_ISSUER',
keyTo: 'iss',
keyTo: 'issuer',
defaultValue: 'something',
},
],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"homepage": "https://github.com/jfrazx/envirator#readme",
"dependencies": {
"@jfrazx/asarray": "^1.0.0",
"chalk": "^3.0.0",
"chalk": "^4.0.0",
"dotenv": "^8.1.0"
},
"devDependencies": {
Expand All @@ -50,7 +50,7 @@
"@types/dotenv": "^8.2.0",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.1",
"@types/sinon": "^7.0.13",
"@types/sinon": "^9.0.0",
"@types/winston": "^2.4.4",
"chai": "^4.2.0",
"codecov": "^3.5.0",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class Envirator implements EnvInitOptions {

return isUndefined(env) && this.noDefaultEnv
? (this.exitOrWarn(this.nodeEnv, env, false, this.logger) as any)
: (env || Default.Development).toLowerCase();
: (env || Default.Development).toLowerCase().trim();
}

set currentEnv(env: string) {
Expand Down
Loading

0 comments on commit c06ab93

Please sign in to comment.