Skip to content

ZeroCoderss/server_agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Server Agent

This is a server agent that you can run locally on your server. It is designed to handle tasks and manage jobs according to the defined configurations.

technology

  1. bun
  2. bun:sqlite
  3. crypto -> for secure token encription

Installation

To install the required dependencies, use Bun:

bun install

Migrate Database

To set up the database schema and perform migrations, run:

bun run migrate

This command will create the necessary tables and ensure the database is up-to-date.

Run the REST API Server

To start the REST API server, which allows you to set jobs and manage users who can add jobs to the server, use:

bun run server

The REST API server provides endpoints for job and user management.

Run the Agent

To run the server agent that processes jobs, execute:

bun run agent

The agent continuously processes jobs and performs the assigned tasks according to the configurations.

Usage

  1. Start the REST API Server: This will allow you to create and manage jobs and users.

  2. Run the Agent: This will continuously process the jobs as per the configurations and schedules.

Here’s the updated README section for the REST API reference, including the necessary curl commands and instructions for managing cookies and tokens.

REST API Reference

Login API

To log in and receive a session cookie:

curl -c cookies.txt --location 'http://localhost:3000/api/v1/login' \
--header 'Content-Type: application/json' \
--header 'X-Forwarded-For: 10.0.0.10' \
--data-raw '{
    "email": "agayen04@gmail.com"
}'

Collecting the Token from Cookies

You need to collect the token from the cookies.txt file. After logging in, the token will be in the cookies file. The format of the file might look like this:

# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_localhost	FALSE	/	TRUE	1722059024	token	31b121f36081c46aee3a7c4fdaa8fa97:1d600f5365bb46ba4b6e4ac9286778cfa64e470a31f14b0a4e2fbfa9da6e4362d5aecf4446c5cbfdf5f45d1a303d50b8c2b08aa3388aee18c7715ae0aa7eb1834550657c626484cc8708738c1166f550

Here, the token is:

31b121f36081c46aee3a7c4fdaa8fa97:1d600f5365bb46ba4b6e4ac9286778cfa64e470a31f14b0a4e2fbfa9da6e4362d5aecf4446c5cbfdf5f45d1a303d50b8c2b08aa3388aee18c7715ae0aa7eb1834550657c626484cc8708738c1166f550

List Users

To list users, including the token from the cookies:

curl --location --request GET 'http://localhost:3000/api/v1/users' \
--header 'Content-Type: application/json' \
--header 'X-Forwarded-For: 10.0.0.10' \
--header 'Cookie: token=<token>'

Replace <token> with the actual token you extracted.

List Jobs

To list jobs, including the token from the cookies:

curl --location --request GET 'http://localhost:3000/jobs' \
--header 'Content-Type: application/json' \
--header 'X-Forwarded-For: 10.0.0.10' \
--header 'Cookie: token=<token>'

Replace <token> with the actual token you extracted.

Create Jobs

To create a new job, including the token from the cookies:

curl --location 'http://localhost:3000/api/v1/jobs' \
--header 'Content-Type: application/json' \
--header 'X-Forwarded-For: 10.0.0.10' \
--header 'Cookie: token=<token>' \
--data-raw '{
    "type": "test",
    "data": "opos test.py"
}'

Replace <token> with the actual token you extracted.

Create User

To create a new user, including the token from the cookies:

curl --location 'http://localhost:3000/api/v1/users' \
--header 'Content-Type: application/json' \
--header 'X-Forwarded-For: 10.0.0.10' \
--header 'Cookie: token=<token>' \
--data-raw '{
    "email": "agayen@gmail.com",
    "name": "Abhijit test",
    "role": "user"
}'

Replace <token> with the actual token you extracted.

Coming Soon

  1. UI will be available soon
  2. RPC call support
  3. Enhanced security

About

A server agent works to handle jobs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published