Write APIs in TypeScript with zero configuration, no boilerplate, request caching, and blazingly fast. Blazze.js is a powerful and lightweight JavaScript framework designed to simplify web development. With a focus on simplicity and performance, Blazze.js provides a set of features that make building web applications a breeze 🎐.
-
😎 Request Caching: - Blazze handles caching automatically in both Production and Dev Environments. In production it is obviously necessary to optimize large computations however, request caching is taken care of in dev mode as well by Blazze to provide a smooth developer experience, there is no need to revalidate the cache manually Blazze handles everything under the hood.
-
🏎️ Powered by SWC: - Blazze leverages Rust-based tool: Speedy Web Compiler to transpile Typescript files, so there is negligible waiting time after file changes.
-
🐣 Easy Setup: - Hit
npx blazz-init
to start building your projects, you'll be asked a few questions for configuring Blazze & that's it Blazze will set up the project for you. -
💪 TypeScript: - Out-of-the-box TS support, no configurations, and environment setup, just get started directly.
-
📂 Directory based Routing: - Keep the logic separated without any setup. Routes are based on the directory structure. ex: you will create a dir
user
inside of which you can add your logic for various request methods viz:GET
,POST
,PUT
,PATCH
,DELETE
. -
🚀 Fast & Robust: - Built on top of Express JS and Helmet JS, security and efficiency by default.
-
💫 No Boiler Plate Code: - Install init and start, Nothing else 🚀
-
🔥 Build Optimization: - Makes a single optimized Expressjs bundle for your complete app
-
Install blazze
npm i blazze@latest
-
Run the below command in the terminal.
npx blazze-init
-
You will be asked a few questions to configure
blazze.config.js
PS C:\Users\yaksh\bltest> npx blazze-init ? What is your project named? myFuckingAPIS ? What will be the root endpoint for your project? api/v5.1/users/i ? Would you like to use TypeScript? yes ? Which port should the server listen to? 3000 ? Where would you like to keep your static content like HTML and PNG files? public ? Would you like to enable request caching? (Experimental) yes ✔ Configuring your Blazze App Run commands: - npm i - npm run dev Success ! Created myFuckingAPIS at C:\Users\yaksh\bltest You are ready to Blazze 🚀. Refer to docs at https://github.com/Axnjr/Blazze.js/main/README.md.
-
Create your API routes in the root-endpoint directory
-
Each route can have 5 HTTP method files viz: GET, POST, PUT, PATCH, DELETE
-
Project Structure
myFuckingAPIS ├── api/v5.1/users/i (root-endpoint) │ ├── Route-1 │ │ ├── GET.ts │ │ ├── POST.ts │ │ ├── PUT.ts │ │ ├── DELETE.ts │ │ ├── PATCH.ts │ └── Other-routes / ... ├── blazze (for typescript) ├── cache (if enabled) ├── public (static-root) ├── blaze.config.js (from blazze-init) ├── package.json ├── packagelock.json └── ...
-
Each file handles specific API request methods
-
You need to export a default normal function from each file
-
These functions get Express Request and Response objects as parameters
-
For nested routes use the "@" symbol ex:
new/subs/ppl
will be ->new@subs@ppl
which will have its respective logic -
This is to avoid deep recursive file watching and being more performant for the system
-
Dynamic routes start with an underscore "_" ex:
api/v1/_users
-
That's it you are ready to Blazze 🚀, below is an example of
get
request for dynamic routeuser
.// api/v1/_user/GET.ts import { Request, Response } from "express" export default async function (req:Request, res:Response){ let data, r = req.query.q try { data = await fetch(`https://freeaiapi.vercel.app/api/Sentiments?query='${r}'`) } catch (error) { data = error } let t = await data.json() res.json({ Data:t, Query:r }); }
- GraphQl integration
- Elegant Middlewares
- Rust binding for faster performance
- Templating Engine
- Web Sockets
Read the Contribution guidlines to begin.