Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

ricardopsantos/RJSP_VaporWebServer

Repository files navigation

Swift 5.3 Swift 5.3 SPM Twitter

About

This is quick start web server, built using Vapor 4.0 and was how this series of articles started...


Features

Using Swift generics, the routing funtion...

func routes(_ app: Application) throws {
    
    app.get { req -> String in
        req.log(app)
        return "Hello stranger!\n\nChoose wishly:\n* https://www.linkedin.com/in/ricardopsantos\n* https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
    
    app.get("version") { req -> String in
        req.log(app)
        let version = "Version 1.0.0"
        return "\(version)\n\n\(app.environment)"
    }
       
    let collection_Config = GenericController<KeyValueDBModel>()
    collection_Config.validOperations = [.get]
    try app.register(collection: collection_Config)

    let collection_Logs = GenericController<LogsDBModel>()
    collection_Logs.validOperations = [.add, .get]
    try app.register(collection: collection_Logs)

    let collection_Todo = GenericController<TodoDBModel>()
    collection_Todo.validOperations = [.all]
    try app.register(collection: collection_Todo)
}

...will automatically build all this routes with the basic CRUD operations.

  • GET

  • GET /version

  • GET /config

  • GET /config/operations/:id

  • GET /messages

  • POST /messages

  • GET /messages/operations/:id

  • DELETE /messages/operations/:id

  • GET /todos

  • POST /todos

  • GET /todos/operations/:id

  • DELETE /todos/operations/:id

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published