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-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

@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.

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 / 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 / MovieCRUDTest.php
Last active April 11, 2021 06:16
Lumen Jwtauth Part 1 - Test Movie CRUD
<?php
use App\Models\Movie;
use Illuminate\Support\Facades\Artisan;
use Laravel\Lumen\Testing\DatabaseMigrations;
class MovieCRUDTest extends TestCase
{
use DatabaseMigrations;
@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 / UserAuthTest.php
Last active April 11, 2021 06:49
Lumen Jwtauth Part 1 - Test User Auth
<?php
use Laravel\Lumen\Testing\DatabaseMigrations;
class UserAuthTest extends TestCase
{
use DatabaseMigrations;
/**
* user token
@farindra
farindra / Handler.php
Created April 4, 2021 23:34
Lumen Jwtauth Part 1 - Error Handler
public function render($request, Throwable $exception)
{
/* only run if debug is turn off */
if ( !env('APP_DEBUG', true) ) {
/* handling 404 exception */
if($exception instanceof NotFoundHttpException){
return response()->json([
'error' => 'Not Found',
@farindra
farindra / MovieController.php
Created April 4, 2021 15:54
Lumen Jwtauth Part 1 - Movie Controller
<?php
namespace App\Http\Controllers;
use App\Models\Movie;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class MovieController extends Controller
{