### Instruction:
Develop a Node.js application that serves as a RESTful API for managing a simple task management system. The API should support endpoints for creating, updating, deleting, and listing tasks. Each task should have a title, description, due date, and status (completed or not). Store the tasks in a MariaDB database.


### Response:

To create a RESTful API for managing a simple task management system, follow these steps:

1. Install required packages
First, you need to install the necessary packages for your Node.js application. You will use Express as the web framework and MariaDB as the database.

```bash
npm init -y
npm install express mariadb body-parser dotenv
```

2. Set up environment variables
Create a `.env` file in your project root directory with the following content:

```
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=tasks_db
```

3. Create a `database.sql` file
Create a new file named `database.sql` in your project root directory with the following SQL script to create the tasks table:

```sql
CREATE DATABASE IF NOT EXISTS tasks_db;

USE tasks_db;

CREATE TABLE IF NOT EXISTS tasks (
  id INT AUTO_INCREMENT PRIMARY KEY,
  title VARCHAR(255) NOT NULL,
  description TEXT,
  due_date DATE,
  status ENUM('completed', 'not_completed') DEFAULT 'not_completed'
);
```

4. Implement the RESTful API
Create a new file named `app.js` in your project root directory with the following code:

```javascript
const express = require('express');
const bodyParser = require('body-parser');
const mariadb = require('mariadb');
const dotenv = require('dotenv');

// Load environment variables from .env file
dotenv.config();

// Initialize app
const app = express();
app.use(bodyParser.json());

// Connect to MariaDB
const pool = mariadb.createPool({
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
});

// Helper function to execute queries
async function query(sql, params) {
  let conn;
  try {
    conn = await pool.getConnection();
    const rows = await conn.query(sql, params);
    return rows;
  } catch (err) {
    throw err;
  } finally {
    if (conn) conn.release();
  }
}

// List tasks
app.get('/tasks', async (req, res) => {
  try {
    const tasks = await query('SELECT * FROM tasks');
    res.json(tasks);
  } catch (err) {
    res.status(500).send(err.message);
  }
});

// Create task
app.post('/tasks', async (req, res) => {
  const { title, description, due_date, status } = req.body;

  try {
    const result = await query(
      'INSERT INTO tasks (title, description, due_date, status) VALUES (?, ?, ?, ?)',
      [title, description, due_date, status]
    );
    res.json({ id: result.insertId });
  } catch (err) {
    res.status(500).send(err.message);
  }
});

// Update task
app.put('/tasks/:id', async (req, res) => {
  const { id } = req.params;
  const { title, description, due_date, status } = req.body;

  try {
    await query(
      'UPDATE tasks SET title=?, description=?, due_date=?, status=? WHERE id=?',
      [title, description, due_date, status, id]
    );
    res.sendStatus(200);
  } catch (err) {
    res.status(500).send(err.message);
  }
});

// Delete task
app.delete('/tasks/:id', async (req, res) => {
  const { id } = req.params;

  try {
    await query('DELETE FROM tasks WHERE id=?', [id]);
    res.sendStatus(200);
  } catch (err) {
    res.status(500).send(err.message);
  }
});

// Start server
const port = process.env.PORT || 3000;
app.listen(port, () => {
  console.log(`Server running on http://localhost:${port}`);
});
```

5. Run the application
First, create the database and table by executing the `database.sql` script:

```bash
mysql -u root -p < database.sql
```

Then, start your Node.js application:

```bash
node app.js
```

Now you have a RESTful API for managing tasks with endpoints for creating, updating, deleting, and listing tasks. The tasks are stored in a MariaDB database.