You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB

  1. import Vapor
  2. func routes(_ app: Application) throws {
  3. let fuelEntryController = FuelEntryController()
  4. app.get("fuel-entries") { req in
  5. try await fuelEntryController.index(req: req)
  6. }
  7. app.post("fuel-entries") { req in
  8. try await fuelEntryController.create(req: req)
  9. }
  10. app.delete("fuel-entries", ":fuelEntryID") { req in
  11. try await fuelEntryController.delete(req: req)
  12. }
  13. // V2 API routes with image upload
  14. let v2Routes = app.group("api", "v2") { v2 in
  15. let fuelEntryV2Controller = FuelEntryV2Controller()
  16. v2.get("fuel-entries") {req in
  17. try await fuelEntryV2Controller.index(req: req)
  18. }
  19. // v2.get("fuel-entries", "with-images") {req in
  20. // try await fuelEntryV2Controller.getAllEntriesWithImages(req: req)
  21. // }
  22. v2.post("fuel-entries") {req in
  23. try await fuelEntryV2Controller.create(req: req)
  24. }
  25. // v2.post("fuel-entries", ":id", "upload-image") { req -> FuelEntry in
  26. // return try await fuelEntryV2Controller.uploadImage(req: req)
  27. // }
  28. v2.delete("fuel-entries", ":fuelEntryID") { req in
  29. try await fuelEntryV2Controller.delete(req: req)
  30. }
  31. }
  32. }