flash
Flash is a type-oriented web framework in TypeScript, particularly optimized for building cloud microservices with a REST API on a serverless platforms with Deno.
Warning
Flash is still an alpha version. Do not use it for production use yet, unless you are a contributor to the framework.
Concepts
- Stay RESTful.
- You implement, we type.
Features / Roadmap
- 🚀 Multi Platform
- Cloudflare Workers
- Deno Deploy
- :magic_wand: Progressive APIs
- Tree-structured and semantic routers
- Polymorphism in resource implementation
- Syntax sugar for responses
- Strong type inference
- 🌤️ Out-of-box middlewares for Cloudflare Workers
- Object storage associated with each resource URL
- Blocking communication among workers
- 📜 Code/Doc Generation
- Universal Typescript SDK for clients
- OpenAPI specs
- Seamless hosting of API documents
- ⚙️ Advanced functionalities
- Multipart support
- GraphQL server
- ✨ Zero third-party dependencies
Usage
Cloudflare Workers
Create a worker module file:
// index.ts
import { flare } from "https://deno.land/x/flash/mod.ts";
export default flare({ "/": "Welcome to flash!" });
And deploy with Denoflare!
$ denoflare push index.ts --name flash-demo
APIs
Routers
Implemented with the standard URLPattern interface.
flare({
"/": "Welcome to flash!",
"/users/:name": ({ params }) => params.name,
});
Error Handlers
You can define error handlers using the same interface as router:
flare({
"/": "Welcome to flash!",
}, {
404: "Not Found",
500: "Unexpected Error",
});
Request Handlers
You can access various utility objects provided by Flash in addition to standard arguments of a platform:
flare({
"/": ({ request, env, context, params, errors, ...}) => ...
});
You can replace a handler with a value if you don’t refer to any argument;
flare({
"/": () => "Hello",
});
can be rewritten as
flare({
"/": "Hello",
});
Responses
You can use syntax sugar to create a response with a specified status. You can omit it for a response with the OK status;
flare({
"/": "Hello",
});
flare({
"/": { 200: "Hello" },
});
are equivalent to:
flare({
"/": new Response("Hello", { status: 200 }),
});
Formatters
You can add different formatters for each response status:
flare({
// [200] "Hello"
"/": "Hello",
}, {
// [400] "Not Found",
404: "Not Found",
// [500] { message: "Unexpected Error" }
500: "Unexpected Error",
}, {
format: {
error: { message: true },
400: { message: false },
},
});
Acknowledgment
Development of Flash is supported by Active Connector Inc..