Skip to content

acmcsufoss/api.acmcsuf.com

Repository files navigation

api.acmcsuf.com

ACM at CSUF club API for managing events, announcements, forms, and other services! Keep reading for information on setting up this project locally, and see the contributor guide and docs/ for more information on using and contributing to this project.


Setting Up

This project requires that you have Go, sqlc, GNU Make, and optionally Air installed. We highly recommend using the provided Nix development environment instead of installing everything manually.

  1. Install nix and direnv if you don't already have them

  2. Run direnv allow at the project root

If you don't have direnv, you can also use nix develop to enter the dev shell, but your environment variables won't get sourced automatically.

Developing

Compiling

Using make will compile both the API and CLI binaries, located at bin/acmcsuf-api and bin/acmcsuf-cli respectively. If you installed direnv, both of these binaries will be automatically added to your path. You can run them directly like:

acmcsuf-api # Run API server
acmcsuf-cli # Start CLI client (start API server before using)

Start API server

We use a program called air, which recompiles the api server on the fly so you don't have to rebuild the server when you make changes.

air
# OR
make run

Running database migrations

After starting the server, you need to apply the database migrations in order to create the database schema.

make migrate-up

Configuring the API

The API server is configurable via environment variables. See .env.example for values you can override and configure in your .env file.

Using the CLI

The CLI is a simple command-line client for the API server. Make sure the API server is running before using.

Output of acmcsuf-cli --help:

A CLI tool to help manage the API of the CSUF ACM website

Usage:
  acmcsuf-cli [command]

Available Commands:
  announcements Manage ACM CSUF's Announcements
  completion    Generate the autocompletion script for the specified shell
  events        A command to manage events.
  help          Help about any command
  officers      A command to manage officers.

Flags:
  -h, --help      help for acmcsuf-cli
  -v, --version   version for acmcsuf-cli

Use "acmcsuf-cli [command] --help" for more information about a command.

Configuring the CLI

The CLI's auth-related configuration is currently handled via environemnt variables similarly to the API. Other settings can be configured by modifiying the config file, located at ~/.config/acmcsuf-cli/config.json.

Other useful commands from the Makefile

make all      # Format and generate code + build both binaries
make generate # Regenerate Swagger docs and sqlc models
make check    # Run checks
make fix-sql  # Format and fix SQL files
make clean    # Removes all build artifacts
make help     # Display all targets

Developed with 💚 by @acmcsufoss

About

Data layer of acmcsuf.com and more!

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 14