Home

Awesome

ApiCore

Slack Jenkins Platforms Swift Package Manager Swift 4 Vapor 3

Base for API's that require user & team management including forgotten passwords, etc. This library should contain all the basic endpoints necessary to make your own SaaS platform similar to a github's own user management.

Warning!: This system is only designed to work with PostgreSQL at the moment!

Available endpoints

Install (available in DEBUG mode only!)

Authentication

Server

Users

Teams

Misc

Install

Just add following line package to your Package.swift file.

.package(url: "https://github.com/LiveUI/ApiCore.git", .branch("master"))

Configuration

There is a few ways to configure ApiCore. The easiest is through the Environmental variables.

CONFIG_PATH            // Path to a configuration file (default one is included `config.default.json`)
APICORE.JWT_SECRET     // Secret passphrase to sign JWT tokens (mandatory in production)

Configuration file looks like this

{
	"general": {
		"single_team": false
	},
	"auth": {
		"allow_registrations": true,
		"allow_invitations": true,
		"registration_domains": []
	},
	"server": {
		"name": "Booster!",
		"url": "http://localhost:8080",
		"max_upload": 50
	},
	"jwt_secret": "secret",
	"database": {
		"host": "localhost",
		"port": 5432,
		"user": "boost",
		"password": "aaaaaa",
		"database": "boost",
		"logging": false
	},
	"mail": {
		"email": "admin@apicore",
		"mailgun": {
			"domain": "sandbox-domain.mailgun.org",
			"key": "secret-key"
		}
    },
    "storage": {
        "local": {
	        "root": "/tmp/Boost"
        },
        "s3": {
	        "enabled": false,
			"bucket": "my-boost-appstore",
			"access_key": "my-access-key",
			"secret_key": "my-secret-key",
			"region": "us-east-1",
			"security_token": null
        }
    }
}

Each value can be set through a corresponding environmental variable in a number of formats

1) apicore.jwt_secret
2) APICORE.JWT_SECRET
3) apicore_jwt_secret
4) APICORE_JWT_SECRET

Integrationg ApiCore into a Vapor 3 app

To use ApiCore in an app, your configure.swift file could look something like this:

import Foundation
import Vapor
import DbCore
import MailCore
import ApiCore


public func configure(_ config: inout Config, _ env: inout Vapor.Environment, _ services: inout Services) throws {
    print("Starting ApiCore by LiveUI")
    sleep(10)
    Env.print()
    
    // Register routes
    let router = EngineRouter.default()
    try ApiCoreBase.boot(router: router)
    services.register(router, as: Router.self)
    
    // Go!
    try ApiCoreBase.configure(&config, &env, &services)
}

and main.swift somehow like that:

import ApiCoreApp
import Service
import Vapor

do {
    var config = Config.default()
    var env = try Environment.detect()
    var services = Services.default()
    
    // Setup ApiCore configure
    try ApiCoreApp.configure(&config, &env, &services)
    
    let app = try Application(
        config: config,
        environment: env,
        services: services
    )
    
    try app.run()
} catch {
    print("Top-level failure: \(error)")
}

Usage

TBD

Support

Join our Slack, channel <b>#help-boost</b> to ... well, get help :)

Boost AppStore

Core package for <b>Boost</b>, a completely open source enterprise AppStore written in Swift!

Other core packages

Code contributions

We love PR’s, we can’t get enough of them ... so if you have an interesting improvement, bug-fix or a new feature please don’t hesitate to get in touch. If you are not sure about something before you start the development you can always contact our dev and product team through our Slack.

Author

Ondrej Rafaj (@rafiki270 on Github, Twitter, LiveUI Slack and Vapor Slack)

License

ApiCore is distributed under an Apache 2 license and can be shared or used freely within the bounds of the license itself. Most third party components used (like Vapor framework and all its components) in this software are MIT licensed. List of all used software is listed in the repository. All components are available in the dependencies folder.

See the LICENSE file for more info.