import Fluent
import Vapor
import Crypto


let
 encryptionKey = SymmetricKey(data: Environment.get("ENCRYPTION_KEY")!.data(using: .utf8)!)

func routes(_ app: Application) throws {
    app.routes.caseInsensitive = true
    app.routes.defaultMaxBodySize = "64mb";
    let baseApp = app.grouped("api").grouped("v2.0")
    baseApp.get { req async in
        "Connexion Mobile Services Version 2.0"
    }
    try baseApp.register(collection: cntrlCategory())
    try baseApp.register(collection: cntrlValueType())
    try baseApp.register(collection: cntrlDataType())
    try baseApp.register(collection: cntrlRole())
    try baseApp.register(collection: cntrlUser())
    try baseApp.register(collection: cntrlLocation())
    try baseApp.register(collection: cntrlDivision())
    try baseApp.register(collection: cntrlGate())
    try baseApp.register(collection: cntrlSegment())
    try baseApp.register(collection: cntrlResponseType())
    try baseApp.register(collection: cntrlUnit())
    try baseApp.register(collection: cntrlComparisonType())
    try baseApp.register(collection: cntrlEquipmentType())
    try baseApp.register(collection: cntrlFluid())
    try baseApp.register(collection: cntrlFuel())
    try baseApp.register(collection: cntrlIncompleteReason())
    try baseApp.register(collection: cntrlInputType())
    try baseApp.register(collection: cntrlJobSite())
    try baseApp.register(collection: cntrlLevel())
    try baseApp.register(collection: cntrlNoteType())
    try baseApp.register(collection: cntrlPart())
    try baseApp.register(collection: cntrlPriority())
    try baseApp.register(collection: cntrlReason())
    try baseApp.register(collection: cntrlRepairType())
    try baseApp.register(collection: cntrlSignatureType())
    try baseApp.register(collection: cntrlSMSCCode())
    try baseApp.register(collection: cntrlState())
    try baseApp.register(collection: cntrlStatus())
    try baseApp.register(collection: cntrlViscosity())
    try baseApp.register(collection: cntrlCompartment())
    try baseApp.register(collection: cntrlCompartmentLocation())
    try baseApp.register(collection: cntrlContact())
    try baseApp.register(collection: cntrlContactInfo())
    try baseApp.register(collection: cntrlContactType())
    try baseApp.register(collection: cntrlCustomer())
    try baseApp.register(collection: cntrlEquipment())
    try baseApp.register(collection: cntrlMake())
    try baseApp.register(collection: cntrlModel())
    try baseApp.register(collection: cntrlObjProperty())
    try baseApp.register(collection: cntrlProduct())
    try baseApp.register(collection: cntrlItem())
    try baseApp.register(collection: cntrlItemResponseType())
    try baseApp.register(collection: cntrlLabSetting())
    try baseApp.register(collection: cntrlXFluidViscosity())
    try baseApp.register(collection: cntrlXUserRole())
    //try baseApp.register(collection: cntrlXWorkOrderSegment())
    try baseApp.register(collection: cntrlOilSample())
    try baseApp.register(collection: cntrlSpec())
    try baseApp.register(collection: cntrlSpecItem())
    try baseApp.register(collection: cntrlSpecItemValue())
    try baseApp.register(collection: cntrlWorkOrder())
    try baseApp.register(collection: cntrlWorkOrderFlow())
    try baseApp.register(collection: cntrlSignature())
    try baseApp.register(collection: cntrlWorkOrderPart())
    try baseApp.register(collection: cntrlWorkOrderAttachment())
    try baseApp.register(collection: cntrlInspectionType())
    try baseApp.register(collection: cntrlInspectionLevel())
    try baseApp.register(collection: cntrlWorkOrderSegment())
    try baseApp.register(collection: cntrlInspection())
    try baseApp.register(collection: cntrlInspectionCategory())
    try baseApp.register(collection: cntrlInspectionItem())
    try baseApp.register(collection: cntrlInspectionItemResponse())
    try baseApp.register(collection: cntrlInspectionItemSpec())
    try baseApp.register(collection: cntrlInspectionItemSpecItem())
    try baseApp.register(collection: cntrlInspectionItemSpecItemTest())
    try baseApp.register(collection: cntrlInspectionItemSpecItemValue())
    try baseApp.register(collection: cntrlNote())
    try baseApp.register(collection: cntrlConsumption())
    try baseApp.register(collection: cntrlTemplate())
    try baseApp.register(collection: cntrlTemplateCategory())
    try baseApp.register(collection: cntrlTemplateItemSpec())
}
