Last active
September 18, 2018 22:29
-
-
Save brianleroux/38a6f126edd47861084ecc3efe946541 to your computer and use it in GitHub Desktop.
what if I told u
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import data from '@architect/data' | |
import App from '@architect/shared/app' | |
import render from 'preact-to-string' | |
import {h} from 'preact' | |
/** | |
* ssr preact from a lambda | |
* if, instead of index.js, you have index.jsx OR index.tsx arc will automatically transpile the code | |
*/ | |
export async function handler(req) { | |
let notes = await data.all({ns:'notes'}) | |
let body = render(<App path={req.path} state={notes} />) | |
// future: support returning headers/body and promises | |
return `<!doctype html><html><body>${body}</body></html>` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment