A sample Node.js notes application built with Express, EJS, and MySQL, ready to deploy to Hostinger.
- Create notes with a title and body
- View all saved notes on the homepage (newest first)
- Health check endpoint at
/health
- Express — web framework
- EJS — server-rendered templates
- mysql2 — MySQL/MariaDB driver (promise-based)
- dotenv — environment configuration
- Docker Compose — local MariaDB matching Hostinger
.
├── server.js # App entry point, routes, server bootstrap
├── db.js # MySQL connection pool + table initialization
├── views/ # EJS templates
│ ├── partials/head.ejs
│ ├── index.ejs # Homepage (note list)
│ ├── new.ejs # New-note form
│ └── error.ejs
├── public/css/style.css
├── docker-compose.yml # Local MariaDB for development
├── .env.example
└── package.json
-
Install dependencies:
npm install
-
Create your environment file:
cp .env.example .env
The defaults already match the bundled Docker database (below), so you can leave them as-is for local development.
-
Start a local database. Hostinger's Web/Cloud hosting runs MariaDB, so the included
docker-compose.ymlprovides a matching MariaDB instance:docker compose up -d
This starts MariaDB on
DB_PORT(3306) and creates theDB_NAME(notetaker) database using the credentials from your.env. Data persists in a named volume, so notes survive restarts. Stop it withdocker compose down.No Docker? Point the
.envcredentials at any existing MySQL/MariaDB server instead — just make sure theDB_NAMEdatabase exists. Thenotestable is created automatically on startup either way. -
Start the app:
npm start
The app runs at
http://localhost:3000.
| Method | Path | Description |
|---|---|---|
| GET | / |
List all saved notes |
| GET | /notes/new |
Show the new-note form |
| POST | /notes |
Create a note (title + body) |
| GET | /health |
Health check (verifies DB access) |
- In hPanel, create a Node.js application and a MySQL database.
- Set the application's environment variables (
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD,DB_NAME, and optionallyPORT) to match your Hostinger database. On Hostinger,DB_HOSTis typicallylocalhost. - Upload the project files (or deploy via Git), set the startup file to
server.js, and runnpm install. - Start the application. Verify it is healthy by visiting
/health.