Socket
Socket
Sign inDemoInstall

@authelion/api-adapter

Package Overview
Dependencies
73
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @authelion/api-adapter

Authelion http & socket server adapter package for api module.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@authelion/api-adapter 🌉

npm version main codecov Known Vulnerabilities

The main propose of this package, is to provide middlewares for microservices, which are based on a http (express) or (web-) socket (socket.io) server.

Table of Contents

Installation

npm install @authelion/api-adapter --save

Usage

HTTP

import express from 'express';
import { setupHTTPMiddleware } from "@authelion/api-adapter";
import { setConfig, useClient } from "redis-extension";
import axios from 'axios';

// setup express server
const server = expres();

// setup redis connection
setConfig('default', {connectionString: 'redis://127.0.0.1'});

// retrieve redis instance
const redis = useClient('default');

// set bearer token or achieve it on another way e.g. response interceptor ;)
axios.defaults.headers.common['Authorization'] = 'AUTH_TOKEN';

// setup socket middleware for socket server
server.use(setupHTTPMiddleware({
    redis,
    redisPrefix: 'token',
    http: axios
}));

Socket

import { Server } from 'socket.io';
import { setupSocketMiddleware } from "@authelion/api-adapter";
import { setConfig, useClient } from "redis-extension";
import axios from 'axios';

// setup socket.io server
const server = new Server();

// setup redis connection
setConfig('default', {connectionString: 'redis://127.0.0.1'});

// retrieve redis instance
const redis = useClient('default');

// set bearer token or achieve it on another way e.g. response interceptor ;)
axios.defaults.headers.common['Authorization'] = 'AUTH_TOKEN';

// setup socket middleware for socket server
server.use(setupSocketMiddleware({
    redis,
    redisPrefix: 'token',
    http: axios
}));

Keywords

FAQs

Last updated on 08 Jul 2022

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