Skip to content

Releases: alchemy-swift/alchemy

v0.4.0

29 Jun 17:27
d62982c
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.3.2...v0.4.0

v0.3.2

12 Jan 20:22
0ee997d
Compare
Choose a tag to compare

Fix an issue with package versions. Thanks @ShonFrazier for the report.

v0.3.1

04 Oct 16:20
Compare
Choose a tag to compare

Fixes an issue with a crash when there's no Queue registered to the app.

Also updates the README.

Thanks @adam-fowler for the report.

v0.3.0

24 Sep 22:49
Compare
Choose a tag to compare

Commands

This release adds commands to make it easy to run custom maintenance, cleanup or productivity tasks with your app.

Commands are built on top of Swift Argument Parser which means there is a ton of baked in functionality for custom flags, options, arguments and automatically generated help details. Commands also have access to your application's services meaning your can easily use your configured Databases, Queues, etc inside commands.

To create a command, first conform to the Command interface and implement func start(). You may add options, flags and configuration provided by Swift Argument Parser.

final class SyncUserData: Command {
    static var configuration = CommandConfiguration(commandName: "sync", discussion: "Sync all data for all users.")

    @Option(help: "Sync data for a specific user only.")
    var id: Int?

    @Flag(help: "Should data be loaded but not saved.")
    var dry: Bool = false

    func start() -> EventLoopFuture<Void> {
        if let userId = id {
            // sync only a specific user's data
        } else {
            // sync all users' data
        }
    }
}

Next, register your command type.

app.registerCommand(SyncUserData.self)

Now you may run your Alchemy app with your new command.

$ swift run MyApp sync --id 2 --dry

Make Commands

Also new are a suite of commands to increase productivity by generate typical interfaces you might use such as models, controllers, migrations, middleware, jobs, etc. Run $ swift run MyApp help for a list of all make commands.

For example, the make:model command makes it easy to generate a model with the given fields. You can event generate a full populated Migration and Controller with CRUD routes by passing the --migration and --controller flags.

$ swift run Server make:model Todo id:increments:primary name:string is_done:bool user_id:bigint:references.users.id --migration --controller
🧪 create Sources/App/Models/Todo.swift
🧪 create Sources/App/Migrations/2021_09_24_11_07_02CreateTodos.swift
          └─ remember to add migration to a Database.migrations!
🧪 create Sources/App/Controllers/TodoController.swift

Like all commands, you may view the details & arguments of each make command with swift run MyApp help <command>.

Additional Model CRUD functions

Also new are a few functions to help quickly look up, update, or delete models. Check out Model.find, Model.delete, and Model.update for what's new.

For a more in depth summary, check out the Commands guide.

v0.2.2

14 Sep 06:52
ba39656
Compare
Choose a tag to compare

This release adds support for running your server over TLS and HTTP/2.

By default, the server runs unencrypted over HTTP/1.1.

Enable TLS

To enable running HTTP/1.1 over TLS, use useHTTPS.

func boot() throws {
    try useHTTPS(key: "/path/to/private-key.pem", cert: "/path/to/cert.pem")
}

Enable HTTP/2

To enable HTTP/2 upgrades (will prefer HTTP/2 but still accept HTTP/1.1 over TLS), use useHTTP2.

func boot() throws {
    try useHTTP2(key: "/path/to/private-key.pem", cert: "/path/to/cert.pem")
}

Note that the HTTP/2 protocol is only supported over TLS, so implies using it. Thus, there's no need to call both useHTTPS and useHTTP2; useHTTP2 sets up both TLS and HTTP/2 support.

v0.2.1

12 Sep 22:04
Compare
Choose a tag to compare

Fix an issue with named services being registered

v0.2.0

08 Sep 21:48
Compare
Choose a tag to compare

Lots of new APIs including...

  • Robust job queues
  • Redis interfaces
  • Powerful, cron-based scheduler
  • Advanced Rune relationship configurations
  • Service container & Service protocol for injecting services
  • Persisted cache backed by Redis or SQL
  • @main support
  • Tons of convenience, bug fixes & cleanup

Check out the new README & Docs/ for the lowdown on what's new.

v0.1.4

25 Jan 19:49
Compare
Choose a tag to compare

Adds grouping of routes by path prefix.

Courtesy of @slashmo

v0.1.3

24 Jan 03:05
Compare
Choose a tag to compare

Adds MySQL support for JSON types

v0.1.2

21 Jan 23:38
1b4b81b
Compare
Choose a tag to compare

Fixes some issues around MySQL, also adds support for ON DELETE, ON UPDATE, and bigInt in migrations.