OpenPing is a versatile Rails API application designed to support a variety of backend services. It offers essential features for managing and authenticating users.
To get started with OpenPing, follow these steps:
-
Clone the repository:
git clone https://github.com/yourusername/openping.git cd openping
-
Install dependencies:
Ensure you have Ruby and Bundler installed, then run:
bundle install
-
Set up the database:
Configure your database settings in
config/database.yml
, then run:rails db:create rails db:migrate
-
Set up credentials:
Edit your credentials file to include necessary secrets:
rails credentials:edit
-
Start the server:
Run the Rails server:
rails server
Once the server is running, you can interact with the API using tools like Postman or curl. The base URL for local development is http://localhost:3000
.
OpenPing uses GoodJob for background job processing. GoodJob is configured to handle Active Job tasks, such as pinging sites at specified intervals. Ensure that the GoodJob worker is running to process these jobs. You can start the GoodJob worker with:
bundle exec good_job start
- Endpoint:
POST /api/v1/users
- Description: Register a new user.
- Request Body:
{ "user": { "email": "[email protected]", "password": "password" } }
- Endpoint:
POST /api/v1/sessions
- Description: Sign in an existing user.
- Request Body:
{ "email": "[email protected]", "password": "password" }
-
Endpoint:
GET /api/v1/sites
- Description: Retrieve a list of sites for the authenticated user.
- Response: Array of site objects.
-
Endpoint:
GET /api/v1/sites/:id
- Description: Retrieve a specific site by ID.
- Response: Site object.
-
Endpoint:
POST /api/v1/sites
- Description: Create a new site.
- Request Body:
{ "site": { "url": "http://example.com", "frequency": 10, "is_active": true } }
-
Endpoint:
PATCH /api/v1/sites/:id
- Description: Update an existing site.
- Request Body:
{ "site": { "url": "http://newexample.com" } }
-
Endpoint:
DELETE /api/v1/sites/:id
- Description: Delete a site by ID.
All endpoints require authentication. Include a valid JWT token in the Authorization
header of your requests. The token can be obtained by signing in a user via the /api/v1/sessions
endpoint.
To run the test suite, execute:
bundle exec rspec
OpenPing uses environment variables and credentials for configuration. Ensure you have the following set up:
- Database URL: Set in
config/database.yml
or via environment variables. - Secret Key Base: Managed via Rails credentials.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Do work.
- Commit your changes with clear messages.
- Push your branch and open a pull request.
This project is licensed under the GNU General Public License v3.0. You are free to use, modify, and distribute this software under the terms of the GPL. For more details, see the LICENSE file.
The GPL license ensures that this project remains free and open-source, allowing anyone to contribute and benefit from its development.