Trying to set up an environment that:
server.js
:
When the server is created, it will check if the a series of files exist: [api.log, error.log, access.log], if they do not yet exist, it will create them.
routes/api.js
:
I can use the file created at start up to, on api errors, log the error.
A lot of the advice revolves around fs.exists() which is now deprecated.
I am struggling to piece together the order of events, shall server.js
check for files, act accordingly, then open a stream? Or must routes/api.js
open the stream and write to it on every error?
I am using Node v5.0.0