https://github.com/adamsondavid/nano-edge
A selfhosted platform for seamless JAM-stack and serverless app deployments
https://github.com/adamsondavid/nano-edge
cloudflare edge-functions faas functions lambda netlify self-hosted serverless vercel
Last synced: 3 months ago
JSON representation
A selfhosted platform for seamless JAM-stack and serverless app deployments
- Host: GitHub
- URL: https://github.com/adamsondavid/nano-edge
- Owner: adamsondavid
- License: mit
- Created: 2024-10-11T22:32:33.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-03-31T19:00:19.000Z (3 months ago)
- Last Synced: 2025-03-31T19:38:42.931Z (3 months ago)
- Topics: cloudflare, edge-functions, faas, functions, lambda, netlify, self-hosted, serverless, vercel
- Language: TypeScript
- Homepage:
- Size: 2.86 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NanoEdge
All you need to do to deploy your app is to run the following command:
```sh
npx @nano-edge/cli deploy
```Advanced usage:
Do not forget to set the `NANO_EDGE_AUTH_TOKEN` env var, which is required by the cli.
```sh
export NANO_EDGE_AUTH_TOKEN=xxx npx @nano-edge/cli deploy --env.MY_SECRET=$SOME_SECRET
```
To customize cli options, you can create a file `nano-edge.config.json`:
```json
{
"env": {
"SOME_ENV_VAR": "SOME_VALUE"
}
}
```> [!IMPORTANT]
> Do not deploy secrets that are really secret! These secrets might be exploitable as nano-edge is currently not (yet?) hardened!## Build output API example:
- functions/api.js
- functions/env.json
- static/index.html
- static/main.jsThe signature of a function is `export default async (request: Request) => Promise`.\
A function can access env vars by using process.env.\
`env.json` will be generated by the cli if `nano-edge.config.ts` contains env vars. The file is overwritten if it already did exist before.## How inbound traffic would be handled by which resource from the build output:
- `/api` -> `functions/api.js` (function exec)
- `/api/some/sub/path` -> `functions/api.js` (function exec)
- `/index.html` -> `static/index.html` (served static)
- `/main.js` -> `static/main.js` (served static)
- `/some/random/path` -> `static/index.html` (served static)
- Edge-case (precedence): If a static file exists with same name as a function, the static file is
not served.
Instead, the function is executed.## Local development
If this is the first time you cloned this repository, make sure to run `npm install` in all subdirectories to make sure all dependencies are present. \
Only then continue with the following steps:Just run the following two scripts to start the stack and deploy an example app:
```sh
docker compose -f compose.yml -f compose.dev.yml up --build --watch --remove-orphans
``````sh
cd example-app && npm run deploy
```