All Projects → jesusvilla → natural

jesusvilla / natural

Licence: GPL-3.0 license
Fastest Framework for NodeJS. Written in pure ES6+

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to natural

cloudflare-worker-router
A super lightweight router (1.3K) with middleware support and ZERO dependencies for CloudFlare Workers.
Stars: ✭ 144 (+380%)
Mutual labels:  workers, cloudflare, cloudflare-workers
cloudflare-worker-graphql-ws-template
A template for WebSockets powered Cloudflare Worker project using graphql-ws
Stars: ✭ 21 (-30%)
Mutual labels:  workers, cloudflare, cloudflare-workers
workers-jwt
Generate JWTs on Cloudflare Workers using the WebCrypto API
Stars: ✭ 67 (+123.33%)
Mutual labels:  workers, cloudflare, cloudflare-workers
DNS-over-Discord
A 1.1.1.1 DNS resolver built for Discord
Stars: ✭ 228 (+660%)
Mutual labels:  cloudflare, cloudflare-workers
worker-template-postgres
Reference demo and modified PostgreSQL driver to connect Cloudflare Workers to a relational database.
Stars: ✭ 75 (+150%)
Mutual labels:  workers, cloudflare
html
HTML templating and streaming response library for Service Worker-like environments such as Cloudflare Workers.
Stars: ✭ 41 (+36.67%)
Mutual labels:  workers, cloudflare-workers
Cfworker
A collection of packages optimized for Cloudflare Workers and service workers.
Stars: ✭ 152 (+406.67%)
Mutual labels:  workers, cloudflare
miniflare
🔥 Fully-local simulator for Cloudflare Workers
Stars: ✭ 2,811 (+9270%)
Mutual labels:  cloudflare, cloudflare-workers
workers-unsplash-api
Serverless API for requesting images from Unsplash's API, designed for use with a React frontend
Stars: ✭ 20 (-33.33%)
Mutual labels:  cloudflare, cloudflare-workers
slshx
⚔️ Strongly-typed Discord commands on Cloudflare Workers
Stars: ✭ 163 (+443.33%)
Mutual labels:  cloudflare, cloudflare-workers
cfw-easy-utils
An in-depth library to assist with common tasks with CF Workers. Includes utils for responses, cookies, and more!
Stars: ✭ 52 (+73.33%)
Mutual labels:  cloudflare, cloudflare-workers
Agoo
A High Performance HTTP Server for Ruby
Stars: ✭ 679 (+2163.33%)
Mutual labels:  fast, webserver
inkrss
Notify when rss feeds are updated | RSS 更新通知
Stars: ✭ 234 (+680%)
Mutual labels:  cloudflare, cloudflare-workers
worker-auth-providers
worker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers.
Stars: ✭ 85 (+183.33%)
Mutual labels:  cloudflare, cloudflare-workers
vite-plugin-cloudflare
🔥Building Cloudflare workers is faster and easier using vite-plugin-cloudflare with node builtins like process and stream
Stars: ✭ 108 (+260%)
Mutual labels:  workers, cloudflare
Google Drive Index
Index Google Drive Files Easily and Free
Stars: ✭ 205 (+583.33%)
Mutual labels:  workers, cloudflare
IPFS PHOTO SHARE
💰用甚嚒服务器,ServerLess搭建一个图片分享站点!| 基于CloudFlareWorker无服务器函数和IPFS去中心化存储的图片分享网站
Stars: ✭ 76 (+153.33%)
Mutual labels:  cloudflare, cloudflare-workers
Serverless Cloudflare Workers
Serverless provider plugin for Cloudflare Workers
Stars: ✭ 114 (+280%)
Mutual labels:  workers, cloudflare
Worker Typescript Template
ʕ •́؈•̀) TypeScript template for Cloudflare Workers
Stars: ✭ 129 (+330%)
Mutual labels:  workers, cloudflare
viteflare
Cloudflare workers meet Vite plugins
Stars: ✭ 35 (+16.67%)
Mutual labels:  workers, cloudflare

Natural

Donate

Fastest Framework for Node.js. Written in pure javascript (ES6+)

  • Created with the least possible code.
  • Pure native HTTP Server.
  • Based on Polka, Restana, Fastify, Express (for the creation of the Router).
  • Based on NestJS (framework concepts and abstraction).
  • Support Serverless: Workers Cloudflare, AWS Lambda, Google Cloud Functions

Requirements

Node.js v14+ (v16+ for Workers)

Installation (/example)

$ npm i -S natural-framework

Example

View examples folder

NaturalRouter (Local Server)

import NaturalRouter from 'natural-framework/router'
import * as HttpServer from 'natural-framework/server/uws'
// import * as HttpServer from 'natural-framework/server/node' // for Node.js native application

function createRoutes (router) {
  router
    .get('/', (_, response) => {
      response.end('')
    })
    .get('/user/:id', (request, response) => {
      response.end(request.params.id)
    })
    .post('/user', (request, response) => {
      response.end('')
    })
    .route({
      url: '/test/simple/:id',
      method: 'GET',
      type: 'json',
      handler: (request, response) => {
        // request.params, request.query, request.body, request.files
        response.send({ id: request.params.id }, 'json')
      }
    })

  /* router.route({
    url: '/meet/auth',
    method: 'GET',
    type: 'json',
    handler: (request, response) => {
      const params = Object.assign({}, request.params, request.query)
      response.send(params)
    }
  }) */

  // or
  /*
  router.on('GET', '/station/test/simple/:id', (request, response) => {
    // request.params, request.query, request.body, request.files
    response.send({ id: request.params.id }, 'json')
  })
  */
}

async function bootstrap () {
  const router = new NaturalRouter({
    server: HttpServer
    /* ssl: {
      key: path.join(__dirname, './security/cert.key'),
      cert: path.join(__dirname, './security/cert.pem')
    } */
  })
  try {
    createRoutes(router)
    const port = await router.listen(3000)
    console.log(`Listen http://localhost:${port}`)
  } catch (error) {
    console.log('Error:', error)
  }
}

bootstrap()

NaturalRouter (Serverless)

Workers Cloudflare, AWS Lambda, Google Cloud Functions (Yeah, Same code for any serverless!!)

import NaturalRouter from 'natural-framework/router'
import * as HttpServer from 'natural-framework/server/worker' // for Workers Cloudflare
// import * as HttpServer from 'natural-framework/server/lambda' // for AWS Lambda
// import * as HttpServer from 'natural-framework/server/function' // Google Cloud Functions

const router = new NaturalRouter({
  server: HttpServer
}

router
  .get('/', (_, response) => {
    response.end('')
  })
  .get('/user/:id', (request, response) => {
    response.end(request.params.id)
  })
  .post('/user', (request, response) => {
    response.end('')
  })
  .route({
    url: '/test/simple/:id',
    method: 'GET',
    type: 'json',
    handler: (request, response) => {
      // request.params, request.query, request.body
      return { id: request.params.id }
      // or: response.send({ id: request.params.id }, 'json')
    }
  })

  /* router.route({
    url: '/test/simple/:id',
    method: 'POST',
    type: 'json',
    handler: (request, response) => {
      const params = Object.assign({}, request.params, request.query, request.body)
      response.send(params)
    }
  })

  // or

  router.on('POST', '/test/simple/:id', (request, response) => {
    const params = Object.assign({}, request.params, request.query, request.body)
    response.send(params)
  })

  */

export default {
  fetch: router.run()
}

NaturalJS

import NaturalJS from 'natural-framework'
import * as HttpServer from 'natural-framework/server/uws'
import station from './station'

async function bootstrap () {
  const app = new NaturalJS({
    server: HttpServer,
    modules: {
      station
    }
  })

  try {
    const port = await app.listen(3000)
    console.log(`Listen http://localhost:${port}`)
  } catch (error) {
    console.log('Error:', error)
  }
}

bootstrap()

Definitions

Controller

import { Controller, Accepts, Get, TypeJson } from 'natural-framework/common'

// Registered route: /test
@Controller('test')
class Test {
  // Without path
  // Registered route: /test/
  @Get()
  main () {
    // Return string, automatic detected by Natural
    return 'Welcome'
  }

  // With path
  // Registered route: /test/simple
  @Get('simple')
  getSimple () {
    // Return string
    return 'Simple Main'
  }

  // With path, with params
  // Registered route: /test/simple/:id
  @Get('simple/:id')
  // With arguments: id
  @Accepts('id')
  // Return type: json (application/json)
  @TypeJson()
  getSimpleId (id) {
    return { id, type: typeof id }
  }

  // With path, with params
  @Get('validator/:id')
  // With arguments with validator: id (only type number)
  @Accepts({ name: 'id', type: 'number' })
  // Return type: json (application/json)
  @TypeJson()
  getIdWithValidator (id) {
    return { id, type: typeof id }
  }
}

export default Test

Use (Contribute)

Start NaturalRouter (/example)

$ npm run dev:router

Start NaturalJS (/example)

$ npm run dev

Benchmarks

Coming soon...

ToDo

  • Providers: Services, Models, ...

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

paypal

Thanks

Made with love for all nodejs developers Inspired in my family

License

GPL-3.0 License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].