All Projects → ethanent → Vaxic

ethanent / Vaxic

Licence: mit
Node HTTP server framework

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vaxic

Proteus
Lean, mean, and incredibly fast JVM framework for web and microservice development.
Stars: ✭ 178 (+295.56%)
Mutual labels:  api, api-server, web-framework
Gaea
Gaea is a Gin-based web framework, reference gin https://github.com/gin-gonic/gin
Stars: ✭ 105 (+133.33%)
Mutual labels:  api, web-framework, http-server
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+14417.78%)
Mutual labels:  web-framework, http-server
Nei Toolkit
NEI 接口文档管理平台配套自动化工具
Stars: ✭ 781 (+1635.56%)
Mutual labels:  api, api-server
Zato
ESB, SOA, REST, APIs and Cloud Integrations in Python
Stars: ✭ 889 (+1875.56%)
Mutual labels:  api, api-server
Lithium
Easy to use C++17 HTTP Server with no compromise on performances. https://matt-42.github.io/lithium
Stars: ✭ 523 (+1062.22%)
Mutual labels:  api-server, http-server
Kretes
A Programming Environment for TypeScript & Node.js built on top of VS Code
Stars: ✭ 570 (+1166.67%)
Mutual labels:  web-framework, node-js
Goyave
🍐 Elegant Golang REST API Framework
Stars: ✭ 811 (+1702.22%)
Mutual labels:  api, web-framework
Cppwebframework
​The C++ Web Framework (CWF) is a MVC web framework, Open Source, under MIT License, using C++ with Qt to be used in the development of web applications.
Stars: ✭ 348 (+673.33%)
Mutual labels:  http-server, webapp
Server
Serve your Rubix ML models in production with scalable stand-alone model inference servers.
Stars: ✭ 30 (-33.33%)
Mutual labels:  api, http-server
Farwest
Framework for building RESTful HATEOAS-driven applications.
Stars: ✭ 18 (-60%)
Mutual labels:  web-framework, http-server
Spyne
A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.
Stars: ✭ 992 (+2104.44%)
Mutual labels:  api, api-server
Diet
A tiny, fast and modular node.js web framework. Good for making fast & scalable apps and apis.
Stars: ✭ 394 (+775.56%)
Mutual labels:  api, http-server
Para
Open source back-end server for web, mobile and IoT. The backend for busy developers. (self-hosted or hosted)
Stars: ✭ 389 (+764.44%)
Mutual labels:  api, api-server
Takes
True Object-Oriented Java Web Framework
Stars: ✭ 670 (+1388.89%)
Mutual labels:  web-framework, http-server
Ocrserver
A simple OCR API server, seriously easy to be deployed by Docker, on Heroku as well
Stars: ✭ 359 (+697.78%)
Mutual labels:  api, api-server
Graphiti
Stylish Graph APIs
Stars: ✭ 783 (+1640%)
Mutual labels:  api, api-server
Kuzzle
Open-source Back-end, self-hostable & ready to use - Real-time, storage, advanced search - Web, Apps, Mobile, IoT -
Stars: ✭ 991 (+2102.22%)
Mutual labels:  api-server, node-js
Comet
Modern PHP framework for building blazing fast REST APIs, CRUDs and microservices
Stars: ✭ 328 (+628.89%)
Mutual labels:  api, http-server
Allorigins
👽 Pull contents from any page as JSON via API
Stars: ✭ 343 (+662.22%)
Mutual labels:  api, node-js

vaxic logo


The ultra-light superpower Node web framework

GitHub | NPM

Install

npm install --save vaxic

Basic usage

const Vaxic = require('vaxic')

const app = new Vaxic()

app.add('GET', '/getEndpoint', (req, res) => {
	res.writeHead(200)
	res.end('Hello.')
})

app.listen(80, '0.0.0.0')

Extensions

Extensions are super powerful overlays you can add onto your app to add new functionality!

Two built-in extensions exist. One is called static. It can be used to serve static files.

app.use(Vaxic.static('/site'))

The other built-in extension is called route. It can be used to route requests.

app.use(Vaxic.route)

app.add('POST', async (req, res) => {
	try {
		await res.route({
			'origin': 'http://localhost:5135'
		})
	}
	catch (err) {
		res.writeHead(500)
		res.end('Failed to route!')
	}
})

Handles

Handles are methods you provide to be used as request handlers for specific requests.

You can target them by request method or by URL (or both or neither!)

Creating handles is as easy as...

app.add('POST', (req, res) => {
	// This handle handles all POST requests.

	console.log(req.body)
})

Regular expressions in handles

Regular expressions can be used as handle URL targets!

app.add('GET', /^\/api/, (req, res) => {
	// This handle handles all GET requests to /api and all subpaths of /api!
})

The Request and Response classes, extended

Vaxic request and response objects passed to handlers extend the http.ClientRequest and http.ServerResponse objects.

How Vaxic changes ClientRequest

Vaxic adds the body property to requests which contain a body. (Ex. POST requests with bodies.)

Vaxic changes the url property of ClientRequest by URL parsing it into a URL object. (Without its querystring parsed.)

How Vaxic changes ServerResponse

Vaxic adds the endGzip, endDeflate, and endCompressed methods to the http.ServerResponse object.

ServerResponse.endGzip(body, statusCode, ?headers, ?cb)

ServerResponse.endDeflate(body, statusCode, ?headers, ?cb)

ServerResponse.endCompressed(body, ?statusCode:200, ?headers, ?cb)

All of the compression methods add the appropriate content-encoding header. Use endCompressed to autodetect the preferred compression method of the client based on the accept-encoding header.

Using another HTTP server package (such as HTTPS)

If you'd like to use your Vaxic app with another HTTP server such as Node's built-in HTTPS module, you can do so using app.serverHandler.

For example:

const https = require('https')

https.createServer(app.serverHandler).listen(80)

Creating extensions

Making extensions is easy! Extensions are just methods to which requests are passed before (or instead of) being handed over to handles.

(req, res, next) => {
	res.setHeader('Powered-By': 'Vaxic-Engine')
	next()
}

Calling next() in extension handler methods is important because it allows the request to propagate to the next applicable handler. (An extension or handle.)

Async / Promise handler methods for handles and extensions

Async or Promise-returning functions may be used as handlers in handles and extensions.

If a promise returned by a Promise-based handler is rejected, the rejection will be caught and a promiseHandleRejection (for handles) or a promiseExtensionRejection (for extensions) will be emitted with the error from the Vaxic instance.

Ex. for Async handle handlers:

app.add('GET', '/async', async function (req, res) {
	// Perform await / other logic if desired and handle request.
})

Ex. for async extension handlers:

app.use(async function (req, res, next) {
	// Perform await / other logic if desired and handle request.
})
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].