Giter VIP home page Giter VIP logo

peasy's People

Contributors

chaoscoder avatar corteggo-roche avatar kanecheshire 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

Watchers

 avatar  avatar  avatar

peasy's Issues

Handle port in use errors better

If the port is in use it would be better to let people know rather than fatalErroring so they can change the port.

Generally errors need to be handled better throughout but this is the first step.

Requests will fail to parse if header end indicator is split over two events

Currently the parser expects the double line break that indicates the header section is complete is sent in one chunk of data, so if it happens to have been chunked so the line break is split over two chunks the parsing will fail.

It’s unlikely to happen but possible and would be one of those things that’s super hard to debug when tests randomly fail using Peasy.

Luckily it’s easy to add unit tests to cover this.

Use unused ports

As I don't control all the used ports on the system that runs the ui tests, it would be great to just use the next unused port and ask the server about the port it used. This would make parallel UI testing with one server per UI test more reliable.

E.g. usage like this:

let server = Server()
server.start(port: 0) // indicate we want to use a port the system chooses for us. Method name could be different.
let serverAddress = "http://localhost:\(server.port)" // Server needs a new property e.g. `var port: Int?` that gets set when start is called.

let app = XCUIApplication()
app.launchArguments.append(contentsOf: ["-SERVER_ADDRESS", serverAddress]) // use serverURL to pass to app as the server url

Is that possible?

Split Peasy up into raw server and API

Currently everything is bundled up as one lib which includes the code to handle sockets, and the nice API on top of that to handle intercepting requests and responding etc.

It would be beneficial for the socket stuff to be broken out into a separate reusable lib so that any API can be built on top of it. Peasy's API is nice but may not suit everyone, and also restricts the way that new APIs must be written (for example I've had to really think about the way websockets work and fit nicely with Peasy's existing API).

The socket lib (name pending lol) will essentially be a wrapper around the core Darwin APIs to listen for incoming socket requests, keep them open and handle reading from and writing to a socket.

Improve Loop usage

Drawing it out, the loop is only needed in two places:

  • Server for incoming connection events
  • Transport for requests and responses

Currently, we create one Loop in Server, and then pass that into Connections which don't use it directly but pass it to its Transport.

Wondering if it's even needed and whether we could just use a regular DispatchQueue async call on a queue.

Load JSON body data from file

It would be nice if you could load JSON from a file to respond with, like so:

extension Response {
    public init(status: Status, headers: [Header] = [], bodyFromJSONFile: String) {
        // load body data as JSON from given file
    }
}

Stopping and restarting a server on the same address crashes

The way it's currently set up (with not great error handling) is that if you stop and immediately restart the server with the same port and address it crashes.

Although Peasy does close ports when they're deinitialized, there's some odd behaviour with the InputLoop which stops it from closing immediately.

Probably easily rectified by explicitly closing things rather than waiting for deinits.

DarwinError() - Operation not permitted - MacOS - UITests target

I got an issue "operation not permitted"

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.security.app-sandbox</key>
	<true/>
	<key>com.apple.security.network.client</key>
	<true/>
	<key>com.apple.security.network.server</key>
	<true/>
</dict>
</plist>

and if I run:

server = Server()
server.start(port: 8880)

from main target it works, but from uiTests target it always fails.

Reverse order of matched configurations

As mentioned in #21, it's more beneficial if configs are matched in reverse order, so that you can set up a set of "defaults", and then add overrides that are removed after they're matched, so it falls back to the defaults after.

The reason I haven't approved that PR is because I want to spend some time and make sure I get the API right.

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.