I'm new to NodeJS, sorry for a simple question. I have a not-so big program, but want to make my main web.js file a bit more clear and create a few separate files (e.g. user_login.js, admin.js, etc) and simply paste these files' contents into web.js.
On the Internets everyone is advising to use require(), but that means writing a module - a self-consistent piece of code. But I need to simply include text of one file into another. Say, I would have
admin.js:
app.get('/admin', function (request, response)
{
response.send("hey, you are an admin!");
});
user.js:
app.get('/', function (request, response)
{
response.send("hi, how are you?");
}
web.js:
var express = require('express');
var app = express();
include('admin.js');
include('user.js');