0.0.19-b • Published 1 month ago

papaya.js v0.0.19-b

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

Bun TypeScript GitHub repo size npm package minimized gzipped size (select exports)

papaya.js

Webserver made for TypeScript, using TypeScript.

💯 What's new?

🔥 Dynamic paths 🐶 Pug SSR support 👏 Split classes in files for easier maintainability

Usage

// index.ts
import { PapayaServer } from "papaya.js";

const server = new PapayaServer();

// Middleware
server.use(function testWare(req, res) {
    return new Promise((resolve, reject) => {
        resolve("TestData")
    })
})

server.listen();

// ./server/get/index.ts
import {  renderPublic, PapayaRoute } from "papaya.j"

export default class GetIndex extends PapayaRoute {
    path = "/";
    callback = () => {
        return new Promise((resolve) => {
            resolve(renderPublic("index.html"));
        })
    };
}

Functionality

  • Full Bun support
    • Made using standard Node.js libraries, purposed to be used with Bun
  • Asynchronous and promised
    • Middleware and routes are made using promises, ensuring a blazingly fast server.
    • Public files are served asynchronously alongside coded paths.
    • Easy filesystem layout instead of spaghetti-code files.

Initiate a new project

To initiate a new project, make a new directory:

$ mkdir papaya-project
$ cd papaya-project

Set-up a new project using NPM:

$ npm create papaya@latest

Run your brand new project:

$ bun index.ts

Due to the nature of the framework, you can exclusively use Bun for now.

File structure

  • 📁 server
    • 📁 get - GET endpoint controller files.
      • 🗒️main.ts - example GET controller.
    • 📁 post - POST endpoint controller files.
      • 🗒️hello.ts - example POST controller
    • 📁 public - Public files.
      • 🗒️moveButton.js - example served file.
      • 🗒️adminPage.html - example served file.
  • 🗒️entry.ts - Entry point for server

‼️ Every folder MUST exist, but can be empty. ‼️

0.0.19-b

1 month ago

0.0.19

1 month ago

0.0.12

7 months ago

0.0.13

7 months ago

0.0.14

7 months ago

0.0.15

7 months ago

0.0.16

7 months ago

0.0.17

5 months ago

0.0.18

5 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago