Comments (4)
@mrkurt I can take a look. Where's the app code?
from fly.rs.
Currently this:
import { expect } from "chai"
import cache from "@fly/cache"
import { Image } from "@fly/image"
import db, { Collection } from "@fly/data"
fly.http.respondWith(async function(req){
const result = []
// Document global
try{
const dom = Document.parse(html)
expect(dom).to.be.instanceof(Document)
const p = dom.querySelector("p")
expect(p).to.be.instanceof(Element)
expect(p.getAttribute("something")).to.equal("yo")
result.push("Document success!")
}catch(err){
result.push("Document error: " + err.toString())
}
// Text Encoding
try{
const td = new TextDecoder()
expect(td.decode(new Uint8Array([104, 101, 108, 108, 111]))).to.equal("hello")
const te = new TextEncoder()
expect(te.encode("hello")).to.deep.equal(new Uint8Array([104, 101, 108, 108, 111]))
result.push("Text Encoding success!")
}catch(err){
result.push("Text Encoding error: " + err.toString())
}
// Cache
try{
await cache.del("test-key")
await cache.set("test-key", "test-value")
const v = await cache.getString("test-key")
expect(v).to.eq("test-value")
result.push("Cache success!")
}catch(err){
result.push("Cache error: " + err.toString())
}
// Image
try{
const img = new Image({
width: 200,
height: 200,
background: { r: 255, g: 0, b: 0, alpha: 0.5 },
channels: 4
})
const meta = img.metadata()
expect(meta.width).to.eq(200)
expect(meta.height).to.eq(200)
result.push("Image success!")
}catch(err){
result.push("Image error: " + err.toString())
}
// Data
try{
const coll = db.collection("testing")
// insert initial object
let ok = await coll.put("yo", { some: "json" })
expect(ok).to.be.true
// replace the object
ok = await coll.put("yo", { some: "json2" })
expect(ok).to.be.true
// get the obj, to assert its value
const res = await coll.get("yo")
expect(res).to.deep.equal({ some: "json2" })
result.push("Data success!")
}catch(err){
result.push("Data error: " + err.toString())
}
try{
expect(app.config.secretThing).to.eq("secretValue")
result.push("Secret success!")
}catch(err){
result.push("Secret error: " + err.toString())
}
return new Response(result.join("\n\n"))
})
const html = `
<html>
<p something="yo">hello</p>
</html>
`
from fly.rs.
fwiw, it wouldn't bother me at all to solve this with a babel/webpack step that transforms the node based bundles into something better for this. It also wouldn't bother me to just have fly.rs understand these natively. Choose your own adventure.
from fly.rs.
Document
is one of the several objects not inserted into the global scope yet. The rest of the errors are from the old bridge api being referenced from the bundle. I think we can prepend a shim to the compiled source to get it working. I'll give that a try and see if there's an easy mode fix.
from fly.rs.
Related Issues (20)
- Handling uncaught exception and promise rejections
- Example DNS app
- resolv against specific nameserver addresses HOT 1
- Abstract file operations as a "store"
- Proposal: Programmatic "secrets" API HOT 1
- fetch + serverName / SNI for https requests HOT 1
- Slow data store instantiation
- Global cache notifications reader + writer HOT 1
- Handle Let's Encrypt http acme challenges HOT 3
- Use the new cache schema for responseCache HOT 2
- Move the `app` global under `fly`
- Moving forward towards execution with v8 modules. HOT 5
- Allow promises to be handled after rejection
- [cache] support onlyIfEmpty set option
- Improve response cache implementation
- Validate arguments
- [fly.cache] implement ttl function
- Graceful shutdown of HTTP server
- Use deno core crate? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fly.rs.