/packetify

framework for backend applications.

MIT LicenseMIT



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