Group Group Group Group Group Group Group Group Group

Vapor Installation Instruction

Chapter 11 states:
“Follow the installation instructions found in Chapter 8, “RESTful Networking,” to install Vapor.”
when, in fact, the book never mentions Vapor prior to Chapter 11.

Instructions for anyone who needs them:
Follow https://docs.vapor.codes/3.0/install/macos/ to install vapor onto your computer
Personally I also had to fix https://www.jianshu.com/p/9aa9e123eb07 but that may have been specific to me.

1 Like

@h2whoa Thank you for sharing this - much appreciated!

So I’ve ended up here too. I tried the following so far:

cd projects/backend
brew install vapor
brew install libressl
brew install pkg-config
echo "export PKG_CONFIG=/usr/local/bin/pkg-config" >> ~/.zshrc
cd MyBiz
vapor xcode -y
  1. Wait for all dependencies to install (happened automatically for me)
  2. Select Run scheme (was not available before …)
  3. Build & Run

I’ve tried all those things in order to fix errors that showed up …

Now I’m stuck with the following errors in configure.swift:

Cannot convert value of type 'DatabaseIdentifier<Event.Database>' to expected argument type 'DatabaseIdentifier<Event.Database>'
Generic parameter 'D' could not be inferred
Arguments to generic parameter 'D' ('Event.Database' and 'Event.Database') are expected to be equal

@shogunkaramazov can you please help me or provide updated backend code that works?

I really enjoyed the book so far. Please help me.

1 Like

Okay I got this.

Had to change line 57–65 in configure.swift to the following:

  // Configure migrations
  var migrations = MigrationConfig()
  migrations.add(model: Event.self, database: DatabaseIdentifier<Event.Database>.sqlite)
  migrations.add(model: Employee.self, database: DatabaseIdentifier<Employee.Database>.sqlite)
  migrations.add(model: User.self, database: DatabaseIdentifier<User.Database>.sqlite)
  migrations.add(model: Token.self, database: DatabaseIdentifier<Token.Database>.sqlite)
  migrations.add(model: Announcement.self, database: DatabaseIdentifier<Announcement.Database>.sqlite)
  migrations.add(model: Product.self, database: DatabaseIdentifier<Product.Database>.sqlite)
  migrations.add(model: PurchaseOrder.self, database: DatabaseIdentifier<PurchaseOrder.Database>.sqlite)

Server is running now. Figuring all that stuff out did cost me quite some time. And I did almost quit because I ran from one issue into the next. The book was also not really trustworthy since it mentioned contents that are simply not available …

There’s a web.Dockerfile in the backend project. Maybe you could add some information on how to run this using docker. That would make things more future proof maybe? (I didn’t try because I don’t know if I have to work on the backend code / if docker is a good idea in that case …)

Best regards
Martin

3 Likes

Did you have errors shown in the log console after running command + U in MyBiz project?

[ INFO ] Migrating ‘sqlite’ database (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/MigrationConfig.swift:69)

[ INFO ] Preparing migration ‘Event’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘Employee’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘User’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘Token’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘Announcement’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘Product’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘PurchaseOrder’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘AnalyticsEvent’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘AdminUser’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘SeedUsers’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘SeedAnnouncements’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘SeedProducts’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘SeedPurchases’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘SeedEvents’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Preparing migration ‘SeedEmployees’ (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/Migrations.swift:111)

[ INFO ] Migrations complete (/Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/SourcePackages/checkouts/fluent/Sources/Fluent/Migration/MigrationConfig.swift:73)

Running default command: /Users/davidlee/Library/Developer/Xcode/DerivedData/MyBiz-euouwrqhmvmncxfjodgroaabdnfk/Build/Products/Debug/Run serve

Server starting on http://localhost:8080

Swift/ErrorType.swift:200: Fatal error: Error raised at top level: NIO.SocketAddressError.unknown(host: “localhost”, port: 8080)

2021-09-13 15:41:03.158691+0800 Run[6955:10372334] Swift/ErrorType.swift:200: Fatal error: Error raised at top level: NIO.SocketAddressError.unknown(host: “localhost”, port: 8080)

(lldb)