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.
 
 

56 line
1.4 KiB

  1. //import Fluent
  2. //import Vapor
  3. //
  4. //func routes(_ app: Application) throws {
  5. // app.get { req async in
  6. // "It works!"
  7. // }
  8. //
  9. // app.get("hello") { req async -> String in
  10. // "Hello, world!"
  11. // }
  12. //
  13. // try app.register(collection: TodoController())
  14. //}
  15. import Vapor
  16. func routes(_ app: Application) throws {
  17. let fuelEntryController = FuelEntryController()
  18. app.get("fuel-entries") { req in
  19. try await fuelEntryController.index(req: req)
  20. }
  21. app.post("fuel-entries") { req in
  22. try await fuelEntryController.create(req: req)
  23. }
  24. app.delete("fuel-entries", ":fuelEntryID") { req in
  25. try await fuelEntryController.delete(req: req)
  26. }
  27. // V2 API routes with image upload
  28. let v2Routes = app.group("api", "v2") { v2 in
  29. let fuelEntryV2Controller = FuelEntryV2Controller()
  30. v2.get("fuel-entries") {req in
  31. try await fuelEntryV2Controller.index(req: req)
  32. }
  33. v2.post("fuel-entries") {req in
  34. try await fuelEntryV2Controller.create(req: req)
  35. }
  36. v2.post("fuel-entries", ":id", "upload-image") { req -> FuelEntry in
  37. return try await fuelEntryV2Controller.uploadImage(req: req)
  38. }
  39. v2.delete("fuel-entries", ":fuelEntryID") { req in
  40. try await fuelEntryV2Controller.delete(req: req)
  41. }
  42. }
  43. }