Coder Social home page Coder Social logo

papaya.js's Introduction

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. ‼️

papaya.js's People

Contributors

stuncs69 avatar sympact06 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

sympact06

papaya.js's Issues

Optional object keys

POST routes with optional keys like "Required" or "possible" for inputs, maybe queries?

Statistics

Papaya connects to a centralized websocket, which will display "Servers currently running Papaya instances: "
& Every time a new papaya.js project is created using npm create papaya@latest, add 1 to the amount of Papaya projects existing, displayed on the default page as "Existing papaya projects". The default page being the page that papaya creates upon initializing the project

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.