immux / immux1

https://immux.com
0 stars 0 forks source link

MVP for Foldr #115

Closed blaesus closed 5 years ago

blaesus commented 5 years ago

This PR implements three parts: Steward, Foldr, and ImmuxDB.ts.

Resolves #111 #114 #116

1. Steward

Steward (steward.ts) is responsible for: I. Executing backend code JavaScript II. Load projects by URL (project-name.foldr.site would load project-name) III. Serve as the HTTP server that actually passes the requests and responses to respective receivers

2. Foldr

Foldr (projects/foldr) is divided into two modes: the steward-node (akin to traditional server), and the transient-node (akin to traditional client).

Transient node provides the UI for users to operate on, and steward-node saves users' actions and provide support logic, such as authentication.

3. ImmuxDB.ts

ImmuxDB.ts is an adapter of ImmuxDB in TypeScript. It allows (asynchronous) access to ImmuxDB in a MongoDB-like manner:

await state.users.insert({name: ‘hello’})
const data = await state.users.find({})

Refactoring

http server

Previously, unicus cortex uses a hand-written TCP->HTTP mechanism, which breaks when the incoming message is too large (~1.5MB), and it's extremely error-prone.

The http mechanism is re-implemented with tiny-http.

Alternative packages including hyper and h2 were tried and they provide very leaky abstraction, requiring manual operation of futures. tiny-http is the only one that works with minimal manual works.

blaesus commented 5 years ago

@poppindouble Updated.