# Gemfile
gem 'graphql'
# Installation
# rails generate graphql:install
Rails.application.config.middleware.insert_before 0, Rack::Cors do
# Development CORS - allow any localhost
allow do
origins(
/http:\/\/localhost:\d+/,
/http:\/\/127\.0\.0\.1:\d+/,
package domain
import (
"errors"
"fmt"
)
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
package paging
import (
"encoding/base64"
"encoding/json"
"time"
class Problem
DEFAULT_TYPE = "https://api.example.com/problems/about:blank".freeze
attr_reader :type, :title, :status, :detail, :instance, :extensions
def initialize(status:, title:, detail: nil, type: nil, instance: nil, extensions: {})
const jwt = require('jsonwebtoken');
const SECRET = process.env.JWT_SECRET;
const ALGORITHM = 'HS256';
const ACCESS_TTL = '15m';
class ProjectPresenter
def initialize(project, include_tasks: true)
@project = project
@include_tasks = include_tasks
end
class OrderPresenter < SimpleDelegator
attr_reader :current_user
def initialize(order, current_user:)
super(order)
@current_user = current_user
module MyApp
class Application < Rails::Application
config.load_defaults 6.1
# API-only mode
config.api_only = true
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
resources :users, only: [:index, :show, :create, :update]
resources :posts do
resources :comments, only: [:index, :create]