Jump to content

thomasaull

Members
  • Content Count

    55
  • Joined

  • Last visited

  • Days Won

    2

thomasaull last won the day on September 19 2018

thomasaull had the most liked content!

Community Reputation

97 Excellent

About thomasaull

  • Rank
    Full Member

Contact Methods

  • Website URL
    www.thomasaull.de

Profile Information

  • Location
    Würzburg, Germany

Recent Profile Visitors

1,342 profile views
  1. @pmichaelis I'm gonna ask anyway: Why? Seems like a weird server config, but I could add this to the variables the module checks by default.
  2. @pmichaelis If the error is thrown in line 131 it's likeley there is an error with the JWT Authorization. Maybe the Token you're submitting is not valid, maybe something else. Hard to tell with the little information you provided. Oh, just noticed you already mentioned the JWT Auth… Probably the error is produced in those 4 lines: $secret = wire('modules')->RestApi->jwtSecret; $token = str_replace('Bearer', '', $authHeader); $token = trim($token); $decoded = JWT::decode($token, wire('modules')->RestApi->jwtSecret, array('HS256')); if the secret is in your config and you didn't change it, I'd check if the token gets transmitted properly with the request.
  3. @siilak I think all you need to do is to add your route in Routes.php: $routes = [ ['PUT', 'user', User::class, 'addUser'], ]; And have some functionality for adding your data in your 'addUser' Function. Let me know, if it works!
  4. @Sebi@pmichaelis Think I'm going to include @pmichaelis since it does not required additional configuration (actually before I used the RestApi Module with NGINX it was using apache_request_headers anyway)
  5. @flydev Thanks for your PR. I'm going to investigate (feel free to remind me, if you don't hear back)! One concern though, do you think it's a good practice to send the password on every request? In this case you'd have to store the password somewhere in your frontend, which I think is security bad practise. Maybe other people do have an opinion about that?
  6. @pmichaelis Is vagrant using an apache or nginx server? Can you check where the authorization header is contained in your case (apache_request_headers or $_SERVER)? And what version of php are you using?
  7. @dragan Yes, it basically only sends a POST Request to a webhook url without any further information. So your assumption is correct In my case the CI Pipeline does a static build of the website and deploys it on the server. What happens in your build pipeline is totally up to you though. You could also do a request from your pipeline to your API to gather further information if needed. The trigger does not become active for system templates and pages which are not public, this is the related code: // do nothing for system pages: if ($page->template->flags === Template::flagSystem) return; // do nothing if page is not public if (!$page->isPublic) return;
  8. @flydev I adjusted the Regex Pattern for the endpoint url to allow numbers too: https://github.com/thomasaull/RestApi/commit/f2e851faf4b89449bca496d6bea20ee85dc0f6ee Please update the module to 0.0.6 for this to become active
  9. It might be a good idea to make this configurable, so the user can choose between a webhook or select a page to act as the api endpoint. You wanna provide a PR @eelkenet? I'm a bit short of time currently.
  10. I created a little helper module to trigger a CI pipeline when your website has been changed. It's quite simple and works like this: As soon as you save a page the module sets a Boolean via a pages save after hook. Once a day via LazyCron the module checks if the Boolean is set and sends a POST Request to a configurable Webhook URL. Some ideas to extend this: make request type configurable (GET, POST) make the module trigger at a specified time (probably only possible with a server cronjob) trigger manually Anything else? If there's interest, I might put in some more functionality. Let me know what you're interested in. Until then, maybe it is useful for a couple of people Github Repo: https://github.com/thomasaull/CiTrigger
  11. @gottberg @flydev I created a small helper class for dealing with responsive images: <?php namespace ProcessWire; class Image { public static function get ($image, $widths = [400, 800, 1200]) { $response = new \StdClass(); $response->focus = ["x" => $image->focus['left'], "y" => $image->focus['top']]; $response->urls = []; $response->description = $image->description; $response->name = $image->basename; $response->width = $image->width; $response->height = $image->height; foreach ($widths as $width) { $croppedImage = $image->width($width); $url = new \StdClass(); $url->url = $croppedImage->httpUrl; $url->width = $croppedImage->width; $url->height = $croppedImage->height; $url->ratio = $croppedImage->height / $croppedImage->width; array_push($response->urls, $url); } return $response; } } Usage: // $image is your ProcessWire PageImage return Image::get($image, [400, 800, 1200, 2000, 2500]);
  12. @eelkenet I'm sorry, somehow I missed your post. Do you think there is any way I can support ProCache with the module itself? I could also use a page in the pagetree to deliver the endpoint instead of doing it with a Hook
  13. @pwFoo What exactely do you mean by 1)? Mapping an endpoint to a PW Page is as easy as $page = wire('pages')->get(1042); in your endpoint function. Mapping an endpoint to a php file is the intendend behaviour of the module, check the example: https://github.com/thomasaull/RestApi/blob/master/apiTemplate/Example.php which get's mapped in the Routes.php: https://github.com/thomasaull/RestApi/blob/master/apiTemplate/Routes.php 2) That's basically the approach @LuisM used in his PR. I'm not sure if it's the best solution, check my comment on Github: https://github.com/thomasaull/RestApi/pull/1#issuecomment-450135767
  14. Oh dear! Thanks @BitPoet that's the solution I actually just missed to update the version in info.json…
  15. I tried to update the RestApi Module (http://modules.processwire.com/modules/rest-api/) from 0.0.3 to 0.0.4 without success. I updated everything on Github, published a new release over there and tried the following: wait couple of days for the module to update itself automatically input the new version number manually – after saving the version just stays the same Dunno if I'm doing something wrong or if it's broken?
×
×
  • Create New...