repost
v1.0.1
Published
repost is a system that enables fast and easy request transformation proxying.
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: 3000The private port where the control panel and configuration api is exposedREPOST_PUBLIC_PORT
number – default: 3001The public port where repost listens for incoming eventsREPOST_DB_CLIENT –
sqlite3 | better-sqlite3 | mysql | mysql2 | oracledb | pg – default: sqlite3The database client to use. See knex configuration options for more information.
REPOST_DB_CONNECTION
string – default: repost.dbThe 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 | DELETEThe HTTP method to accept requests forpath -
stringThe path to listen onBasic auth -
jsonA json object containing username and password which must be matched when the validation strategy is set to "basic"Headers -
jsonA json object containing headers which must be matched when the validation strategy is set to "basic"Data -
jsonA 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 | noneWhen 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 -
stringA label for the actionRepost Target -
urlThe target URL to send the request toStrategy -
Static | JavaScriptStatic
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
eventThe variable
eventhas been updated with the url to the Repost Target set in the action. The requested url is also available onevent.incomingRequestUrlTo transform the request, a call must be made to
repost(event)where the event is also an object following the Request Configuration model.eventcan 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 -
urlDirect link to a script compliant with the selected strategy. The content-type must betext/plainortext/htmlCode -
stringPlain 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 -
stringA label for the entryAction -
numberThe ID of the chosen actionEvent -
numberThe 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";
}