Sha256: 7b5881abc4107d26ca9e10eddb382f009b81cda1aafb37cefd6620d4c71f73a5

Contents?: true

Size: 721 Bytes

Versions: 6

Compression:

Stored size: 721 Bytes

Contents

const http = require("http")
const litexec = require("./server/ssr_exec")

const server = http.createServer((req, res) => {
  if (req.method === "POST" && req.headers.authorization?.endsWith(process.env.LIT_SSR_AUTH_TOKEN)) {
    let body = ""
    req.on("data", (chunk) => {
      body += chunk.toString()
    });
    req.on("end", () => {
      let ret = "";
      try {
        ret = litexec.execScript(body)
      } catch (e) {
        console.warn(e);
      }
      if (ret) {
				res.end(ret.toString())
			} else {
				res.end("SCRIPT NOT VALID!")
			}
    })
  } else {
    res.statusCode = 400
    res.end("Invalid Request!")
  }
})

const port = process.env.LIT_SSR_SERVER_PORT
server.listen(port, "127.0.0.1")

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bridgetown-lit-renderer-2.1.0.beta2 src/serve.js
bridgetown-lit-renderer-2.1.0.beta1 src/serve.js
bridgetown-lit-renderer-2.0.0 src/serve.js
bridgetown-lit-renderer-2.0.0.beta3 src/serve.js
bridgetown-lit-renderer-2.0.0.beta2 src/serve.js
bridgetown-lit-renderer-2.0.0.beta1 src/serve.js