Create a Node.js RESTful API that supports CRUD operations on a PostgreSQL database. The API should handle requests for managing a "Task" entity with attributes such as title, description, due date, and status.
PLAINFORMAT
const express = require('express');
const bodyParser = require('body-parser');
const Task = require('./taskModel');

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

// Get all tasks
app.get('/tasks', async (req, res) => {
  const tasks = await Task.getAll();
  res.json(tasks);
});

// Get task by ID
app.get('/tasks/:id', async (req, res) => {
  const task = await Task.getById(req.params.id);
  res.json(task);
});

// Create a new task
app.post('/tasks', async (req, res) => {
  const { title, description, due_date, status } = req.body;
  const task = await Task.create(title, description, due_date, status);
  res.status(201).json(task);
});

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

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

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