function send(req, res) {
    if (!database) {
      log.info(`Database file is not loaded yet.`);
      return sendError(res, 404, 'Database file is not loaded yet.')
    }
    filterDatabase(database, req.query?.q || '', req)
      .then(database => {
        if (!req.query?.offset && !req.query?.limit) {
          return res.send(database)
        }
        const length = database.data.length;
        const offset = sanitizeInt(req.query.offset, 0, length, 0);
        const limit = sanitizeInt(req.query.limit, Math.min(10, length), length, length);
        const data = database.data.slice(offset, offset + limit);
        res.send({type: database.type, limit, offset, ...database, data });
      })
      .catch(err => {
        log.error(err, `Failed to filter database with query '${req.query?.q}': ${err}`)
        return sendError(res, 400, `Failed to filter database with query '${req.query?.q}': ${err}`)
      })
  }
@type {import('@home-gallery/types').TQueryContext}