FBLA24/fbla-api
2024-06-25 18:27:53 -05:00
..
lib More fixes 2024-06-25 18:27:53 -05:00
logos init commit - move from separate git repos 2024-04-07 12:32:23 -05:00
test API Rewrite 2024-06-13 14:27:36 -05:00
.gitignore init commit - move from separate git repos 2024-04-07 12:32:23 -05:00
analysis_options.yaml init commit - move from separate git repos 2024-04-07 12:32:23 -05:00
CHANGELOG.md init commit - move from separate git repos 2024-04-07 12:32:23 -05:00
docker-compose.yml API Rewrite 2024-06-13 14:27:36 -05:00
Dockerfile run 2024-06-13 16:00:28 -05:00
Jenkinsfile security updates part 2 2024-06-06 15:44:28 -05:00
MarinoDev.svg init commit - move from separate git repos 2024-04-07 12:32:23 -05:00
MarinoDevTriangle.svg init commit - move from separate git repos 2024-04-07 12:32:23 -05:00
pubspec.lock security updates 2024-06-06 15:13:53 -05:00
pubspec.yaml init commit - move from separate git repos 2024-04-07 12:32:23 -05:00
README.md API change and README updates 2024-06-24 20:24:52 -05:00

This is the API for my 2023-2024 FBLA Coding & Programming App

Installation

  1. Install Dart SDK.
  2. Clone the repo .
git clone https://git.marinodev.com/MarinoDev/FBLA24.git
cd FBLA24/fbla-api/
  1. Run dart pub install to install dart packages.
  2. Install PostgreSQL and set it up.
  3. Create fbla database in postgres.
CREATE DATABASE fbla
    WITH
    OWNER = [username]
    ENCODING = 'UTF8'
    CONNECTION LIMIT = -1
    IS_TEMPLATE = False;

Make sure to change [username] to the actual username of your postgres instance.

  1. Create businesses table.
-- Table: public.businesses

-- DROP TABLE IF EXISTS public.businesses;

CREATE TABLE IF NOT EXISTS public.businesses
(
    id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 0 MINVALUE 0 MAXVALUE 2147483647 CACHE 1 ),
    name text COLLATE pg_catalog."default" NOT NULL,
    description text COLLATE pg_catalog."default" NOT NULL,
    type text COLLATE pg_catalog."default" NOT NULL,
    website text COLLATE pg_catalog."default" NOT NULL,
    "contactName" text COLLATE pg_catalog."default" NOT NULL,
    "contactEmail" text COLLATE pg_catalog."default" NOT NULL,
    "contactPhone" text COLLATE pg_catalog."default" NOT NULL,
    notes text COLLATE pg_catalog."default" NOT NULL,
    "locationName" text COLLATE pg_catalog."default" NOT NULL,
    "locationAddress" text COLLATE pg_catalog."default" NOT NULL,
    CONSTRAINT businesses_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.businesses
    OWNER to [username];

Make sure to change [username] to the actual username of your postgres instance.

  1. Create listings table.
-- Table: public.listings

-- DROP TABLE IF EXISTS public.listings;

CREATE TABLE IF NOT EXISTS public.listings
(
    id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
    "businessId" integer NOT NULL,
    name text COLLATE pg_catalog."default" NOT NULL,
    description text COLLATE pg_catalog."default" NOT NULL,
    type text COLLATE pg_catalog."default" NOT NULL,
    wage text COLLATE pg_catalog."default",
    link text COLLATE pg_catalog."default",
    "offerType" text COLLATE pg_catalog."default" NOT NULL,
    CONSTRAINT listing_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.listings
    OWNER to [username];

Make sure to change [username] to the actual username of your postgres instance.

  1. Create users table.
-- Table: public.users

-- DROP TABLE IF EXISTS public.users;

CREATE TABLE IF NOT EXISTS public.users
(
    username text COLLATE pg_catalog."default" NOT NULL,
    password_hash text COLLATE pg_catalog."default" NOT NULL,
    salt text COLLATE pg_catalog."default" NOT NULL,
    CONSTRAINT users_pkey PRIMARY KEY (username),
    CONSTRAINT username UNIQUE (username)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.users
    OWNER to [username];

Make sure to change [username] to the actual username of your postgres instance.

  1. Set environment variables JOBLINK_POSTGRES_ADDRESS (IP address), JOBLINK_POSTGRES_PORT ( default 5432), JOBLINK_POSTGRES_USERNAME, and JOBLINK_POSTGRES_PASSWORD to appropriate information for your postgres database. Also set JOBLINK_SECRET_KEY to anything you want to generate JSON Web Tokens.
  2. Set lib/create_first_user.dart username and password variables at top of file and run with dart run lib/create_first_user.dart.
    Note: the username and password you use here will be what you use to log into the app as an admin.

Usage

Installed

Start the API with dart run lib/fbla_api.dart
Note the address it is serving at, you will need this to connect it to the UI, and to run tests.

Docker

Run it in a docker container with Docker Build and Docker Compose using the included Dockerfile and docker-compose.yml files. If using Docker Compose, change the first portion of the volumes path on line 9 to any desired storage location.
Note the address it is serving at, you will need this to connect it to the UI, and to run tests.

Testing

You can test all functionality of your api with dart run test/fbla_api_test.dart, setting apiAddress on line 8 to your api address.