Socket
Socket
Sign inDemoInstall

restyts

Package Overview
Dependencies
3
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

restyts

Lightweight small library for REST api. Have all kind of features out of the box!


Version published
Maintainers
1
Weekly downloads
1
decreased by-50%
Install size
796 kB

Weekly downloads

Readme

Source

RestyTS

Lightweight small library for REST api. Have all kind of features out of the box!

Install

npm install restyts

Usage

Typescript:

import { RestyApp } from 'restyts';

const app = new RestyApp({
    logger: console,
    showRoutes: true,
    port: 8080,
    createBodyData: true,
    detectResponseTime: true
});
app.use((req: IRestyRequest, res: IRestyResponse , next: IRestyNextFunction) => {
    // Do any kind of work;
    next();
});

app.get('/:id', (req: IRestyRequest, res: IRestyResponse , next: IRestyNextFunction) => {
    console.log(req.body, req.query, req.params, req.files);
    console.log(req.currentRoute);
    res.send.OK({"isWorking": true}, "Working!");
})

app.use((req: IRestyRequest, res: IRestyResponse , next: IRestyNextFunction, err: any) => {
    // Failed, received some error;
    res.send.SERVERERROR(err);
})

app.start();

Options

OptionExplanationdefault
loggerthis property can receive any logger that have "error" and "log" functionsnone
showRoutescan have a list of all routes with their properties printed to the loggerfalse
portthe port the server will run on8000
createBodyDataparse body data, json/multipart/urlencoded with files datafalse
detectResponseTimeshow in milliseconds how much time the whole endpoint took in the loggerfalse

detectResponseTime

that how it looks when you set it up to true:

[28/5/2020 08:36:47:59]: POST /:id [STARTED]
[28/5/2020 08:36:47:65]: POST /:id [ENDED] -> took: 0.006s

Keywords

FAQs

Last updated on 17 Jul 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc