0x7d8 / AERO-TS

A Lightweight Webserver for NodeJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to aero-ts πŸ‘‹

Version Documentation Maintenance Socket Badge

Easy and Lightweight Way to create an Advanced Web Server in Node.js

🏠 Homepage

Install

using npm

npm i aero-ts

using yarn

yarn add aero-ts

using pnpm

pnpm add aero-ts

Features

  • Compression Support
  • Multithreading Support
  • Websocket Support (soon)
  • Middleware Support (soon)
  • HTTPS Support
  • Async Support

Usage

Initialize Server

/**
 * NOTE:
 * This Project is not finished at all and
 * may not be a good idea to use right now.
*/

import aero from "aero-ts"
// or
const aero = require("aero-ts")


const server = new aero.Server({
  port: 3000,
  bind: '0.0.0.0',
  debug: true
  threading: {
    available: 2,
    automatic: true,
    sync: 20000
  }
})

server.routes
  .add('GET', '/', (ctx) => {
    ctx.print('Hello! Im running on the aero-ts beta...')
  })
  .add('GET', '/<username>', (ctx) => { // This is a placeholder, basically /anything will match to this except if there is a static route
    ctr.print('Hello ${ctx.params.get('username')}! How are you?')
  })
  .redirect('/cool', 'https://rjansen.de') // Redirect from /cool to https://rjansen.de
  .prefix('/api')
    .add('GET', '/', (ctx) => {
      ctx.print('You are currently on /api even though the method says / because of the Prefix')
    })
    .prefix('/v2')
      .add('GET', '/', (ctx) => {
        ctx.print('This is the v2 Homepage')
      })

server.start()

Author

πŸ‘€ 0x4096

🀝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check out the issues.

Show your support

Give a Star if this project helped you!

πŸ“ License

Copyright Β© 2023 0x4096.
This project is MIT licensed.

About

A Lightweight Webserver for NodeJS

License:MIT License


Languages

Language:TypeScript 100.0%