Git Product home page Git Product logo

thetealpickle / cheese-api-swift Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 65 KB

[FRAMEWORK] A Vapor 3 Swift API based on cheese. API capabilities include [Login/Token(Authentication), Logging, API Testing] This project is templated, feel free to use it as a starting point โ™ฅ๏ธ๐Ÿง€

License: MIT License

Swift 94.53% Dockerfile 5.47%
server-side-swift vapor vapor-template vapor-toolbox backend api swift

cheese-api-swift's Introduction

CheeseVapor API Template

โš ๏ธ [FEATURE REFACTOR IN PROGRESS] โš ๏ธ

MIT License Swift 4.1

HELLO! @THETEALPICKLE HERE. Are you a lazy backend coder who loves cheese? Then this is your template.

BACKSTORY

In the alien hyper-stream (the human equivalent of a mall), a substance once believed to be extinct has resurfaced. This substance, known on Earth as ๐Ÿง€ cheese, is a highly corrosive weapon ๐Ÿฆ  capable of slowing down higher consciousness evolution. The ultimate weapon in ๐Ÿ’ฃ war.

The Grand Alieness has approved a reconnaissance mission to collect cheese data from every planet. For the mission, given the origins of the weapon, The Grand Alieness has opted for the use of human technology as the data collection method.

Different planets culture cheese with varying toxin levels.

This is the API.

WHO?

๐Ÿค– CheeseVapor is a Swift based server based on cheese ๐Ÿง€

WHAT?

๐Ÿ™ƒ Features ๐Ÿ™ƒ

  • Authentication [Login/Token]
  • Logging
  • Model Testing
  • Request Testing

HOW?

๐Ÿง  Vapor 3, babyyyyyy ๐Ÿ’จ

Running a Docker MySQL Database

The three databases with Vapor support are sqlite, msql, and postgresql.
This project uses MySQL as its database.

To get this project running on your machine, 3 steps.

  1. Get a Docker MySQL Database up and Running
  2. Clone the project to your machine
  3. Build and run the project

That is all. ๐Ÿ™ƒ

Haha. As if beginner Jessica would understand that shit. ๐Ÿ˜ญ
OKAY, some more effort into the explanation, here we go

Brace yourself, more detailed steps coming. Get your cup of water please

1/3 Docker Setup

You'll first want to get Docker up and running.

Head over to the Docker website and start the download of the Docker Desktop Application
Assuming the link hasn't changed, you should be able to click on 'Docker Desktop Application' above to be directed to the website.

Cool, while that's downloading (can't remember if it took a while, let's assuming it does). Create a docker application. You'll need these credentials to log into the desktop application.
No worries, you won't be charged for anything. F R E E. ๐Ÿ’ฐ๐Ÿ‘๐Ÿพ

Up to this point you should have logged into the Docker desktop application with your docker credentials.
Hold up, you haven't started any databases yet. You've set the stage so that you CAN start running databases.

Open up a new Terminal window and type the command

docker run --name mysql -e MYSQL_DATABASE=vapor -e MYSQL_USER=vapor -e MYSQL_PASSWORD=password \
-p 3306:3306 -d mysql/mysql-server:5.7

Hey, Jessica. WTF, did I just type?

Okay.

docker run

The docker command for running a docker database

--name mysql

The database container I want to create can be identified with the name mysql. This is the name you will use when you want to stop, start, and remove your database

-e MYSQL_DATABASE=vapor

Setup the global variable for my mysql database to the value 'vapor'. This is the database reference that is used in your server's configure.swift file for setting up your databse configuration

-e MYSQL_USER=vapor

Setup the global variable for my mysql user to the value 'vapor'. This is the username reference that is used in your server's configure.swift file for setting up your database configuration.

-e MYSQL_PASSWORD=password

Setup the global variable for my mysql password to the value 'password'. This is the password reference that is used in your server's configure.swift file for setting up your database configuration.

-p 3306:3306

Set the port for your docker database to run on port 3306. 3306 is the default MySQL port.

-d

Set the database to be detached. Detached mode is when your database container is running in the background.

mysql/mysql-server:5.7

Specifying which mysql server version to use. In this case, 5.7

Alright, bitch. Welp. That was most of the work.
Take a breathe, almost done.

2/3 Clone the project

Easiest method if you don't have ssh setup on your device is to download the zip and unzip it. bam.

HOWEVER, you probably do have SSH setup. If not, but you're interested in doing so (a good thing to do for a secure connection between your machine and your github account). You can follow this article (Assuming the link hasn't changed since writing this ๐Ÿ˜ฌ).

Yay, project cloned, docker running. Time to build and run. This is it.

3/3 Building and Running the Project

Pull up a new terminal window and change directory cd AKA navigate to your project's folder.
First, you'll want to build your project's dependencies.

vapor build

Now, run your project

vapor run

From here you can use the Postman or RESTed app to test your API endpoints.

Yay, twerk time. ๐Ÿ‘๐ŸŽ‰

Database Exploration

The main databases supported with Vapor include SQLite, MySQL, and PostgreSQL.
That's cool, but what does that mean?

What are their disadvantages and advantages? Appropriate use cases?

SQLite

SQLite is a lightweight database used for simple local data storage.
I have found this database type is most useful for data analysis/machine learning.
For example local on device storage of an artificial intelligence model

SQLite also shines when it comes to internet of things devices which often operate without human support.
SQLite does not compete with client/server databases like MySQL or PostgreSQL.
SQLite competes more with standard file management libraries such as fopen().

MySQL

MySQL was designed for speed and reliability, making it an ideal database for many use cases.
Currently many large applications and sites such as Facebook, Spotify, and Netflix are powered by MySQL.
MySQL's speed and reliability come at the cost of not fully being SQL compliant, so there are some functional limitations depending on your use case.

Disadvantages of MySQL: [SQL compliance and functionality limitations, licence and propriety features, and slowed development]
Advantages of MySQL: [security, speed, replication (useful for horizontal scaling), and popularity/ease of use]

PostgreSQL

PostgreSQL is the most advanced open-source relational database. PostgreSQL was designed to be highly extensible and standard compliant.


MIT License Swift 4.1

cheese-api-swift's People

Contributors

thetealpickle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.