Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

A service that publishes a directory of research projects at Ghent University.

License

Notifications You must be signed in to change notification settings

ugent-library/projects-service

Repository files navigation

Project service

A service that publishes a directory of research projects at Ghent University.

Setup

Database

Create a new database and a user.

This application uses PostgreSQL's text search feature. You need to create a custom TEXT CONFIGURATION using these queries:

CREATE EXTENSION IF NOT EXISTS unaccent;
CREATE TEXT SEARCH CONFIGURATION usimple ( COPY = simple );
ALTER TEXT SEARCH CONFIGURATION usimple ALTER MAPPING FOR hword, hword_part, word WITH unaccent, simple;

Environment variables

Copy .env.example to .env and ensure these variables are present:

PROJECTS_ENV               # environment (local, production, development, default:production)
PROJECTS_HOST              # host or IP (default: localhost)
PROJECTS_PORT              # host port (default: 3000)
PROJECTS_API_KEY           # REST API Key
PROJECTS_REPO_CONN         # PostgreSQL DSN connection string
PROJECTS_REPO_SECRET       # PostgreSQL secret seed

Application boot

Via Reflex:

cp reflex.conf.example .reflex.conf
reflex -d none -c .reflex.conf

Or via Docker:

cd docker && docker build -f app.Dockerfile -t ugentlib/projects ../
docker run ugentlib/projects /dist/app server

Use tern to initalize the database:

cd etc/migrations && tern migrate apply

Either create a tern.conf file in the etc/migrations directory, or use tern with PG environment variables.

Development

Live reload

go install github.com/cespare/reflex@latest
cp reflex.example.conf reflex.conf
reflex -c reflex.conf

Database

Making changes to the database schema:

  • tern migrate new to create a new migration file.
  • Add SQL code to the migration file.
  • tern migrate apply to apply pending migrations to the database.

This projects uses sqlc.

OpenAPI

The REST API is described through OpenAPI. The code is generated with ogen.

When making changes to the API specification in api/v1/openapi.yaml, you must regenerate the API server code: cd api/v1 && go generate ./....

The implementation of the handler resides in api/v1/service.go. Make sure all methods of the Handler interface are implemented.

About

A service that publishes a directory of research projects at Ghent University.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published