The Pastehistory API is a rudementary API for Pastehistory which uses Node.js to interface with the SQL server of your implementation.
At the moment, the API only supports get
and search
, remember to replace localhost
and 1337
with the appropriate server and port that you have configured.
get
- Get a paste by it's IDhttp://localhost:1337/?cmd=get&id=<id>
- Returns a JSON object with the matching paste in its entirety including all fields.
search
- Search for pastes by keyword and return relevant data, supports multiple keywords seperated by spaces (yes I know this is dirty)http://localhost:1337/?cmd=search&keyword=<query>
- Returns an array of pastes as JSON objects.
Pastehistory uses the following modules to function.
http
- Core Node module for handling HTTP requests. Pastehistory uses this module to perform basic request capturing and response handling.url
- Core Node module which is used to parse and decode urls and queries for processing.mysql
- NPM module used for accessing the SQL database.
- CentOS 7
- Node 0.12
- NPM
- Configure the SQL connection by modifying the follwing block of code with the appropriate settings:
var conn = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'password',
database : 'paste'
});
- Ensure that the server is configured to listen on the proper port:
server.listen(1337);
- Install the dependencies:
$ npm install
- Start the API server using the standard method:
$ npm start
or by using a process manager such as forever: $ npm install -g forever
$ forever start server.js