Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
node-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
project-templates
web
node-api
Commits
3f43d4c6
Commit
3f43d4c6
authored
Apr 17, 2019
by
Vadym Gidulian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `checkEnvironmentVariables` function
parent
c2b8c4e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
db.js
src/utils/db.js
+6
-10
util.js
src/utils/util.js
+12
-0
No files found.
src/utils/db.js
View file @
3f43d4c6
'use strict'
;
'use strict'
;
const
grace
=
require
(
'./grace'
);
const
{
checkEnvironmentVariables
}
=
require
(
'./util'
);
const
{
createError
,
logError
,
logInfo
,
logWarn
}
=
require
(
'./log'
);
[
'MONGODB_URI'
,
'SEQID_GEN_API'
].
forEach
(
varname
=>
{
checkEnvironmentVariables
(
'MONGODB_URI'
,
'SEQID_GEN_API'
);
if
(
!
process
.
env
[
varname
])
{
logError
(
`Environment variable
${
varname
}
is not defined!`
);
grace
.
shutdown
(
1
);
}
});
const
{
MongoClient
}
=
require
(
'mongodb'
);
const
{
MongoClient
}
=
require
(
'mongodb'
);
const
SeqidGenApi
=
require
(
'@gviagroup/seqid-gen-api'
);
const
SeqidGenApi
=
require
(
'@gviagroup/seqid-gen-api'
);
const
grace
=
require
(
'./grace'
);
const
{
createError
,
logError
,
logInfo
,
logWarn
}
=
require
(
'./log'
);
let
mongoClient
=
null
;
let
mongoClient
=
null
;
const
seqidGen
=
new
SeqidGenApi
(
process
.
env
.
SEQID_GEN_API
);
const
seqidGen
=
new
SeqidGenApi
(
process
.
env
.
SEQID_GEN_API
);
...
...
src/utils/util.js
View file @
3f43d4c6
'use strict'
;
'use strict'
;
const
{
shutdown
}
=
require
(
'./grace'
);
const
{
logError
}
=
require
(
'./log'
);
module
.
exports
=
{
module
.
exports
=
{
checkEnvironmentVariables
(...
varNames
)
{
for
(
const
varName
of
varNames
)
{
if
(
!
process
.
env
[
varName
])
{
logError
(
`Environment variable
${
varName
}
is not set!`
);
shutdown
(
1
);
}
}
}
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment