All Projects → etienne-martin → sudden.js

etienne-martin / sudden.js

Licence: MIT license
A high-level API framework built on top of express.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to sudden.js

Ixwebsocket
websocket and http client and server library, coming with ws, a command line swiss army knife utility
Stars: ✭ 204 (+1357.14%)
Mutual labels:  http-server
Criollo
A powerful Cocoa web framework and HTTP server for macOS, iOS and tvOS.
Stars: ✭ 229 (+1535.71%)
Mutual labels:  http-server
Mongols
C++ high performance networking with TCP/UDP/RESP/HTTP/WebSocket protocols
Stars: ✭ 250 (+1685.71%)
Mutual labels:  http-server
Restrserve
R web API framework for building high-performance microservices and app backends
Stars: ✭ 207 (+1378.57%)
Mutual labels:  http-server
Perfecttemplate
Empty Perfect Starter Project.
Stars: ✭ 221 (+1478.57%)
Mutual labels:  http-server
Serve
a static http server anywhere you need one.
Stars: ✭ 233 (+1564.29%)
Mutual labels:  http-server
Miniserve
🌟 For when you really just want to serve some files over HTTP right now!
Stars: ✭ 2,894 (+20571.43%)
Mutual labels:  http-server
cpphttpstack
c++ api for http client & server
Stars: ✭ 30 (+114.29%)
Mutual labels:  http-server
Servr
A simple HTTP server in R
Stars: ✭ 228 (+1528.57%)
Mutual labels:  http-server
Andserver
🍒 Web server and web framework of Android platform.
Stars: ✭ 2,932 (+20842.86%)
Mutual labels:  http-server
Tinywebserver
🔥 Linux下C++轻量级Web服务器
Stars: ✭ 4,720 (+33614.29%)
Mutual labels:  http-server
Aiohttp Wsgi
WSGI adapter for aiohttp.
Stars: ✭ 218 (+1457.14%)
Mutual labels:  http-server
App Servers
App Servers benchmarked for: Ruby, Python, JavaScript, Dart, Elixir, Java, Crystal, Nim, GO, Rust
Stars: ✭ 238 (+1600%)
Mutual labels:  http-server
Swoole Bundle
Symfony Swoole Bundle
Stars: ✭ 201 (+1335.71%)
Mutual labels:  http-server
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (+1707.14%)
Mutual labels:  http-server
Fiery
A flexible and lightweight web server
Stars: ✭ 203 (+1350%)
Mutual labels:  http-server
Router.cr
Minimum High Performance Middleware for Crystal Web Server.
Stars: ✭ 231 (+1550%)
Mutual labels:  http-server
EthernetWebServer SSL
Simple TLS/SSL Ethernet WebServer, HTTP Client and WebSocket Client library for for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52 and RASPBERRY_PI_PICO boards using Ethernet shields W5100, W5200, W5500, ENC28J60 or Teensy 4.1 NativeEthernet/QNEthernet. It now supports Ethernet TLS/SSL Client. The library supports …
Stars: ✭ 40 (+185.71%)
Mutual labels:  http-server
teapot
Utilities for working with HTTP status codes, errors, and more
Stars: ✭ 14 (+0%)
Mutual labels:  http-server
Evpp
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.
Stars: ✭ 2,850 (+20257.14%)
Mutual labels:  http-server

Sudden.js

Coveralls github MIT License npm version npm monthly downloads

A high-level API framework built on top of express.

This project is heavily inspired by Next.js for its simplicity and ease of use.

demo

How to use

Setup

Install it in your project:

npm install sudden

and add a script to your package.json like this:

{
  "scripts": {
    "dev": "sudden",
    "build": "sudden build",
    "start": "sudden start"
  }
}

After that, the file-system is the main API. Every .js file becomes a route that gets automatically processed.

Populate ./endpoints/index.js inside your project:

export default (req, res) => {
  res.json({
    hello: "world!"
  });
};

and then just run npm run dev and go to http://localhost:3000. To use another port, you can run npm run dev -p <your port here>.

So far, we get:

  • Automatic transpilation (with webpack and babel)
  • Automatic route reloading
  • Dynamic routes support
  • API middlewares
  • Built-in error handling
  • Built-in TypeScript support
  • Static endpoints support

Automatic transpilation

Write modern javascript right away without configuring webpack and babel.

Dynamic route support

// TODO: document this thing

Built-in middlewares

export default (req, res) => {
  const body = req.body; // The request body
  const query = req.query; // The url querystring
  const cookies = req.cookies; // The passed cookies

  res.json({
    body,
    query,
    cookies
  });
};

Custom middlewares

You can add your own middleware by extending the default router with a special file called ./endpoints/_router.js as shown below:

import cors from "cors";

export default router => {
  router.use(cors());
};

Built-in error handling

404s and execeptions are handled gracefully out of the box. Any unexpected error will return a generic 500 error to avoid leaking sensitive information. The actual error will be logged in the console.

Error handling

You can add your error handler with a special file called ./endpoints/_error.js as shown below:

export default (err, req, res) => {
  if (err.message === "some error") {
    // Do something with the error
  }
};

TypeScript

Sudden.js provides an integrated TypeScript experience out of the box.

Convert your existing endpoints from .js to .ts and restart your development server with sudden dev (normally npm run dev).

Sudden.js will guide you through installing the necessary packages to complete setup.

Static endpoints support

Static endpoints can be created by populating the ./endpoints folder with json files. The content of those json files will be sent as the response body:

{
  "ping": "pong"
}

HTTP verbs

By default, files in the ./endpoints folder will respond to any type of request. Add the HTTP verb as a suffix to your endpoint's name to allow only a specific verb like so ./endpoints/user.post.js.

The supported HTTP verbs are get, post, put, delete and patch.

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].