0.2.2 • Published 3 years ago

@ax2/api-core v0.2.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

API CORE

API CORE documentation

Setup

Install the module

yarn add @ax2/api-core

Necessary Env variables

OptionDescription
NODE_ENVlocal, prod or dev
LANG_FALLBACKdefault lang to use (default ='en')
LANG_KEYSmultilang keys (example 'fr,en')
MEDIA_DIRECTORYDirectory on gcp in bucket
GCP_PROJECT_IDProject ID from gcp
STORAGE_BUCKETName of the bucket in on gcp storage
MEDIA_RESIZINGSet to 1 to use resize media
MYSQL_DB_NAMEMySQL database name
MYSQL_DB_USERMySQL user
MYSQL_DB_PASSWORDMySQL password
MYSQL_DB_HOSTMySQL host (default: 127.0.0.1)
MYSQL_DB_PORTMysql Port (default: 3306)
REDIS_HOSTRedis Host (default: 127.0.0.1)
REDIS_PORTRedis Port (default: 6379)
REDIS_PASSWORDRedis Password (default: '')
REDIS_PREFIXRedis prefix for cache key (default: '')
REDIS_ENABLESet to 1 to enable Redis (default: disabled)
SENTRYSentry DSN
API_VERSIONAPI version return in response
SITE_URLSITE url for referer to allow cms preview

Load the module into the core

import * as CORE from '@ax2/api-core';
class Article extends CORE.Citadelle {}

import { Citadelle } from '@ax2/api-core';
class Article extends Citadelle implements ModelItem {}

Available class

// Config connection
import { db, language, storage } from '@ax2/api-core';

// Controller core
import { MotherBase } from '@ax2/api-core';

// Helpers function
import { ApiResponse, redis, Sentry, Validator } from '@ax2/api-core';

// Model function
import { Citadelle } from '@ax2/api-core';