const express = require('express');
const ingestService = require('../services/ingest.service');

const router = express.Router();

// Hardware posts GPS here. Auth is public_id + ingest_secret (not IMEI alone).
router.post('/location', async (req, res, next) => {
  try {
    res.json(await ingestService.saveLocation(req.body || {}));
  } catch (err) {
    next(err);
  }
});

module.exports = router;
