repost
v1.0.1
Published
repost is a system that enables fast and easy request transformation proxying.
Downloads
2
Readme
rePOST
repost is a system that enables fast and easy request transformation proxying.
It includes a simple web interface that allows you to manage what incoming requests to listen for, and the resulting transformations.
Configuration
Configure repost by passing in environment variables
REPOST_PRIVATE_PORT
number – default: 3000
The private port where the control panel and configuration api is exposedREPOST_PUBLIC_PORT
number – default: 3001
The public port where repost listens for incoming eventsREPOST_DB_CLIENT –
sqlite3 | better-sqlite3 | mysql | mysql2 | oracledb | pg – default: sqlite3
The database client to use. See knex configuration options for more information.
REPOST_DB_CONNECTION
string – default: repost.db
The database connection configuration. See knex configuration options for more information.
To use an object for configuration, set the environment variable to a valid json string
Usage
Create events, actions and entries to enable functionality in repost
event
An event is an endpoint or request configuration that repost will be able to listen for.
Properties
method –
GET | POST | PUT | PATCH | DELETE
The HTTP method to accept requests forpath -
string
The path to listen onBasic auth -
json
A json object containing username and password which must be matched when the validation strategy is set to "basic"Headers -
json
A json object containing headers which must be matched when the validation strategy is set to "basic"Data -
json
A json object containing a default body which will merge with the request body and propagate on to the action (not supported for GET requests)Validation Strategy -
basic | none
When set to basic, the basic auth and request headers will be validated against the supplied json values
action
An action is a request transformation and resulting request, that follows an event
Properties
name -
string
A label for the actionRepost Target -
url
The target URL to send the request toStrategy -
Static | JavaScript
Static
The supplied code must be a static json object following the Request Configuration model (See below)
JavaScript
The supplied code must be valid JavaScript. The incoming event is a javascript object following the Request Configuration model, and can be accessed from the script using
event
The variable
event
has been updated with the url to the Repost Target set in the action. The requested url is also available onevent.incomingRequestUrl
To transform the request, a call must be made to
repost(event)
where the event is also an object following the Request Configuration model.event
can be mutated and then reposted like sorepost(event)
The third-party libraries axios and lodash can be utilized in the script using
const _ = require("lodash")
andconst axios = require("axios")
respectively.The Request Configuration model is compatible with axios, so additional requests may be sent using
axios(event)
URL -
url
Direct link to a script compliant with the selected strategy. The content-type must betext/plain
ortext/html
Code -
string
Plain text script compliant with the selected strategy. If a URL is specified it will take precedence
entry
An entry is the entity that connects an event to an action.
While an action can be reused across multiple events, each event may only trigger a single action, and should only have one entry. If multiple entries use the same event, the last one will take precedence
Properties
Label -
string
A label for the entryAction -
number
The ID of the chosen actionEvent -
number
The ID of the chosen event
Request Configuration Model
The model that is used for incoming and outgoing requests in rePOST.
{
auth?: {
username: string,
password: string
},
data?: any;
headers?: Record<string, string>;
incomingRequestUrl?: string;
url: string;
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
}