Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tcpress-rs

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcpress-rs

A web framework written in Rust for javascript runtime.

  • 0.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

TCPress Experimental

NPM version

A web framework written in Rust for javascript runtime.

Installation and Usage in NodeJs

npm install tcpress-rs

or

yarn add tcpress-rs
import { TCPress, Response, Request } from 'tcpress-rs';
import net from 'net'

const port = 7070;
const host = '0.0.0.0';
let app = new TCPress();
let sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
// app
app.get("/", [async (req: Request, res: Response, next: Function)=>{
    req.set("test", "app state 1");
    res.header("Powered-By", "TCPress")
    // await sleep(100);
    next();
}, async (req: Request, res: Response)=>{
    console.log("state test", req.get("test"));
    // console.log("headers", req.headers());
    // console.log("raw_body", req.body().raw_body());
    res.status(200).json({
        status: 200,
        message: "Hello World",
    });
}])

// uncaughtException
process.on('uncaughtException', function (err) {
    console.log(err);
});

// Tcpress + NodejsTCP
const server = net.createServer();
function sv(){
    server.listen(port, host, () => {
        console.log('TCP Server is running on port ' + port +'.');
    });
    let  tc = 0
    server.on('connection', (sock) => {
        sock.on('data', (data) => {
            tc++
            let tm_lable = `lap_${tc}`
            console.time(tm_lable)
            app.http(data, (res: string)=>{
                sock.write(res);
                console.timeEnd(tm_lable)
            })
        });
    });
}
sv();

Keywords

FAQs

Package last updated on 17 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc