1.4.0 • Published 3 months ago

blazze v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Screenshot 2024-01-21 153036-modified

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.

Features

  • 😎 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

How to start?

  • 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 route user.

    // 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
        });
    }

Upcoming Features

  • GraphQl integration
  • Elegant Middlewares
  • Rust binding for faster performance
  • Templating Engine
  • Web Sockets & Webhooks
  • Polling

Contribute to Blazze

Read the Contribution guidlines to begin.

Give Blazze a Star ❤️⭐

1.4.0

3 months ago

1.3.5

3 months ago

1.3.4

4 months ago

1.3.3

4 months ago

1.3.2

4 months ago

1.3.0

4 months ago

1.2.2

4 months ago

1.2.0

4 months ago

1.1.4

4 months ago

1.2.1

4 months ago

1.1.35-dev

4 months ago

1.0.3

4 months ago

1.1.34-dev

4 months ago

1.1.33-dev

4 months ago

1.1.29-dev

4 months ago

1.1.32-dev

4 months ago

1.1.30-dev

4 months ago

1.1.31-dev

4 months ago

1.1.26-dev

4 months ago

1.1.25-dev

4 months ago

1.1.28-dev

4 months ago

1.1.24-dev

4 months ago

1.1.23-dev

4 months ago

1.1.23

4 months ago

1.1.22

4 months ago

1.1.27-dev

4 months ago

1.1.20-dev

4 months ago

1.1.18-dev

4 months ago

1.1.21-dev

4 months ago

1.1.19-dev

4 months ago

1.1.16-dev

4 months ago

1.1.15-dev

4 months ago

1.1.13-dev

4 months ago

1.1.14-dev

4 months ago

1.1.17-dev

4 months ago

1.1.9-dev

5 months ago

1.1.11-dev

4 months ago

1.1.7-dev

5 months ago

1.1.2-dev

5 months ago

1.1.4-dev

5 months ago

1.1.8-dev

5 months ago

1.1.10-dev

4 months ago

1.1.6-dev

5 months ago

1.1.12-dev

4 months ago

1.1.3-dev

5 months ago

1.1.5-dev

5 months ago

1.1.0-dev

5 months ago

1.0.0-dev

5 months ago