Skip to content

LuiisCarlos/expressjs-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpressJS Proxy

A lightweight proxy server built with ExpressJS that forwards HTTP requests to a target URL, adding authentication and logging.

Features

  • Forwards requests to a specified target URL via the /proxy endpoint
  • Adds a Bearer Authorization token to outgoing requests
  • Logs all requests and errors in JSON format
  • Supports JSON request and response bodies

Requirements

  • Node.js v16+
  • An API token for authentication

Setup

  1. Clone the repository.
  2. Install dependencies:
npm install
  1. Create a .env file in the project root with the following content:
PORT       = 3000
NODE_ENV   = development
AUTH_TOKEN = your_token_here

Usage

Start the proxy server:

npm run start

Send a request to the proxy endpoint:

POST /proxy?targetUrl=https://api.yourservice.com/endpoint

Body example:

{
    "messages": [
        {
            "role": "role",
            "content": "input"
        }
    ],
    "model": "example-ai",
    "stream": false
}

Project structure

  • src/index.js: Main server entry point
  • src/config/env.js: Environment variable management
  • src/config/logger.js: Simple JSON logger

About

Proxy made for communication with AI providers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors