expo-http-server 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,11 +43,15 @@ public class ExpoHttpServerModule: Module {
43
43
  private func routeHandler(path: String, method: String) {
44
44
  server.add(path, block: { [weak self] (req, res, next) in
45
45
  let uuid = UUID().uuidString
46
+ var bodyString = "{}"
47
+ if let body = req.body, let bodyData = try? JSONSerialization.data(withJSONObject: body) {
48
+ bodyString = String(data: bodyData, encoding: .utf8) ?? "{}"
49
+ }
46
50
  self?.sendEvent("onRequest", [
47
51
  "uuid": uuid,
48
52
  "method": req.method.toString(),
49
53
  "path": path,
50
- "body": req.body,
54
+ "body": bodyString,
51
55
  "headersJson": req.allHTTPHeaderFields.jsonString,
52
56
  "paramsJson": req.query.jsonString,
53
57
  "cookiesJson": req.cookies?.jsonString ?? "{}"
@@ -61,7 +65,7 @@ public class ExpoHttpServerModule: Module {
61
65
  contentType: String,
62
66
  body: String) {
63
67
  if let response = responses[udid] {
64
- response.setStatusCode(UInt(statusCode), description: "Success")
68
+ response.setStatusCode(UInt(statusCode), description: "ExpoHttpServer")
65
69
  response.setValue(contentType, forHTTPHeaderField: "Content-type")
66
70
  response.setValue("\(body.count)", forHTTPHeaderField: "Content-Length")
67
71
  response.send(body);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-http-server",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A simple HTTP server expo module (iOS/Android)",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",