Skip to content

Instantly share code, notes, and snippets.

View farindra's full-sized avatar

Farindra farindra

View GitHub Profile
@farindra
farindra / simple-json-rest-api-response-guidelines.md
Last active March 11, 2024 02:13
SIMPLE JSON REST API RESPONSE GUIDELINES

SIMPLE JSON REST API RESPONSE GUIDELINES

English Version

Pendahuluan

Pada umumnya standarisasi JSON REST API RESPONSE memang tidak ditentukan, namun untuk pencapaian efisiensi, konsistensi dan kemudahan maka dibutuhkan standarisasi tersebut.

Pencapaian ini kami temukan dan terapkan setelah mengerjakan banyak proyek degan kasus-kasus yang umum, sehingga kami simpulkan menjadi suatu standarisasi yang kami gunakan sampai sekarang.

Kami yakin bagi anda yang menemukan artikel ini, berarti Anda sudah mengerti akan segalah hal tentang JSON REST API RESPONSE, sehingga kami tidak menjelaskan detail tentang hal-hal kecil yang berhubungan tentang itu.

@farindra
farindra / simple-json-rest-api-response-guidelines-english.md
Last active March 11, 2024 02:11
SIMPLE JSON REST API RESPONSE GUIDELINES (English version)

SIMPLE JSON REST API RESPONSE GUIDELINES

Introduction

In general, standardization of the JSON REST API RESPONSE is not specified, but to achieve efficiency, consistency and convenience, this standardization is needed.

We discovered and applied this achievement after working on many projects with common cases, so we concluded it became a standardization that we use to this day.

We are sure that for those of you who found this article, you already understand everything about JSON REST API RESPONSE, so we don't explain in detail about the little things related to it.

>Our goal is efficiency, consistency and convenience

This is a simple instruction to use Tabler in your next Laravel project.

(Tabler is a beautiful dashboard: https://tabler.io/)

How to install:

  1. first of all run content of gistfile1.txt in your Laravel project.
  2. Copy tabler.js to recourses/js.
  3. Copy tabler.scss to resources/sass.
  4. Replace webpack.mix.js with your current webpack.mix.js
@farindra
farindra / SetLocale.php
Last active April 21, 2021 21:03
Laravel Middleware - Set Locale from request and session
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class SetLocale
{
/**
@farindra
farindra / movie.php
Last active April 12, 2021 22:52
Lumen Jwtauth Part 1 - Movie Route
<?php
/* movie group */
$router->group(['prefix' => 'movie', 'as' => 'movie'], function () use ($router) {
/* all movies */
$router->get('/all', [ 'as' => 'all', 'uses' => 'MovieController@all']);
/* show movies by id */
$router->get('/{id}', [ 'as' => 'show', 'uses' => 'MovieController@show']);
@farindra
farindra / AuthController.php
Last active April 12, 2021 22:42
Lumen Jwtauth Part 1 - Auth Controller
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class AuthController extends Controller
@farindra
farindra / user.php
Last active April 12, 2021 22:32
Lumen user route
<?php
/* registration */
$router->post('/register', [ 'as' => 'register', 'uses' => 'AuthController@register']);
/* login */
$router->post('/login', [ 'as' => 'login', 'uses' => 'AuthController@login']);
/* restrict route */
$router->group(['middleware' => 'auth'], function () use ($router) {
@farindra
farindra / swagger.yaml
Created April 11, 2021 23:20
Lumen Jwtauth Part 1 - Swagger Version 1.0
openapi: 3.0.3
info:
title: Lumen JWT Auth
version: '1.0'
contact:
email: farindra.project@gmail.com
name: Farindra
url: 'https://farindra.com'
license:
name: MIT license
@farindra
farindra / CorsMiddleware.php
Last active April 11, 2021 23:06
Lumen Jwtauth Part 1 - Cors Middleware
<?php
namespace App\Http\Middleware;
use Closure;
class CorsMiddleware
{
/**
* Handle an incoming request.
@farindra
farindra / EndpointTest.php
Last active April 11, 2021 10:27
Lumen Jwtauth Part 1 - Test Endpoint
<?php
use Illuminate\Support\Facades\Config;
class EndpointTest extends TestCase
{
/**
* unknown route shoult return 404
*
* @return void