<?php

return [
  'pattern' => '(:all)save-file.json',
  'method' => 'POST',
  'action'  => function () {
      $json = file_get_contents('php://input');
      $data = json_decode($json);

      $page = page($data->pageUri);
      $file = $page->file($data->fileName);

      

      $newProperties = [];

      foreach ($data->properties as $incomingProperty) {
        $newProperties[$incomingProperty->name] = $incomingProperty->value;
      }

      $newFile = $file->update($newProperties);

      return json_encode($newProperties);
  }
];