I am writing a Node.JS REST API using Express, and I was a little confused about the require()
and exports
statements in Node.JS.
For instance, let's say I am writing a simple app wherein app.js
contains the basic app.get
statements, routes.js
contains the functions passed as a callback to those app.get
statements and events.js
contains the Mongoose Schemas and Models.
Now, if routes.js
requires events.js
, can I call Model.find() and functions like those in routes.js
and if yes, what exports will I have to make from events.js
?