⚛ A comprehensive framework for server-side applications

Overview

Ion Framework

A comprehensive framework for server-side applications. Being built on top of TypeScript, it surprisingly supports native Web APIs. It can also be used for REST/GraphQL and many others.

Quick start

"Welcome!"); await server.listen();">
// app.ts
import { Server } from "https://deno.land/x/[email protected]/mod.ts";

const server = new Server();

server.on("GET /", () => "Welcome!");

await server.listen();

Run server

deno run --allow-net app.ts

IonContext

{ const accessToken = req.headers["Access-Token"]; // your access token logic... if (accessToken === "X") { res.status = 201; return { id: 1, name: "Deno" }; } else { res.status = 401; } });">
server.on("POST /user", ({ req, res }: any) => {
  const accessToken = req.headers["Access-Token"];

  // your access token logic...
  if (accessToken === "X") {
    res.status = 201;
    return { id: 1, name: "Deno" };
  } else {
    res.status = 401;
  }
});

IonRequest

{ console.log(req.method); // GET console.log(req.url); // URL Object console.log(req.headers); // Request Headers console.log(req.query); // { language: "en" } console.log(req.params); // { bookId: "1" } console.log(req.body); // { name: "Deno" } (POST body: application/json only) });">
// www.example.com/books/1?language=en
server.on("GET /books/:bookId", ({ req }: any) => {
  console.log(req.method); // GET
  console.log(req.url); // URL Object
  console.log(req.headers); // Request Headers
  console.log(req.query); // { language: "en" }
  console.log(req.params); // { bookId: "1" }
  console.log(req.body); // { name: "Deno" } (POST body: application/json only)
});

IonResponse

{ res.headers["Access-Control-Allow-Origin"] = "*"; });">
server.on("GET /example", ({ res }: any) => {
  res.headers["Access-Control-Allow-Origin"] = "*";
});

Custom Events

console.log(x + y + z)); // 6 server.on("GET /bar", () => { server.dispatch("foo", 1, 2, 3); });">
server.on("foo", (x: number, y: number, z: number) => console.log(x + y + z)); // 6

server.on("GET /bar", () => {
  server.dispatch("foo", 1, 2, 3);
});

Custom Options

const server = new Server({ host: "127.0.0.0", port: 3000 }); // default 0.0.0.0:8080

Allowed Methods

null); server.on("PUT /", () => null); server.on("POST /", () => null); server.on("PATCH /", () => null); server.on("DELETE /", () => null); server.on("OPTIONS /", () => null);">
server.on("GET /", () => null);
server.on("PUT /", () => null);
server.on("POST /", () => null);
server.on("PATCH /", () => null);
server.on("DELETE /", () => null);
server.on("OPTIONS /", () => null);

Built-in events

console.log(host, port)); // on request (a.k.a middleware) server.on( "REQ", ({ req, res, onComplete }: any) => console.log(req, res, onComplete), );">
// on server listen
server.on("LISTEN", ({ host, port }: any) => console.log(host, port));

// on request (a.k.a middleware)
server.on(
  "REQ",
  ({ req, res, onComplete }: any) => console.log(req, res, onComplete),
);

Middleware Support

{ res.headers["Access-Control-Allow-Origin"] = "*" }) server.on("REQ", ({ onComplete }) => { const start - performance.now() onComplete(() => { const end = performance.now() console.log(`RequestTime: ${end - start}ms`) }) })">
// cors middleware
server.use(({ res }: any) => {
  res.headers["Access-Control-Allow-Origin"] = "*"
})

// alternative way (preferred)
server.on("REQ", ({ res }: any) => {
  res.headers["Access-Control-Allow-Origin"] = "*"
})

server.on("REQ", ({ onComplete }) => {
  const start - performance.now()
  onComplete(() => {
    const end = performance.now()
    console.log(`RequestTime: ${end - start}ms`)
  })
})

IonRefs (a.k.a global props)

{ console.log(refs.x) // 42 });">
server.refs.x = 42

server.on("GET /", ({ req, res}: any, refs: any) => {
  console.log(refs.x) // 42
});
You might also like...

Make drag-and-drop easier using DropPoint. Drag content without having to open side-by-side windows

Make drag-and-drop easier using DropPoint. Drag content without having to open side-by-side windows

Make drag-and-drop easier using DropPoint! DropPoint helps you drag content without having to open side-by-side windows Works on Windows, Linux and Ma

Dec 29, 2022

This is an application that entered the market with a mobile application in real life. We wrote the backend side with node.js and the mobile side with flutter.

HAUSE TAXI API Get Started Must be installed on your computer Git Node Firebase Database Config You should read this easy documentation Firebase-Fires

Nov 4, 2021

This plugin allows side-by-side notetaking with videos. Annotate your notes with timestamps to directly control the video and remember where each note comes from.

Obsidian Timestamp Notes Use Case Hello Obsidian users! Like all of you, I love using Obsidian for taking notes. My usual workflow is a video in my br

Jan 2, 2023

This Plugin is For Logseq. If you're using wide monitors, you can place journals, linked references, and journal queries side by side.

This Plugin is For Logseq. If you're using wide monitors, you can place journals, linked references, and journal queries side by side.

Logseq Column-Layout Plugin Journals, linked references, and journal queries can be placed side by side if the minimum screen width is "1850px" or mor

Dec 14, 2022

A modular front-end framework - inspired by the server-side and Web Components.

The NX framework Home page, Docs NX is a modular front-end framework - built with ES6 and Web Components. The building blocks of NX are the core, the

Dec 5, 2022

A server side rendering framework for Deno CLI and Deploy. 🦟 🦕

nat A server side rendering framework for Deno CLI and Deploy. Incorporating acorn, nano-jsx, and twind, it provides the tooling to provide a server c

Nov 17, 2022

Monolithic repo for api server, image server, web server

Onsecondary Market Deployed at https://market.onsecondary.com Monolithic repo for api server, image server, web server TODO -use a script to cull expi

Jan 11, 2022

generate a map server side and save/return it as png image

NFT map generator Request a new map to be generated with latitude and longitude params, for example http://localhost:3000/maps?lat=45.3579&lng=9.4427

Jul 12, 2022

Free, open-source client or server-side APIs to "lint" user input.

passbird Free, open-source client or server-side APIs to lint user input. Right now, you can check type for an email address i.e., either of disposabl

Dec 26, 2021
Releases(0.1.4)
Owner
null
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Fast and minimal JS server-side writer and client-side manager.

unihead Fast and minimal JS <head> server-side writer and client-side manager. Nearly every SSR framework out there relies on server-side components t

Jonas Galvez 24 Sep 4, 2022
Easy server-side and client-side validation for FormData, URLSearchParams and JSON data in your Fresh app 🍋

Fresh Validation ??     Easily validate FormData, URLSearchParams and JSON data in your Fresh app server-side or client-side! Validation Fresh Validat

Steven Yung 20 Dec 23, 2022
T3 is a client-side JavaScript framework for building large-scale web applications

Box has migrated using react, webpack, and the latest version of ECMAScript for our frontend projects as of 2018. We no longer support chan

Box 1.6k Dec 8, 2022
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)

?? Why this guide can take your testing skills to the next level ?? 46+ best practices: Super-comprehensive and exhaustive This is a guide for JavaScr

Yoni Goldberg 19.9k Jan 2, 2023
A comprehensive collection of useful tools developed with the help of Ethers.js to interact with the Ethereum Blockchain to develop great DeFi apps as quickly and easily as possible.

hudi-packages-ethersfactory How to install Installing with npm For more information on using npm check out the docs here. npm i @humandataincome/ether

HUDI 6 Mar 30, 2022
A comprehensive user sign-up/sign-in system

Nodejs Login System You want a comprehensive user sign-up/sign-in system I strongly suggest you take a look at this repo. The System Includes Welcome

Furkan Gulsen 8 Aug 1, 2022
LayerX-AI is a comprehensive platform to annotate and manage your machine learning data.

The AI Data Platform Annotate, Manage and Deploy Training Data The end-to-end AI data management platform that helps ML teams annotate, manage and dep

LayerX.ai 15 Dec 18, 2022
A Kubernetes monitoring tool to visualize large-scale activity and real-time comprehensive metrics within your cluster.

Armada A light-weight Kubernetes health monitoring tool. Summary Armada is an open-source tool for monitoring the health of your Kubernetes cluster. I

OSLabs Beta 81 Nov 2, 2022