An example application that lists tasks from the database.
📝 | Please install any missing packages you encounter |
---|
The application will run under its own user account. For this purpose, create
the user with the login name todoapp
.
Your organization has decided that all applications serving web pages must be
placed under /srv/www/
. Create the directory structure and assign sensible
permissions. Keep in mind that multiple users/applications might use this
directory in the future.
Create the directory for the application itself /srv/www/todo-app
and assign
appropriate permissions.
Download the source code and place it directly under /srv/www/todo-app
/srv/www/todo-app/
├── app.js
├── bin
├── db.js
├── LICENSE.TXT
├── node_modules
├── package.json
├── package-lock.json
├── public
├── README.md
├── routes
└── views
You can use git for downloading:
git clone https://github.com/bbusuioc/todo-app
Or you can also use wget (search link for downloading as an archive on Github).
npm install --production
The application is configured using environment variables.
Set the following variables for the database connection:
export DATABASE_HOST=
export DATABASE_NAME=
export DATABASE_USER=
export DATABASE_PASSWORD=
Also set the environment variable NODE_ENV
to production
in order to disable
debugging output when errors occur.
If PORT
is unset, the default port 8000 will be used. This is OK for our
example.
node bin/www