A starter template for FaasJS.
- Click
Code->Codespaces->Create codespace on main. - Wait for the codespace to be created.
- In VS Code, open a new terminal and run
ni && nd(shorten command ofnpm install && npm run dev). - Enjoy!
- Latest stable macOS
- Latest stable Docker https://www.docker.com/
- Latest stable Visual Studio Code https://code.visualstudio.com/
- Use VS Code to open project.
- Install VS Code extension:
ms-vscode-remote.vscode-remote-extensionpack. - In VS Code, click
F1then chooseRemote-Containers: Reopen in Container. - In VS Code, open a new terminal
ni && nd(shorten command ofnpm install && npm run dev). - Open
http://localhost:5173/in browser.
Run nt (shorten command of npm run test).
Run npm run test:types to check action params/data type inference regressions.
npm run ci runs coverage with the Node binary next to npm, avoiding Bun node shims that do not support V8 coverage APIs.
Tests use embedded PGlite in Node test setup, so no external PostgreSQL service is required for local runs.
src/faas.yamlsetsdefaults.plugins.knex.config.clienttopgwith a default pool.development.plugins.knex.config.clientusespglitewith persisted storage at./.pglite_dev.testing.plugins.knex.config.clientusespglitein-memory (noconnection).productionstill uses PostgreSQL (client: pg).
- Run
npm run typegento generate action/event types intosrc/.faasjs/types.d.ts. npm run devusesviteFaasJsServer(), which auto-generates on startup and regenerates when.func.tsorsrc/faas.yamlchanges.
- Run
nb(shorten command ofnpm run build) to build the frontend by Vite. - Run
nr server(shorten command ofnpm run server) to start the server. - Open
http://localhost:3000/in browser.
FaasJS Starter follows the zero-mapping rule: API file path equals API route path.
- File:
src/pages/todo/api/list.func.ts - Client action:
/pages/todo/api/list - Request URL (with
baseUrl: '/'):POST /pages/todo/api/list
Use action paths with a leading slash (for example: /pages/todo/api/list) so TypeScript can match generated FaasActions keys.
Use api/ as the API directory name. Avoid custom rewrites such as actions -> api.
- Run
docker build -t faasjs-starter .to build the Docker image. - Run
docker run -p 3000:3000 faasjs-starterto start the container. - Open
http://localhost:3000/in browser.
Same as preview.