Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated plugin info endpoints #303

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ name: Laravel

on:
push:
<<<<<<< HEAD
branches: [ main ]
pull_request:
branches: [ main ]
=======
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
>>>>>>> 1b8fcd5fedf783df346660b0bbcf2aa16822bbce

jobs:
laravel-tests:
Expand All @@ -17,6 +23,45 @@ jobs:
php-version: '8.0'
- uses: actions/checkout@v2

<<<<<<< HEAD
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.test', '.env');"
- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit

# This job is to cache the node modules in order to reduce the time it would take to run
- name: Use cached node_modules
uses: actions/setup-node@v2
with:
directory: zc_plugin_expenses

#this job installs intalls yarn dependencies on the github runner
#and also to build the static files that would be transferred to server later
- name: Install dependencies
run: |
npm install
npm run production
=======
>>>>>>> 1b8fcd5fedf783df346660b0bbcf2aa16822bbce

- name: Git Pull on Server
uses: appleboy/ssh-action@master
Expand All @@ -27,8 +72,28 @@ jobs:
# key: ${{ secrets.SSHKEY }}
script: |
cd /var/www/expenses.zuri.chat
<<<<<<< HEAD
sudo rm composer.lock
sudo rm package-lock.json
git pull origin dev
git branch -r
git stash
composer install
npm install

# this job copies the build folder from GitHub runners to the server with sftp, make sure the paths are correct
- name: copy build to server
uses: Creepios/[email protected]
with:
username: ${{ secrets.USERNAME }}
host: ${{ secrets.ZURI_HOST }}
password: ${{ secrets.PASSWORD }}
localPath: './zc_plugin_expenses/webpack.mix.js'
remotePath: '/var/www/expenses.zuri.chat'
=======
git stash
git pull origin
git branch -r
composer install
yarn
>>>>>>> 1b8fcd5fedf783df346660b0bbcf2aa16822bbce
24 changes: 17 additions & 7 deletions app/Http/Controllers/AboutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@

class AboutController extends Controller
{
public function show(){
$about = [
'plugin_name' => 'zuri expenses',
public function showPluginInfo() {
$pluginInfo = [
'name' => 'Expenses Plugin',
'version' => '1.0',
'team_name' => 'team_grange',
'information' => 'This describes information about the expenses',
'description' => [
'zuri.chat Plugin',
'A plugin to track expenses'
],
'scaffold_structure' => 'Monolith',
'team' => 'HNG-8.0/Expenses Team',
'ping_url' => 'https://expenses.zuri.chat/api/ping',
// 'html_url' => 'https:',
// 'sidebar_url' => '',
];

return response()->json($about, 200);
return response()->json([
'status' => 'success',
'type' => 'Plugin Information',
'plugin_info' => $pluginInfo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'status' => 'success',
'message' => 'Plugin information retrieved successfully',
'data' => $pluginIfo

//Will be a better return format

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

], 200);
}
}
11 changes: 3 additions & 8 deletions app/Http/Controllers/PingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

class PingController extends Controller
{
public function index(){
$result=[
"status"=>200,
"message" => "Successful",
"data" => "UP"
];
return json_encode($result);
}
public function ping() {
return response()->json(['message' => 'Server is live!'], 200);
}
}
8 changes: 7 additions & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AboutController;
use App\Http\Controllers\PingController;
use App\Http\Controllers\ListApi;
use App\Http\Controllers\ExpenseController;
use App\Http\Controllers\RoomController;
use App\Http\Controllers\RoomMemberController;



/*
|--------------------------------------------------------------------------
| API Routes
Expand All @@ -30,7 +32,7 @@
Route::get('/sidebarlist', [SidebarAPI::class, 'sidebar']);
});

// Expense List endpoints
// Expense List endpoints
Route::prefix('v1')->group(function () {
Route::resource("list", "ListApi");
});
Expand Down Expand Up @@ -65,6 +67,10 @@
// Organization Endpoints


// plugin info related endpoints
Route::get('/info', [AboutController::class, 'showPluginInfo']);
Route::get('/ping', [PingController::class, 'ping']);




Expand Down