init commit - move from separate git repos
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# https://dart.dev/guides/libraries/private-files
|
||||
# Created by `dart pub`
|
||||
.dart_tool/
|
||||
@@ -0,0 +1,3 @@
|
||||
## 1.0.0
|
||||
|
||||
- Initial version.
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Switch to root user for installation
|
||||
USER root
|
||||
|
||||
RUN apt-get update && apt-get install -y git wget gpg apt-transport-https apt-utils
|
||||
RUN wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/dart.gpg
|
||||
RUN echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' | tee /etc/apt/sources.list.d/dart_stable.list
|
||||
RUN apt-get update && apt-get install -y dart
|
||||
ENV PATH="$PATH:/usr/lib/dart/bin"
|
||||
|
||||
RUN cd /root && git clone https://https://git.marinodev.com/MarinoDev/FBLA24.git
|
||||
WORKDIR /root/FBLA24/fbla-api
|
||||
RUN dart pub install
|
||||
|
||||
EXPOSE 8000
|
||||
ENTRYPOINT dart run ./lib/fbla_api.dart
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage('Start API') {
|
||||
steps {
|
||||
sh '''docker image prune -f
|
||||
docker build --no-cache -t fbla-api .
|
||||
docker-compose down
|
||||
docker-compose up -d'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run Tests') {
|
||||
steps {
|
||||
sh '''dart pub install
|
||||
dart run ./test/fbla_api_test.dart'''
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="200mm"
|
||||
height="70mm"
|
||||
viewBox="0 0 200 70"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||
sodipodi:docname="MDEVLogoFull.svg"
|
||||
xml:space="preserve"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:zoom="0.75544332"
|
||||
inkscape:cx="47.654138"
|
||||
inkscape:cy="97.955728"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1046"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" /><defs
|
||||
id="defs1"><rect
|
||||
x="164.6723"
|
||||
y="176.95522"
|
||||
width="237.7821"
|
||||
height="119.97466"
|
||||
id="rect1047" /><rect
|
||||
x="170.3439"
|
||||
y="136.68353"
|
||||
width="277.49832"
|
||||
height="196.87138"
|
||||
id="rect9139" /></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"><path
|
||||
style="font-size:48px;font-family:HeadlineNEWS;-inkscape-font-specification:HeadlineNEWS;white-space:pre;shape-padding:0.133618;fill:#000000;fill-opacity:1;stroke-width:0.608723"
|
||||
d="m 103.58306,22.62203 h -7.380754 q 0,-2.975635 0,-5.95127 0,-4.113378 -0.233384,-5.74706 l -4.113377,8.489312 -3.617439,-0.08752 -3.82165,-8.401793 q -0.262556,1.779547 -0.291729,5.74706 0,2.975635 0,5.95127 h -7.380745 l 1.10857,-21.90884035 h 7.205708 l 5.105257,9.91878235 5.134429,-9.91878235 h 7.147374 z m 22.60912,0 h -5.68875 l -0.90436,-2.683906 h -7.20575 l -0.93354,2.683906 h -5.71792 L 112.7434,5.1182952 h 6.47642 z m -7.52665,-5.54285 -2.71309,-8.4601379 -2.65475,8.4601379 z m 27.62688,5.54285 h -6.12634 q -1.72121,-3.442402 -1.80873,-3.617439 -1.40031,-2.479696 -2.45054,-3.033981 l -1.72121,-0.904359 V 22.62203 H 128.4385 V 5.1182952 h 9.71463 q 2.77144,0 4.43431,1.050224 2.01294,1.2836072 2.01294,3.8799948 0,1.808719 -1.16692,2.888116 -0.81685,0.787668 -2.77145,1.51699 1.25445,0.583458 3.23821,3.850822 1.1961,2.158794 2.39219,4.317588 z m -7.29326,-12.194269 q 0,-2.4505225 -3.034,-2.4505225 h -1.77956 V 12.93663 h 1.77956 q 1.31279,0 2.15881,-0.612631 0.87519,-0.641804 0.87519,-1.896238 z m 15.66591,12.194269 h -6.068 V 5.1182952 h 6.068 z m 22.40489,0 h -5.33867 l -7.67251,-9.743746 0.20421,9.743746 h -5.74709 V 5.1182952 h 5.36784 l 7.76003,9.6562268 -0.26256,-9.6562268 h 5.68875 z m 22.02554,-8.839386 q 0,4.230069 -2.59639,6.709764 -2.59639,2.450523 -6.85563,2.450523 -4.23007,0 -6.85563,-2.42135 -2.62556,-2.42135 -2.62556,-6.622246 0,-4.1717228 2.71308,-6.6805917 2.62556,-2.4505228 6.85563,-2.4505228 4.11338,0 6.70976,2.4213499 2.65474,2.5088688 2.65474,6.5930736 z m -5.74706,0.02917 q 0,-1.808719 -0.96271,-2.946462 -0.9627,-1.1669148 -2.74225,-1.1669148 -1.83789,0 -2.77143,1.2252608 -0.87518,1.10857 -0.87518,2.975635 0,1.837892 0.87518,2.917289 0.93354,1.196089 2.71308,1.196089 3.76331,0 3.76331,-4.200897 z"
|
||||
id="text9137"
|
||||
inkscape:label="Marino"
|
||||
aria-label="Marino" /><path
|
||||
d="m 104.7848,29.612184 q 8.86861,0 14.46983,5.4456 5.60122,5.393746 5.60122,14.210437 0,8.505515 -5.18631,13.899254 -5.13446,5.341879 -13.58816,5.341879 H 86.114135 v -38.89717 z m 6.37918,19.500449 q 0,-4.200897 -2.1264,-6.690317 -2.28198,-2.696869 -6.43104,-2.696869 h -2.956187 v 18.774366 h 3.059917 q 4.25279,0 6.43104,-2.645003 2.02267,-2.437559 2.02267,-6.742177 z m 45.19311,19.396721 H 128.71401 V 29.560317 h 27.53935 v 8.92042 H 142.2503 v 5.964233 h 12.65462 v 8.868553 H 142.2503 v 6.327278 h 14.10679 z m 43.5333,-38.949037 -15.40328,38.949037 H 173.18098 L 157.31084,29.560317 h 14.41797 l 7.62387,23.234579 q 0.15559,-0.20745 7.31267,-23.234579 z"
|
||||
id="text1045"
|
||||
style="font-size:85.3333px;font-family:HeadlineNEWS;-inkscape-font-specification:HeadlineNEWS;letter-spacing:-4.66px;white-space:pre;fill:#000000;fill-opacity:1;stroke-width:0.608723"
|
||||
inkscape:label="Dev"
|
||||
aria-label="DEV" /><path
|
||||
d="m 39.967467,0 c -1.24713,0 -2.07854,1.440059 -2.07854,1.440059 l -4.57281,7.920321 17.81611,30.858404 c 4.37185,-0.99615 6.86321,4.80385 3.14145,7.29302 -3.72178,2.48917 -8.13084,-2.02826 -5.54068,-5.68838 v 0 L 31.653287,12.240495 0.47509223,66.242704 c -0.55431396,0.96004 -0.62353496,1.80008 -0.20783896,2.52011 0.41568996,0.72005 1.17784883,1.08004 2.28640583,1.08004 h 9.1456049 l 17.816103,-30.8584 c -3.04862,-3.28806 0.72867,-8.34565 4.74522,-6.36708 4.01656,1.97857 2.30888,8.05564 -2.15596,7.64256 v 0 l -17.079704,29.58292 h 62.356384 c 0,0 1.66283,0 2.2864,-1.08004 0.62353,-1.08005 -0.20784,-2.52011 -0.20784,-2.52011 l -4.57281,-7.92032 h -35.63222 c -1.32322,4.28422 -7.59186,3.5418 -7.88666,-0.92594 -0.29484,-4.46773 5.82195,-6.02738 7.69662,-1.95418 v 0 h 34.15941 L 42.046017,1.440059 c 0,0 -0.83138,-1.440059 -2.07855,-1.440059"
|
||||
style="display:inline;fill:#2096f3;fill-opacity:1;stroke:none;stroke-width:2.37548"
|
||||
id="path395"
|
||||
inkscape:label="triangle"
|
||||
inkscape:transform-center-y="-11.666667" /></g></svg>
|
||||
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="80mm"
|
||||
height="80mm"
|
||||
viewBox="0 0 80 80"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||
sodipodi:docname="triangleblue.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:zoom="2"
|
||||
inkscape:cx="81"
|
||||
inkscape:cy="106.5"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1046"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1"
|
||||
shape-rendering="crispEdges"
|
||||
inkscape:export-bgcolor="#ffffffff" />
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
d="m 40.063302,5.1541583 c -1.24713,0 -2.07854,1.440059 -2.07854,1.440059 l -4.57281,7.9203207 17.81611,30.858401 c 4.37185,-0.996148 6.86321,4.803857 3.14145,7.293026 -3.72178,2.489169 -8.13084,-2.028265 -5.54068,-5.688379 v 0 L 31.749122,17.394653 0.57092766,71.396858 c -0.554314,0.96004 -0.623535,1.80008 -0.207839,2.52011 0.41568997,0.72005 1.17784894,1.08004 2.28640594,1.08004 H 11.795099 L 29.611202,44.138609 c -3.04862,-3.288058 0.72867,-8.345647 4.74522,-6.367078 4.01656,1.97857 2.30888,8.055642 -2.15596,7.642556 v 0 L 15.120758,74.997008 h 62.356384 c 0,0 1.66283,0 2.2864,-1.08004 0.62353,-1.08005 -0.20784,-2.52011 -0.20784,-2.52011 l -4.57281,-7.92032 h -35.63222 c -1.32322,4.28422 -7.59186,3.5418 -7.88666,-0.92594 -0.29484,-4.467728 5.82195,-6.027375 7.69662,-1.95418 v 0 h 34.15941 L 42.141852,6.5942173 c 0,0 -0.83138,-1.440059 -2.07855,-1.440059"
|
||||
style="display:inline;fill:#2096f3;fill-opacity:1;stroke:none;stroke-width:2.37548"
|
||||
id="path395"
|
||||
inkscape:label="triangle"
|
||||
inkscape:transform-center-y="-11.666667" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,79 @@
|
||||
This is the API for my 2023-2024 FBLA Coding & Programming App
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install [Dart SDK](https://dart.dev/get-dart)
|
||||
2. Install [PostgreSQL](https://www.postgresql.org/) and set it up
|
||||
3. Clone the repo
|
||||
```
|
||||
git clone https://git.marinodev.com/MarinoDev/FBLA24.git
|
||||
cd FBLA24/api/
|
||||
```
|
||||
3. Run `dart pub install` to install dart packages
|
||||
|
||||
## Usage
|
||||
|
||||
1. 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
|
||||
2. 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
|
||||
3. 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 postgres;
|
||||
```
|
||||
4. Set environment variables `POSTGRES_ADDRESS` (IP address), `POSTGRES_PORT` (default 5432), `POSTGRES_USERNAME`, and `POSTGRES_PASSWORD` to appropriate information for your postgres database. Also set `SECRET_KEY` to anything you want to genera te JSON Web Tokens.
|
||||
5. 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
|
||||
6. Your database should be all set up! Start the API with `dart run lib/fbla_api.dart` or alternatively, 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.
|
||||
7. Test your api with `dart run test/fbla_api_test.dart`, setting `apiAddress` on line 8 to your api address.
|
||||
@@ -0,0 +1,30 @@
|
||||
# This file configures the static analysis results for your project (errors,
|
||||
# warnings, and lints).
|
||||
#
|
||||
# This enables the 'recommended' set of lints from `package:lints`.
|
||||
# This set helps identify many issues that may lead to problems when running
|
||||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
||||
# style and format.
|
||||
#
|
||||
# If you want a smaller set of lints you can change this to specify
|
||||
# 'package:lints/core.yaml'. These are just the most critical lints
|
||||
# (the recommended set includes the core lints).
|
||||
# The core lints are also what is used by pub.dev for scoring packages.
|
||||
|
||||
include: package:lints/recommended.yaml
|
||||
|
||||
# Uncomment the following section to specify additional rules.
|
||||
|
||||
# linter:
|
||||
# rules:
|
||||
# - camel_case_types
|
||||
|
||||
# analyzer:
|
||||
# exclude:
|
||||
# - path/to/excluded/files/**
|
||||
|
||||
# For more information about the core and recommended set of lints, see
|
||||
# https://dart.dev/go/core-lints
|
||||
|
||||
# For additional information about configuring this file, see
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
@@ -0,0 +1,25 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEQzCCAyugAwIBAgISA1MOaRzFLZim3nvjG7iscMdEMA0GCSqGSIb3DQEBCwUA
|
||||
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
|
||||
EwJSMzAeFw0yMzEyMTQyMjI5NTVaFw0yNDAzMTMyMjI5NTRaMCAxHjAcBgNVBAMT
|
||||
FWhvbWVsYWIubWFyaW5vZGV2LmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA
|
||||
BER7NDX7FANFf72Pqwl5haoczQchiOhMGNyMa5foT0aYG2DeMQeEhpl+17vBzEwu
|
||||
KewujegQNWZdNHVbGxqdUmWjggIuMIICKjAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0l
|
||||
BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYE
|
||||
FOsys6fx3sqsaEaqklTWasLzlNJzMB8GA1UdIwQYMBaAFBQusxe3WFbLrlAJQOYf
|
||||
r52LFMLGMFUGCCsGAQUFBwEBBEkwRzAhBggrBgEFBQcwAYYVaHR0cDovL3IzLm8u
|
||||
bGVuY3Iub3JnMCIGCCsGAQUFBzAChhZodHRwOi8vcjMuaS5sZW5jci5vcmcvMDgG
|
||||
A1UdEQQxMC+CFWhvbWVsYWIubWFyaW5vZGV2LmNvbYIWbWFyaW5vLW5hcy5zeW5v
|
||||
bG9neS5tZTATBgNVHSAEDDAKMAgGBmeBDAECATCCAQMGCisGAQQB1nkCBAIEgfQE
|
||||
gfEA7wB2AEiw42vapkc0D+VqAvqdMOscUgHLVt0sgdm7v6s52IRzAAABjGqqUTkA
|
||||
AAQDAEcwRQIhAJncD2v9CgQii1KCLJhILJ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kh+BIm
|
||||
lJNXoB1lBMEKIq4QDUOXoRgffuDghje1WrG9ML+Hbisq/yFOGwXD9RiX8F6sw6W4
|
||||
avAuvDszue5L3sz85K+EC4Y/wFVDNvZo4TYXao6Z0f+lQKc0t8DQYzk1OXVu8rp2
|
||||
yJMC6alLbBfODALZvYH7n7do1AZls4I9d1P4jnkDrQoxB3UqQ9hVl3LEKQ73xF1O
|
||||
yK5GhDDX8oVfGKF5u+decIsH4YaTw7mP3GFxJSqv3+0lUFJoi5Lc5da149p90Ids
|
||||
hCExroL1+7mryIkXPeFM5TgO9r0rvZaBFOvV2z0gp35Z0+L4WPlbuEjN/lxPFin+
|
||||
HlUjr8gRsI3qfJOQFy/9rKIJR0Y/8Omwt/8oTWgy1mdeHmmjk7j1nYsvC9JSQ6Zv
|
||||
MldlTTKB3zhThV1+XWYp6rjd5JW1zbVWEkLNxE7GJThEUG3szgBVGP7pSWTUTsqX
|
||||
nLRbwHOoq7hHwg==
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFYDCCBEigAwIBAgIQQAF3ITfU6UK47naqPGQKtzANBgkqhkiG9w0BAQsFADA/
|
||||
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
||||
DkRTVCBSb290IENBIFgzMB4XDTIxMDEyMDE5MTQwM1oXDTI0MDkzMDE4MTQwM1ow
|
||||
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
||||
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwggIiMA0GCSqGSIb3DQEB
|
||||
AQUAA4ICDwAwggIKAoICAQCt6CRz9BQ385ueK1coHIe+3LffOJCMbjzmV6B493XC
|
||||
ov71am72AE8o295ohmxEk7axY/0UEmu/H9LqMZshftEzPLpI9d1537O4/xLxIZpL
|
||||
wYqGcWlKZmZsj348cL+tKS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IDAeMBygGqAYhhZodHRw
|
||||
Oi8veDEuYy5sZW5jci5vcmcvMCIGA1UdIAQbMBkwCAYGZ4EMAQIBMA0GCysGAQQB
|
||||
gt8TAQEBMA0GCSqGSIb3DQEBCwUAA4ICAQCFyk5HPqP3hUSFvNVneLKYY611TR6W
|
||||
PTNlclQtgaDqw+34IL9fzLdwALduO/ZelN7kIJ+m74uyA+eitRY8kc607TkC53wl
|
||||
ikfmZW4/RvTZ8M6UK+5UzhK8jCdLuMGYL6KvzXGRSgi3yLgjewQtCPkIVz6D2QQz
|
||||
CkcheAmCJ8MqyJu5zlzyZMjAvnnAT45tRAxekrsu94sQ4egdRCnbWSDtY7kh+BIm
|
||||
lJNXoB1lBMEKIq4QDUOXoRgffuDghje1WrG9ML+Hbisq/yFOGwXD9RiX8F6sw6W4
|
||||
avAuvDszue5L3sz85K+EC4Y/wFVDNvZo4TYXao6Z0f+lQKc0t8DQYzk1OXVu8rp2
|
||||
yJMC6alLbBfODALZvYH7n7do1AZls4I9d1P4jnkDrQoxB3UqQ9hVl3LEKQ73xF1O
|
||||
yK5GhDDX8oVfGKF5u+decIsH4YaTw7mP3GFxJSqv3+0lUFJoi5Lc5da149p90Ids
|
||||
hCExroL1+7mryIkXPeFM5TgO9r0rvZaBFOvV2z0gp35Z0+L4WPlbuEjN/lxPFin+
|
||||
HlUjr8gRsI3qfJOQFy/9rKIJR0Y/8Omwt/8oTWgy1mdeHmmjk7j1nYsvC9JSQ6Zv
|
||||
MldlTTKB3zhThV1+XWYp6rjd5JW1zbVWEkLNxE7GJThEUG3szgBVGP7pSWTUTsqX
|
||||
nLRbwHOoq7hHwg==
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFYDCCBEigAwIBAgIQQAF3ITfU6UK47naqPGQKtzANBgkqhkiG9w0BAQsFADA/
|
||||
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
||||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Jl
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -0,0 +1,15 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
fbla_api:
|
||||
image: fbla-api
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- /var/jenkins_home/logos:/root/FBLA24/fbla-api/logos
|
||||
environment:
|
||||
- POSTGRES_USERNAME
|
||||
- POSTGRES_PASSWORD
|
||||
- SECRET_KEY
|
||||
- POSTGRES_ADDRESS
|
||||
- POSTGRES_PORT
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'package:argon2/argon2.dart';
|
||||
import 'dart:io';
|
||||
import 'package:postgres/postgres.dart';
|
||||
|
||||
String username = 'admin';
|
||||
String password = 'password';
|
||||
|
||||
var r = Random.secure();
|
||||
String randomSalt = String.fromCharCodes(List.generate(32, (index) => r.nextInt(33) + 89));
|
||||
final salt = randomSalt.toBytesLatin1();
|
||||
|
||||
var parameters = Argon2Parameters(
|
||||
Argon2Parameters.ARGON2_i,
|
||||
salt,
|
||||
version: Argon2Parameters.ARGON2_VERSION_10,
|
||||
iterations: 2,
|
||||
memoryPowerOf2: 16,
|
||||
);
|
||||
|
||||
final postgres = PostgreSQLConnection(
|
||||
Platform.environment['POSTGRES_ADDRESS']!,
|
||||
int.parse(Platform.environment['POSTGRES_PORT']!),
|
||||
'fbla',
|
||||
username: Platform.environment['POSTGRES_USERNAME'],
|
||||
password: Platform.environment['POSTGRES_PASSWORD'],
|
||||
);
|
||||
|
||||
Future<void> main() async {
|
||||
await postgres.open();
|
||||
var argon2 = Argon2BytesGenerator();
|
||||
argon2.init(parameters);
|
||||
|
||||
var passwordBytes = parameters.converter.convert(password);
|
||||
var result = Uint8List(32);
|
||||
argon2.generateBytes(passwordBytes, result);
|
||||
var resultHex = result.toHexString();
|
||||
|
||||
postgres.query(
|
||||
'''
|
||||
INSERT INTO public.users (username, password_hash, salt)
|
||||
VALUES ('$username', '$resultHex', '$randomSalt')
|
||||
'''
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,472 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
||||
import 'package:postgres/postgres.dart';
|
||||
import 'package:shelf/shelf.dart';
|
||||
import 'package:shelf/shelf_io.dart' as io;
|
||||
import 'package:shelf_router/shelf_router.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:argon2/argon2.dart';
|
||||
|
||||
|
||||
SecretKey secretKey = SecretKey(Platform.environment['SECRET_KEY']!);
|
||||
|
||||
enum BusinessType {
|
||||
food,
|
||||
shop,
|
||||
outdoors,
|
||||
manufacturing,
|
||||
other,
|
||||
}
|
||||
|
||||
class Business {
|
||||
int id;
|
||||
String name;
|
||||
String description;
|
||||
BusinessType type;
|
||||
String website;
|
||||
String contactName;
|
||||
String contactEmail;
|
||||
String contactPhone;
|
||||
String notes;
|
||||
String locationName;
|
||||
String locationAddress;
|
||||
|
||||
Business({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.type,
|
||||
required this.website,
|
||||
required this.contactName,
|
||||
required this.contactEmail,
|
||||
required this.contactPhone,
|
||||
required this.notes,
|
||||
required this.locationName,
|
||||
required this.locationAddress,
|
||||
});
|
||||
|
||||
factory Business.fromJson(Map<String, dynamic> json) {
|
||||
bool typeValid = true;
|
||||
try {
|
||||
BusinessType.values.byName(json['type']);
|
||||
} catch (e) {
|
||||
typeValid = false;
|
||||
}
|
||||
return Business(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
type: typeValid
|
||||
? BusinessType.values.byName(json['type'])
|
||||
: BusinessType.other,
|
||||
website: json['website'],
|
||||
contactName: json['contactName'],
|
||||
contactEmail: json['contactEmail'],
|
||||
contactPhone: json['contactPhone'],
|
||||
notes: json['notes'],
|
||||
locationName: json['locationName'],
|
||||
locationAddress: json['locationAddress'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> fetchBusinessData() async {
|
||||
final result = await postgres.query(
|
||||
'''
|
||||
SELECT json_agg(
|
||||
json_build_object(
|
||||
'id', id,
|
||||
'name', name,
|
||||
'description', description,
|
||||
'type', type,
|
||||
'website', website,
|
||||
'contactName', "contactName",
|
||||
'contactEmail', "contactEmail",
|
||||
'contactPhone', "contactPhone",
|
||||
'notes', notes,
|
||||
'locationName', "locationName",
|
||||
'locationAddress', "locationAddress"
|
||||
)
|
||||
) FROM businesses
|
||||
'''
|
||||
);
|
||||
|
||||
var encoded = json.encode(result);
|
||||
var decoded = json.decode(encoded);
|
||||
encoded = json.encode(decoded[0][0]);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
//set defaults
|
||||
String _hostname = 'localhost';
|
||||
const _port = 8000;
|
||||
|
||||
|
||||
final postgres = PostgreSQLConnection(
|
||||
Platform.environment['POSTGRES_ADDRESS']!,
|
||||
int.parse(Platform.environment['POSTGRES_PORT']!),
|
||||
'fbla',
|
||||
username: Platform.environment['POSTGRES_USERNAME'],
|
||||
password: Platform.environment['POSTGRES_PASSWORD'],
|
||||
);
|
||||
|
||||
|
||||
|
||||
void main() async {
|
||||
await postgres.open();
|
||||
|
||||
final app = Router();
|
||||
|
||||
// routes
|
||||
app.get('/fbla-api/hello', (Request request) async {
|
||||
print('Hello received');
|
||||
|
||||
return Response.ok(
|
||||
'Hello, World!',
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
});
|
||||
app.get('/fbla-api/businessdata', (Request request) async {
|
||||
print('business data request received');
|
||||
final output = await fetchBusinessData();
|
||||
return Response.ok(
|
||||
output.toString(),
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
});
|
||||
app.get('/fbla-api/logos/<logo>', (Request request, String logoId) {
|
||||
print('business logo request received');
|
||||
|
||||
var logo = File('logos/$logoId.png');
|
||||
List<int> content = logo.readAsBytesSync();
|
||||
|
||||
return Response.ok(
|
||||
content,
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Content-Type': 'image/png'
|
||||
},
|
||||
);
|
||||
});
|
||||
app.post('/fbla-api/createbusiness', (Request request) async {
|
||||
print('create business request received');
|
||||
|
||||
final payload = await request.readAsString();
|
||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
||||
try {
|
||||
JWT.verify(auth!, secretKey);
|
||||
var json = jsonDecode(payload);
|
||||
Business business = Business.fromJson(json);
|
||||
|
||||
await postgres.query(
|
||||
'''
|
||||
INSERT INTO businesses (name, description, type, website, "contactName", "contactPhone", "contactEmail", notes, "locationName", "locationAddress")
|
||||
VALUES ('${business.name.replaceAll("'", "''")}', '${business.description.replaceAll("'", "''")}', '${business.type.name}', '${business.website}', '${business.contactName.replaceAll("'", "''")}', '${business.contactPhone}', '${business.contactEmail}', '${business.notes.replaceAll("'", "''")}', '${business.locationName.replaceAll("'", "''")}', '${business.locationAddress.replaceAll("'", "''")}')
|
||||
'''
|
||||
);
|
||||
|
||||
final dbBusiness = await postgres.query(
|
||||
'''SELECT * FROM public.businesses
|
||||
ORDER BY id DESC LIMIT 1''');
|
||||
var id = dbBusiness[0][0];
|
||||
var logoResponse = await http.get(
|
||||
Uri.http('logo.clearbit.com', '/${business.website}'),
|
||||
);
|
||||
|
||||
if (logoResponse.headers.toString().contains('image/png')) {
|
||||
await File('logos/$id.png').writeAsBytes(logoResponse.bodyBytes);
|
||||
}
|
||||
return Response.ok(
|
||||
id.toString(),
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
} on JWTExpiredException {
|
||||
print('JWT Expired');
|
||||
} on JWTException catch (e) {
|
||||
print(e.message);
|
||||
}
|
||||
|
||||
return Response.unauthorized(
|
||||
'unauthorized',
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
});
|
||||
app.post('/fbla-api/deletebusiness', (Request request) async {
|
||||
print('delete business request received');
|
||||
|
||||
|
||||
final payload = await request.readAsString();
|
||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
||||
try {
|
||||
JWT.verify(auth!, secretKey);
|
||||
var json = jsonDecode(payload);
|
||||
var id = json['id'];
|
||||
|
||||
await postgres.query(
|
||||
'''
|
||||
DELETE FROM public.businesses
|
||||
WHERE id IN
|
||||
($id);
|
||||
'''
|
||||
);
|
||||
|
||||
try{
|
||||
await File('logos/$id.png').delete();
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
return Response.ok(
|
||||
id.toString(),
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
} on JWTExpiredException {
|
||||
print('JWT Expired');
|
||||
} on JWTException catch (e) {
|
||||
print(e.message);
|
||||
}
|
||||
|
||||
return Response.unauthorized(
|
||||
'unauthorized',
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
});
|
||||
app.post('/fbla-api/editbusiness', (Request request) async {
|
||||
print('edit business request received');
|
||||
|
||||
final payload = await request.readAsString();
|
||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
||||
try {
|
||||
JWT.verify(auth!, secretKey);
|
||||
|
||||
var json = jsonDecode(payload);
|
||||
Business business = Business.fromJson(json);
|
||||
|
||||
await postgres.query(
|
||||
'''
|
||||
UPDATE businesses SET
|
||||
name = '${business.name.replaceAll("'", "''")}'::text, description = '${business.description.replaceAll("'", "''")}'::text, website = '${business.website}'::text, type = '${business.type.name}'::text, "contactName" = '${business.contactName.replaceAll("'", "''")}'::text, "contactPhone" = '${business.contactPhone}'::text, "contactEmail" = '${business.contactEmail}'::text, notes = '${business.notes.replaceAll("'", "''")}'::text, "locationName" = '${business.locationName.replaceAll("'", "''")}'::text, "locationAddress" = '${business.locationAddress.replaceAll("'", "''")}'::text WHERE
|
||||
id = ${business.id};
|
||||
'''
|
||||
);
|
||||
|
||||
var logoResponse = await http.get(
|
||||
Uri.http('logo.clearbit.com', '/${business.website}'),
|
||||
);
|
||||
|
||||
try {
|
||||
await File('logos/${business.id}.png').delete();
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
if (logoResponse.headers.toString().contains('image/png')) {
|
||||
await File('logos/${business.id}.png').writeAsBytes(logoResponse.bodyBytes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Response.ok(
|
||||
business.id.toString(),
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
} on JWTExpiredException {
|
||||
print('JWT Expired');
|
||||
} on JWTException catch (e) {
|
||||
print(e.message);
|
||||
}
|
||||
|
||||
return Response.unauthorized(
|
||||
'unauthorized',
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
});
|
||||
app.post('/fbla-api/signin', (Request request) async {
|
||||
print('signin request received');
|
||||
|
||||
final payload = await request.readAsString();
|
||||
var json = jsonDecode(payload);
|
||||
var username = json['username'];
|
||||
var password = json['password'];
|
||||
|
||||
var saltDb = await postgres.query(
|
||||
'SELECT salt FROM users WHERE username=\'$username\''
|
||||
);
|
||||
if (saltDb.isEmpty) {
|
||||
return Response.unauthorized(
|
||||
'invalid username',
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
}
|
||||
|
||||
var saltString = saltDb[0][0].toString();
|
||||
var salt = saltString.toBytesLatin1();
|
||||
|
||||
var parameters = Argon2Parameters(
|
||||
Argon2Parameters.ARGON2_i,
|
||||
salt,
|
||||
version: Argon2Parameters.ARGON2_VERSION_10,
|
||||
iterations: 2,
|
||||
memoryPowerOf2: 16,
|
||||
);
|
||||
var argon2 = Argon2BytesGenerator();
|
||||
argon2.init(parameters);
|
||||
|
||||
var passwordBytes = parameters.converter.convert(password);
|
||||
var result = Uint8List(32);
|
||||
argon2.generateBytes(passwordBytes, result);
|
||||
var resultHex = result.toHexString();
|
||||
|
||||
var passwordHashDb = await postgres.query(
|
||||
'SELECT password_hash FROM users WHERE username=\'$username\''
|
||||
);
|
||||
var passwordHash = passwordHashDb[0][0].toString();
|
||||
|
||||
if (passwordHash == resultHex) {
|
||||
|
||||
final jwt = JWT(
|
||||
{
|
||||
'username': username
|
||||
},
|
||||
);
|
||||
final token = jwt.sign(secretKey);
|
||||
try {
|
||||
JWT.verify(token, secretKey);
|
||||
} on JWTExpiredException {
|
||||
print('JWT Expired');
|
||||
} on JWTException catch (e) {
|
||||
print(e.message);
|
||||
}
|
||||
|
||||
return Response.ok(
|
||||
token.toString(),
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
|
||||
} else {
|
||||
return Response.unauthorized(
|
||||
'invalid password',
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
}
|
||||
});
|
||||
app.post('/fbla-api/createuser', (Request request) async {
|
||||
print('create user request received');
|
||||
|
||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
||||
final payload = await request.readAsString();
|
||||
|
||||
try {
|
||||
JWT.verify(auth!, secretKey);
|
||||
|
||||
var json = jsonDecode(payload);
|
||||
var username = json['username'];
|
||||
var password = json['password'];
|
||||
|
||||
var r = Random.secure();
|
||||
String randomSalt = String.fromCharCodes(List.generate(32, (index) => r.nextInt(33) + 89));
|
||||
final salt = randomSalt.toBytesLatin1();
|
||||
|
||||
var parameters = Argon2Parameters(
|
||||
Argon2Parameters.ARGON2_i,
|
||||
salt,
|
||||
version: Argon2Parameters.ARGON2_VERSION_10,
|
||||
iterations: 2,
|
||||
memoryPowerOf2: 16,
|
||||
);
|
||||
var argon2 = Argon2BytesGenerator();
|
||||
argon2.init(parameters);
|
||||
|
||||
var passwordBytes = parameters.converter.convert(password);
|
||||
var result = Uint8List(32);
|
||||
argon2.generateBytes(passwordBytes, result);
|
||||
var resultHex = result.toHexString();
|
||||
|
||||
postgres.query(
|
||||
'''
|
||||
INSERT INTO public.users (username, password_hash, salt)
|
||||
VALUES ('$username', '$resultHex', '$randomSalt')
|
||||
'''
|
||||
);
|
||||
|
||||
return Response.ok(
|
||||
username,
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
|
||||
} on JWTExpiredException {
|
||||
print('JWT Expired');
|
||||
} on JWTException catch (e) {
|
||||
print(e.message);
|
||||
}
|
||||
|
||||
return Response.unauthorized(
|
||||
'unauthorized',
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
});
|
||||
app.post('/fbla-api/deleteuser', (Request request) async {
|
||||
print('delete user request received');
|
||||
|
||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
||||
final payload = await request.readAsString();
|
||||
|
||||
try {
|
||||
JWT.verify(auth!, secretKey);
|
||||
|
||||
var json = jsonDecode(payload);
|
||||
var username = json['username'];
|
||||
|
||||
postgres.query(
|
||||
'''
|
||||
DELETE FROM public.users
|
||||
WHERE username IN ('$username');
|
||||
'''
|
||||
);
|
||||
|
||||
return Response.ok(
|
||||
username,
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
|
||||
} on JWTExpiredException {
|
||||
print('JWT Expired');
|
||||
} on JWTException catch (e) {
|
||||
print(e.message);
|
||||
}
|
||||
|
||||
return Response.unauthorized(
|
||||
'unauthorized',
|
||||
headers: {'Access-Control-Allow-Origin': '*'},
|
||||
);
|
||||
});
|
||||
app.get('/fbla-api/marinodev', (Request request) async {
|
||||
print('marinodev request received');
|
||||
|
||||
var logo = File('MarinoDev.svg');
|
||||
List<int> content = logo.readAsBytesSync();
|
||||
|
||||
return Response.ok(
|
||||
content,
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Content-Type': 'image/svg+xml'
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
// get ip address for hosting
|
||||
for (var interface in await NetworkInterface.list()) {
|
||||
for (var addr in interface.addresses) {
|
||||
if (addr.type == InternetAddressType.IPv4) {
|
||||
_hostname = addr.address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final server = await io.serve(app, _hostname, _port);
|
||||
|
||||
print('Serving at http://${server.address.host}:${server.port}');
|
||||
}
|
||||
@@ -0,0 +1,509 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
_fe_analyzer_shared:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "64.0.0"
|
||||
adaptive_number:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: adaptive_number
|
||||
sha256: "3a567544e9b5c9c803006f51140ad544aedc79604fd4f3f2c1380003f97c1d77"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.2.0"
|
||||
argon2:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: argon2
|
||||
sha256: ee456fa6f71392faadd9c43f4a2cc66c8d56132337fe71dc09d217d4e994102e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.2"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
buffer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: buffer
|
||||
sha256: "8962c12174f53e2e848a6acd7ac7fd63d8a1a6a316c20c458a832d87eba5422a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.18.0"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
coverage:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: coverage
|
||||
sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.6.3"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
dart_jsonwebtoken:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dart_jsonwebtoken
|
||||
sha256: "6703695f581fc54d0a7e5f281c5538735167605bb9e5abd208c8b330625a92b1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.12.1"
|
||||
ed25519_edwards:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ed25519_edwards
|
||||
sha256: "6ce0112d131327ec6d42beede1e5dfd526069b18ad45dcf654f15074ad9276cd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fixnum
|
||||
sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: frontend_server_client
|
||||
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: glob
|
||||
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
hex:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: hex
|
||||
sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: http
|
||||
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
http_methods:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_methods
|
||||
sha256: "6bccce8f1ec7b5d701e7921dca35e202d425b57e317ba1a37f2638590e29e566"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
http_multi_server:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_multi_server
|
||||
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.2"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: io
|
||||
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.7"
|
||||
lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: lints
|
||||
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.16"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mime
|
||||
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
node_preamble:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: node_preamble
|
||||
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_config
|
||||
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.3"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
pointycastle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pointycastle
|
||||
sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.7.3"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pool
|
||||
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.1"
|
||||
postgres:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: postgres
|
||||
sha256: "98457afc06dd3f9d6892c178ea03ca9659e454107c9be90111e607691998d70d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.2"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
sasl_scram:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sasl_scram
|
||||
sha256: a47207a436eb650f8fdcf54a2e2587b850dc3caef9973ce01f332b07a6fc9cb9
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.1"
|
||||
saslprep:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: saslprep
|
||||
sha256: "79c9e163a82f55da542feaf0f7a59031e74493299c92008b2b404cd88d639bb4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
shelf:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: shelf
|
||||
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
shelf_packages_handler:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_packages_handler
|
||||
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
shelf_router:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: shelf_router
|
||||
sha256: f5e5d492440a7fb165fe1e2e1a623f31f734d3370900070b2b1e0d0428d59864
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.4"
|
||||
shelf_static:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_static
|
||||
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
shelf_web_socket:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_web_socket
|
||||
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
source_map_stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_map_stack_trace
|
||||
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
source_maps:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_maps
|
||||
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.10.12"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
test:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: test
|
||||
sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.24.6"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.1"
|
||||
test_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_core
|
||||
sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.6"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
unorm_dart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: unorm_dart
|
||||
sha256: "5b35bff83fce4d76467641438f9e867dc9bcfdb8c1694854f230579d68cd8f4b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: "0fae432c85c4ea880b33b497d32824b97795b04cdaa74d270219572a1f50268d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.9.0"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: watcher
|
||||
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket_channel
|
||||
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
webkit_inspection_protocol:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webkit_inspection_protocol
|
||||
sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.0.6 <4.0.0"
|
||||
@@ -0,0 +1,21 @@
|
||||
name: fbla_api
|
||||
description: A sample command-line application.
|
||||
version: 1.0.0
|
||||
# repository: https://github.com/my_org/my_repo
|
||||
|
||||
environment:
|
||||
sdk: ^3.0.6
|
||||
|
||||
# Add regular dependencies here.
|
||||
dependencies:
|
||||
argon2: ^1.0.1
|
||||
dart_jsonwebtoken: ^2.12.1
|
||||
http: ^1.1.0
|
||||
postgres: ^2.6.2
|
||||
shelf: ^1.4.1
|
||||
shelf_router: ^1.1.4
|
||||
# path: ^1.8.0
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^2.0.0
|
||||
test: ^1.21.0
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'dart:convert';
|
||||
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
||||
import 'package:fbla_api/fbla_api.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:io';
|
||||
|
||||
final apiAddress = 'https://homelab.marinodev.com';
|
||||
SecretKey secretKey = SecretKey(Platform.environment['SECRET_KEY']!);
|
||||
|
||||
void main() async{
|
||||
final jwt = JWT(
|
||||
{
|
||||
'username': 'tmp'
|
||||
},
|
||||
);
|
||||
final token = jwt.sign(secretKey);
|
||||
|
||||
test('hello', () async {
|
||||
var response = await http
|
||||
.get(Uri.parse('$apiAddress/fbla-api/hello'))
|
||||
.timeout(const Duration(seconds: 20));
|
||||
var output = response.body;
|
||||
|
||||
expect(response.statusCode, 200);
|
||||
expect(output, 'Hello, World!');
|
||||
});
|
||||
test('business-data', () async {
|
||||
var response = await http
|
||||
.get(Uri.parse('$apiAddress/fbla-api/businessdata'))
|
||||
.timeout(const Duration(seconds: 20));
|
||||
var output = response.body;
|
||||
|
||||
expect(response.statusCode, 200);
|
||||
for (var jsonBusiness in jsonDecode(output)) {
|
||||
Business.fromJson(jsonBusiness);
|
||||
}
|
||||
});
|
||||
test('create-user', () async {
|
||||
var json = '''
|
||||
{
|
||||
"username": "tmp",
|
||||
"password": "tmp"
|
||||
}
|
||||
''';
|
||||
var response = await http.post(Uri.parse('$apiAddress, /fbla-api/createuser'),
|
||||
body: json,
|
||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
||||
expect(response.statusCode, 200);
|
||||
expect(response.body, 'tmp');
|
||||
});
|
||||
test('sign-in', () async{
|
||||
var json = '''
|
||||
{
|
||||
"username": "tmp",
|
||||
"password": "tmp"
|
||||
}
|
||||
''';
|
||||
var response = await http.post(
|
||||
Uri.parse('$apiAddress/fbla-api/signin'),
|
||||
body: json,
|
||||
);
|
||||
|
||||
expect(response.statusCode, 200);
|
||||
expect(JWT.decode(response.body).payload['username'], 'tmp');
|
||||
});
|
||||
test('delete-user', () async{
|
||||
var json = '''
|
||||
{
|
||||
"username": "tmp"
|
||||
}
|
||||
''';
|
||||
var response = await http.post(
|
||||
Uri.parse('$apiAddress/fbla-api/deleteuser'),
|
||||
body: json,
|
||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20)
|
||||
);
|
||||
expect(response.statusCode, 200);
|
||||
expect(response.body, 'tmp');
|
||||
});
|
||||
test('create-delete-business', () async {
|
||||
var json = '''
|
||||
{
|
||||
"id": 0,
|
||||
"name": "tmp",
|
||||
"description": "tmp",
|
||||
"type": "business",
|
||||
"website": "tmp",
|
||||
"contactName": "tmp",
|
||||
"contactEmail": "tmp",
|
||||
"contactPhone": "tmp",
|
||||
"notes": "tmp",
|
||||
"locationName": "tmp",
|
||||
"locationAddress": "tmp"
|
||||
}
|
||||
''';
|
||||
var response = await http.post(Uri.parse('$apiAddress/fbla-api/createbusiness'),
|
||||
body: json,
|
||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
||||
|
||||
expect(response.statusCode, 200);
|
||||
|
||||
String responseId = response.body;
|
||||
int id = int.parse(responseId);
|
||||
|
||||
json = '''
|
||||
{
|
||||
"id": $id
|
||||
}
|
||||
''';
|
||||
response = await http.post(Uri.parse('$apiAddress/fbla-api/deletebusiness'),
|
||||
body: json,
|
||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
||||
|
||||
expect(response.statusCode, 200);
|
||||
expect(int.parse(response.body), id);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user