New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

yeps-response

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yeps-response

YEPS response

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

YEPS Response

NPM

npm version Build Status Coverage Status Linux Build Windows Build

Dependency Status devDependency Status NSP Status

Known Vulnerabilities License GitHub stars GitHub forks GitHub issues Twitter

How to install

npm i -S yeps-response

How to use

You can put any type of response data: value, promise, error.

Without response

const App = require('yeps');

const error = require('yeps-error');
const logger = require('yeps-logger');
const server = require('yeps-server');

const app = new App();

app.all([
  error({ isJSON: true }),
  logger(),
]);

app.then(async (ctx) => {
  ctx.res.end('data');
  
  return Promise.reject();
});

server.createHttpServer(app);

With response

const App = require('yeps');

const error = require('yeps-error');
const logger = require('yeps-logger');
const server = require('yeps-server');

const response = require('yeps-response');

const app = new App();

app.all([
  error({ isJSON: true }),
  logger(),
]);
app.then(response());

app.then(async (ctx) => {
  return ctx.response.resolve('data');
});

server.createHttpServer(app);

Custom response

const App = require('yeps');

const error = require('yeps-error');
const logger = require('yeps-logger');
const server = require('yeps-server');

const Response = require('yeps-response/response');

const app = new App();

app.all([
  error({ isJSON: true }),
  logger(),
]);

app.then(async (ctx) => {
  const response = new Response(ctx);

  return response.resolve('data');
});

server.createHttpServer(app);

Redirect

app.then(async (ctx) => {
  return ctx.response.redirect(url = '/', code = 301);
});

Custom redirect

app.then(async (ctx) => {
  const response = new Response(ctx);

  return response.redirect(url = '/', code = 301);
});

Reject

If you need to send request and finish response

app.then(async (ctx) => {
  return ctx.response.reject(data);
});

YEPS documentation

Keywords

promise

FAQs

Package last updated on 09 Dec 2017

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