- Notifications
You must be signed in to change notification settings - Fork3
Main Laravel based API for wikibase.cloud
License
wbstack/api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ℹ️ Issues for this repository are tracked onPhabricator - (Click here to open a new one)
The platform API comes in a few different flavours that can be toggled using environment variables:
ROUTES_LOAD_WEB
- web routes for the public facing wbstack.com usecaseROUTES_LOAD_SANDBOX
- web routes for the public facing sandbox usecaseROUTES_LOAD_BACKEND
- internal only API endpoints (non public) for all usecases
This single application could likely be split up at some point.Everything is currently together to make use of the shared wiki management codeand query service management code.
WBSTACK_CONTACT_MAIL_SENDER
- The mail address of the sender address of the contact page mails.If the address includes the placeholder<subject>
, it gets replaced with a shorthand for the actual selected subject (give-feedback
,report-a-problem
, etc)WBSTACK_CONTACT_MAIL_RECIPIENT
- The receiver address of the contact page mails
It is recommened to install the php dependencies via a composer docker container as that contains the required php extensions:
docker run --rm -it -v $PWD:/app -u $(id -u):$(id -g) composer install
Alternatively, you can runcomposer
on your local machine (ignoring platform requirements):
composer install --ignore-platform-reqs
cp .env.example .env
and modify the contents accordingly.
You should be able to run some amount of this application in docker-compose.
Though the experience is not that refined...
docker-compose up -d
Run everything in one go ...
docker-composeexec api bash -c'php artisan migrate:fresh && php artisan passport:install && php artisan db:seed && php artisan key:generate && php artisan storage:link'
Or each command separately ...
# Create the SQL tables neededdocker-composeexec api php artisan migrate:fresh# Create some certs needed for authentication (passport is a laravel plugin)docker-composeexec api php artisan passport:install# Seed some useful development datadocker-composeexec api php artisan db:seed# Generate and set the APP_KEY env variable.docker-composeexec api php artisan key:generate# Create a symlink from `public/storage` to `storage/app/public`docker-composeexec api php artisan storage:link
Try loadinghttp://localhost:8070/ until the DB is up and the connection works.
If you want to develop with the UI then simply point the UI docker-compose setup to localhost:8082
Some data is added to the database via the laraval seeders.
You can log in with these details for example.
User:a@a.a
Password:a
And create a wiki.
Currently most of the tests require the DB connection to exist.
docker-composeexec api vendor/bin/phpunit
If you get a CORS error from an API when testing, it might be due to an exception internally, resulting in a 500 response with no CORS.
If you are testing a route and believe an exception is happening (returning a 500), you can disable error handling to see the trace.
use \Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling;functionsomeTest() {$this->withoutExceptionHandling();// rest of test code...}
You may need to run these from within a container with a DB attached:
php artisan ide-helper:modelsphp artisan ide-helper:eloquent
About
Main Laravel based API for wikibase.cloud