From 3cdf3b54ed4f3c022f917d3c1230dbc549d2f07f Mon Sep 17 00:00:00 2001 From: drake Date: Mon, 24 Jun 2024 20:24:52 -0500 Subject: [PATCH] API change and README updates --- fbla-api/README.md | 62 +++++++++++++++++++++++++++---- fbla_ui/lib/shared/api_logic.dart | 4 +- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/fbla-api/README.md b/fbla-api/README.md index d222c6a..80d2313 100644 --- a/fbla-api/README.md +++ b/fbla-api/README.md @@ -4,13 +4,16 @@ This is the API for my 2023-2024 FBLA Coding & Programming App 1. Install [Dart SDK](https://dart.dev/get-dart). 2. Clone the repo . + ```bash git clone https://git.marinodev.com/MarinoDev/FBLA24.git cd FBLA24/fbla-api/ ``` + 3. Run `dart pub install` to install dart packages. 4. Install [PostgreSQL](https://www.postgresql.org/) and set it up. 5. Create `fbla` database in postgres. + ```SQL CREATE DATABASE fbla WITH @@ -19,9 +22,11 @@ CREATE DATABASE fbla CONNECTION LIMIT = -1 IS_TEMPLATE = False; ``` + Make sure to change [username] to the actual username of your postgres instance. 6. Create `businesses` table. + ```SQL -- Table: public.businesses @@ -48,9 +53,39 @@ 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. -7. Create `users` table. +7. Create `listings` table. + +```SQL +-- 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. + +8. Create `users` table. + ```SQL -- Table: public.users @@ -68,11 +103,19 @@ CREATE TABLE IF NOT EXISTS public.users TABLESPACE pg_default; ALTER TABLE IF EXISTS public.users - OWNER to postgres; + OWNER to [username]; ``` -8. 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. -9. 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. + +Make sure to change [username] to the actual username of your postgres instance. + +8. 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. +9. 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 @@ -83,9 +126,14 @@ Note the address it is serving at, you will need this to connect it to the UI, a ### Docker -Run it in a docker container with [Docker Build](https://docs.docker.com/reference/cli/docker/image/build/) and [Docker Compose](https://docs.docker.com/compose/) using the included [Dockerfile](Dockerfile) and [docker-compose.yml](docker-compose.yml) files. If using `Docker Compose`, change the first portion of the volumes path on line 9 to any desired storage location.\ +Run it in a docker container +with [Docker Build](https://docs.docker.com/reference/cli/docker/image/build/) +and [Docker Compose](https://docs.docker.com/compose/) using the included [Dockerfile](Dockerfile) +and [docker-compose.yml](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. +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. diff --git a/fbla_ui/lib/shared/api_logic.dart b/fbla_ui/lib/shared/api_logic.dart index 3a9a20a..ff7eecc 100644 --- a/fbla_ui/lib/shared/api_logic.dart +++ b/fbla_ui/lib/shared/api_logic.dart @@ -6,8 +6,8 @@ import 'package:fbla_ui/shared/global_vars.dart'; import 'package:fbla_ui/shared/utils.dart'; import 'package:http/http.dart' as http; -// var apiAddress = 'https://homelab.marinodev.com/fbla-api'; -var apiAddress = 'http://192.168.0.114:8000/fbla-api'; +var apiAddress = 'https://homelab.marinodev.com/fbla-api'; +// var apiAddress = 'http://192.168.0.114:8000/fbla-api'; var client = http.Client();