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.
 
 

64 lines
1.9 KiB

  1. import Vapor
  2. func routes(_ app: Application) throws {
  3. app.routes.caseInsensitive = true
  4. app.routes.defaultMaxBodySize = "64mb";
  5. let V2_1 = app.grouped("api").grouped("v2.1")
  6. try V2_1.register(collection: FuelEntryV2ControllerV2_1())
  7. let v2_2 = app.grouped("api").grouped("v2.2")
  8. try v2_2.register(collection: FuelEntryV2ControllerV2_2())
  9. let v2 = app.grouped("api").grouped("v2")
  10. try v2.register(collection: FuelEntryV2Controller())
  11. try v2.register(collection: UserController())
  12. let fuelEntryController = FuelEntryController()
  13. app.get {
  14. req in return "Fueling API v2"
  15. }
  16. app.get("fuel-entries") { req in
  17. try await fuelEntryController.index(req: req)
  18. }
  19. app.post("fuel-entries") { req in
  20. try await fuelEntryController.create(req: req)
  21. }
  22. app.delete("fuel-entries", ":fuelEntryID") { req in
  23. try await fuelEntryController.delete(req: req)
  24. }
  25. // V2 API routes with image upload
  26. // let v2Routes: () = app.group("api", "v2") { v2 in
  27. // let fuelEntryV2Controller = FuelEntryV2Controller()
  28. //
  29. // v2.get("fuel-entries") {req in
  30. // try await fuelEntryV2Controller.index(req: req)
  31. // }
  32. //
  33. //// v2.get("fuel-entries", "with-images") {req in
  34. //// try await fuelEntryV2Controller.getAllEntriesWithImages(req: req)
  35. //// }
  36. //
  37. // v2.post("fuel-entries") {req in
  38. // try await fuelEntryV2Controller.create(req: req)
  39. // }
  40. //
  41. //// v2.post("fuel-entries", ":id", "upload-image") { req -> FuelEntry in
  42. //// return try await fuelEntryV2Controller.uploadImage(req: req)
  43. //// }
  44. //
  45. // v2.delete("fuel-entries", ":fuelEntryID") { req in
  46. // try await fuelEntryV2Controller.delete(req: req)
  47. // }
  48. // }
  49. }