Giter Club home page Giter Club logo

sugar's Introduction

Sugar ๐Ÿฌ

Swift Version Vapor Version Circle CI codebeat badge codecov Readme Score GitHub license

๐Ÿ“ฆ Installation

Add Sugar to the package dependencies (in your Package.swift file):

dependencies: [
    ...,
    .package(url: "https://github.com/nodes-vapor/sugar.git", from: "4.0.0")
]

as well as to your target (e.g. "App"):

targets: [
    ...
    .target(
        name: "App",
        dependencies: [... "Sugar" ...]
    ),
    ...
]

Getting started ๐Ÿš€

Make sure that you've imported Sugar everywhere when needed:

import Sugar

Helpers

This package contains a lot of misc. functionality that might not fit into it's own package or that would best to get PR'ed into Vapor. Some examples of what this package contains:

Environment variables

Access environment variables by writing

env("my-key", "my-fallback-value")

Seeder commands

If you want to make your model seedable, you can conform it to Seedable and use SeederCommand to wrap your seedable model. This basically means that you can focus on how your model gets initialized when running your command, and save a little code on actually performing the database work.

Seeding multiple instances of your model will be added - feel free to PR.

Authentication

This package contains a lot of convenience related to JWT, usernames and passwords which is used in JWTKeychain and Admin Panel.

Migrations

Sugar contains a helper function for adding properties while excluding some specific ones. This makes it a bit more convenient if you want to only modify how a single one or a couple of fields gets prepared.

extension MyModel: Migration {
    static func prepare(on connection: MySQLConnection) -> Future<Void> {
        return MySQLDatabase.create(self, on: connection) { builder in
            try addProperties(to: builder, excluding: [\.title])
            builder.field(for: \.title, type: .varchar(191))
        }
    }
}

๐Ÿ† Credits

This package is developed and maintained by the Vapor team at Nodes.

๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license

sugar's People

Contributors

brettrtoomey avatar casperhr avatar cweinberger avatar emarashliev avatar jdmcd avatar kimdv avatar martinlasek avatar mauran avatar rasmusebbesen avatar siemensikkema avatar steffendsommer avatar themitvp avatar valen90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sugar's Issues

StrongPassword regex is malfunctioning

The StrongPassword validation would fail if you pass Qwer1234 although you are matching the described requirements:

  • Minimum Length 6
  • One Uppercase
  • One Lowercase
  • One Digit.

Align with Vapor 2

Go through the provided functionality and see if it is still relevant in Vapor 2. Also, consider if some of the functionality is not working correctly. In general, polish and bring this up to speed again.

Add more validators

  • IP Address
  • JSON
  • Numeric
  • Required
  • URL
  • After (Date)
  • After Or Equal (Date)
  • Before (Date)
  • Before Or Equal (Date)
  • Different

Date.startOfMonth() fails on Linux

Date.startOfMonth() fails on linux with the following error message:

2019-08-14T07:06:27.833935048Z /entrypoint.sh: line 33:     6 Segmentation fault      (core dumped) /vapor/[projectName]/code/.build/release/Run serve --port 8080 --hostname 0.0.0.0 --env development

Swift version: Swift 5.0

Create missing validators

With Vapor 2, we should add validators for the following (either getting it merged into Vapor or adding it to Sugar):

  • Unique field (query)
  • Field exists (query)
  • Password repeat
  • Strong password

Duplicate in ml-archive/admin-panel#30

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.