Skip to content

Demo chat web service for「Swift実践入門」刊行記念 Tech Talks

License

Notifications You must be signed in to change notification settings

noppoMan/SwiftJNChatApp

Repository files navigation

SwiftJNChatApp

Demo chat web service for「Swift実践入門」刊行記念 Tech Talks

Getting Starterd

Environement Variables

You may need to specify following Environement Variables to run application successfully.

  • MYSQL_HOST: default is localhost
  • MYSQL_USER: default is root
  • MYSQL_PASSWORD: default is null
  • GITHUB_CLIENT_ID
  • GITHUB_CLIENT_SECRET
  • JWT_SECRET

Linux

On the Linux, it's easy to run application with Docker

$ git clone https://github.com/noppoMan/SwiftJNChatApp.git
$ cd SwiftJNChatApp

# create .env
$ touch .env
echo "GITHUB_CLIENT_ID=YOUR_CLIENT_ID" >> .env
echo "GITHUB_CLIENT_SECRET=YOUR_SECRET" >> .env
echo "JWT_SECRET=foobar" >> .env
echo "MYSQL_HOST=host" >> .env
echo "MYSQL_USER=user" >> .env
echo "MYSQL_PASSWORD=password" >> .env

# Build and run Server and Schema Migrations with Docker
docker build -t swiftjn-chat-app .
docker run -v /path/to/your/.env:/var/www/app/.env swiftjn-chat-app
docker exec -it swiftjn-chat-app /var/www/app/.build/debug/Migration migrate:latest

MacOSX

Flows

  1. Open Project with Xcode
  2. Add .env into Project Root
  3. Schema Migration
  4. Run

1. Open Project with Xcode

$ git clone https://github.com/noppoMan/SwiftJNChatApp.git
$ cd SwiftJNChatApp
$ swift package generate-xcodeproj --type=executable
$ open *.xcodeproj 

2. Add .env into Project Root

First, You need to create github Oauth Application and get CLIENT_ID AND CLIENT_SECRET from Your Application page.

$ touch .env
echo "GITHUB_CLIENT_ID=YOUR_CLIENT_ID" >> .env
echo "GITHUB_CLIENT_SECRET=YOUR_SECRET" >> .env
echo "JWT_SECRET=foobar" >> .env
echo "MYSQL_HOST=host" >> .env
echo "MYSQL_USER=user" >> .env
echo "MYSQL_PASSWORD=password" >> .env

3. Schema Migration

$ swift build
$ ./.build/debug/Migration migrate:latest

4. Run

Select SwiftJNChatApp executable Schema from Schema List

and then, press Command-R to run application

Xcode says, Server Listening at localhost:3030.

Open http://localhost:3030 with Browser

If you finished to run application on Linux or Mac, let's check it in Browser.

That's it!

License

SwiftJNChatApp is released under the MIT license. See LICENSE for details.

About

Demo chat web service for「Swift実践入門」刊行記念 Tech Talks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published