Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
restyts
Advanced tools
Readme
Lightweight small library for REST api. Have all kind of features out of the box!
npm install restyts
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();
Option | Explanation | default |
---|---|---|
logger | this property can receive any logger that have "error" and "log" functions | none |
showRoutes | can have a list of all routes with their properties printed to the logger | false |
port | the port the server will run on | 8000 |
createBodyData | parse body data, json/multipart/urlencoded with files data | false |
detectResponseTime | show in milliseconds how much time the whole endpoint took in the logger | false |
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
FAQs
Lightweight small library for REST api. Have all kind of features out of the box!
The npm package restyts receives a total of 23 weekly downloads. As such, restyts popularity was classified as not popular.
We found that restyts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.