Skip to content

fitchle/packetify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation



Logo

packet based asynchronous rest library for backend applications.

(read -> handle -> write)


📖 Documents 📖 · 🕷️ Report Bug 🕷️ · 💎 Request Feature 💎



Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. License
  5. Contact
  6. Contributors


📗 About The Project

Packetify is an understandable asynchronous library made to make your backend works easier (RESTAPI, jwt-token based authentication etc.)

Here's why:

  • It is an easy to use library, no need to waste time anymore!
  • It is an understandable library.
  • It is an asynchronous library.

Built With

In this project, `fastify` was used as server base, `zod` was used as validation, `@fastify/jwt` was used as authentication token library.

🌙 Getting Started

✨ Installation

  1. Install with npm or yarn
   npm install packetify

with yarn

   yarn add packetify
  1. Read the documents
  2. wake(), eat(), code(), sleep(), repeat() !

⚡ Usage

Creating Packetify Server

const packetify: Packetify = new Packetify()

// registering packets etc. 

packetify.listen(PORT) // Default Port: 45317

Creating Packets 📦

import { Packet } from 'packetify'

@PacketifyPacket("/my/path/:id",
 PacketMethod.GET, // PacketMethod.GET or PacketMethod.POST (under construction)
 z.object({ // Query Schema (zod)
    username: z.string().min(5).max(16),
    password: z.string()
}))
class MyPacket extends Packet {
    /**
     * 
     * READING QUERY & PARAMS DATA
     * 
    */
    read(data: any): void {
        this.data = data;
    }


    /**
     * 
     * HANDLING SOMETHINGS
     * 
     */
    handle(): void {
        console.log(this.data.query)
    }


    /**
     * 
     * RESPONSE (SUCCESSFUL)
     * 
     */
    write() {
        return {"asdasdasd": "asdasd"};
    }


    /**
     * 
     * ERROR HANDLING (zod query errors etc.)
     * 
     */
    onError(error: FastifyError, request: FastifyRequest): void {
        console.log(error)
        reply.send("ERROR!")
    }

    
}

For more examples, please refer to the Documentation

🔐 License

Distributed under the MIT License. See LICENSE for more information.

📞 Contact

🧑🏻‍💻 Contributors

About

framework for backend applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors