You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@curveball/links

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@curveball/links

Weblinking Middelware for curveball

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
4
Created
Source

This Curveball middleware helps you parse and generate HTTP Weblinks.

Any links passed in a request via the Link header will now be exposed in ctx.request. Similarly, if a link was set in ctx.response.links, it will automatically be encoded as a Link header in the HTTP response.

Lastly, if the request body was a HAL object, and it has a _links property, these links will also be added to ctx.response.links.

Installation

npm i @curveball/links

Usage

import { Application, Context } from '@curveball/core';
import links from '@curveball/links';
import bodyParser from '@curveball/bodyparser';


const app = new Application();

// If you would like to parse HAL links, the bodyParser must be loaded first.
app.use(bodyParser());

app.use(links());

app.use( (ctx: Context) => {

  // Read a Link from a HAL body or Link header
  console.log(ctx.request.links.get('author'));

  // Write a Link header
  ctx.response.links.set({ rel: 'alternate' , type: 'text/csv', href: '/export.csv'});

});

Keywords

http

FAQs

Package last updated on 25 Jan 2024

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