Giter Site home page Giter Site logo

readme's Introduction

Vapor at Nodes

Welcome to the Vapor team at Nodes' space on GitHub. We โค๏ธ Vapor. Look below to see what we are working on.

Feel free to get in touch or to submit a PR to any of our repos.

Documentation

Configuration

Blogging

Packages

Made at Nodes

Made by others

readme's People

Contributors

brettrtoomey avatar casperhr avatar cweinberger avatar heidipuk avatar johsoe avatar kimdv avatar martinlasek avatar rasmusebbesen avatar siemensikkema avatar steffendsommer avatar tomserowka 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  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  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

readme's Issues

Add more MySQL types to Schema.Creator

extension Schema.Creator {
    public func datetime(
        _ name: String,
        optional: Bool = false,
        unique: Bool = false,
        default: NodeRepresentable? = nil
    ) {
        custom(name, type: "DATETIME", optional: optional, unique: unique, default: default)
    }
}

SwiftDate does not compile for Linux

So I just figured out when trying to deploy

I created some fast extensions here

import Foundation

extension Date {
    
    public enum Error: Swift.Error {
        case couldNotParse
    }
    
    public static func parse(_ format: String, _ date: String) -> Date {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = format
        
        return dateFormatter.date(from: date) ?? Date()
    }
    
    public static func parse(_ date: String) -> Date {
        return Date.parse("yyyy-MM-dd HH:mm:ss", date)
    }
    
    public static func parseOrThrow(_ format: String, _ date: String?) throws -> Date {
        guard let dateString: String = date else {
            throw Error.couldNotParse
        }
        
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = format
        
        let newDate = dateFormatter.date(from: dateString)
        
        guard let newDateUnw = newDate else {
            throw Error.couldNotParse
        }
        
        return newDateUnw
    }
   
    public static func parseOrThrow(_ date: String?) throws -> Date {
        return try Date.parseOrThrow("yyyy-MM-dd HH:mm:ss", date)
    }
    
    public func to(_ format: String) throws -> String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = format
        
        return dateFormatter.string(from: self)
    }
    
    public func toDateTimeString() throws -> String {
        return try self.to("yyyy-MM-dd HH:mm:ss")
    }
    
    public func isPast() -> Bool {
        return self.compare(Date()).rawValue < 0
    }
    
    public func isFuture() -> Bool {
        return self.compare(Date()).rawValue > 0
    }
}

Is this something we should have one time? else our code will be super ugly :)

@steffendsommer @rasmusebbesen @NickSkull @skyback @BrettRToomey

Queues?

Do we have queue capabilities?

Test helper package

We should have a package that gives you all related helpers/mocks/stubs when testing Vapor projects.

Data source doc update

Lacking data source documentation
I am missing a section in the official docs regarding data sources. Persisting data is an integral part of most web based systems and there should be a dedicated section for this to make vapor more accessible to newcomers.
Also docs regarding column attributes in my data source. Nullable fields, unsigned integers etc.
Missing docblocks in the source
One of the best things about Laravel is that most of the code base is fully documented with doc blocks. They even have design guides to how doc blocks should look. Some parts of the code base is missing this (though I have also encountered several helpful ones)
Basic database operations
Database operations are not documented with clear examples. Common operations such as UPDATE and DELETE are not present in the docs. Only a very simple CREATE along with some generic JOIN example could be found.

Request: How to set up dev environment

Following the guides at Vapor (which also are out of date) does not seem to be enough - as there are Nodes specifics as well (mysql, mongodb, more?) - a guide would be much appreciated instead of blocking two developers for x amount of time.

Thanks in advance :)

Primary id is a INT not not SIGNED

MySQL Primary keys
The id() preparation function generates a signed int field as my tableโ€™s primary key. It should not be signed.

Mysql Query with NULL is not supported

Querying database for NULL values...
...seems impossible with Vapor. Need to use raw querying to achieve this. A query comparison filter .isNull could be an elegant solution (as well as an .isNotNull filter)

Should we formalize JSend for API responses?

Looking into our API guidelines and wondering why we should return 200 + {"status": "ok"} when there is no data (eg. for DELETE) instead of using 204 with an empty body I found this (JSend).
The guidelines mostly already follow this (except for "ok" instead of "success"). It does not seem to be an official spec but "success" pops up everywhere I find it mentioned.

I see 3 options:

  • change nothing
  • mention JSend
  • mention JSend and change "ok" to "success"

What do you think?

@steffendsommer

DateTime support in fluent

I tried to code around it. But it's not pretty

import Vapor
import Fluent
import Foundation
import HTTP
import Turnstile
import TurnstileCrypto
import SwiftDate
import Auth

public final class BackendUser: Auth.User, Model {
    
    public var exists: Bool = false
    public static var entity = "backend_users"
    
    public var id: Node?
    public var name: String
    public var email: Valid<Email>
    public var password: String
    public var role: String
    public var createdAt: DateInRegion
    public var updatedAt: DateInRegion
    
    enum Error: Swift.Error {
        case userNotFound
        case registerNotSupported
        case unsupportedCredentials
    }
    
    public init(node: Node, in context: Context) throws {
        id = try node.extract("id")
        name = try node.extract("name")
        let emailTemp: String = try node.extract("email")
        email = try emailTemp.validated()
        password = try node.extract("password")
        role = try node.extract("role")
        
        do {
            createdAt = try DateInRegion(string: node.extract("created_at"), format: .custom("yyyy-MM-dd HH:mm:ss"))
        } catch {
            createdAt = DateInRegion()
        }
        
        do {
            updatedAt = try DateInRegion(string: node.extract("updated_at"), format: .custom("yyyy-MM-dd HH:mm:ss"))
        } catch {
            updatedAt = DateInRegion()
        }
    }

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.