@onereach/types-hitl-api 0.0.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +75 -0
  2. package/package.json +9 -0
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ ## Getting Started
2
+
3
+ In this section we are going to explain how to run the application locally, without (almost) any OneReach dependencies.
4
+
5
+ #### Make sure OneReach NPM token is available
6
+
7
+ In order to install some dependencies you are going to need a valid token available as a variable - `OR_NPM_TOKEN`. If it is not available using `echo $OR_NPM_TOKEN` - you should ask someone to help you setup access to OneReach NPM.
8
+
9
+ #### Installing local PostgreSQL
10
+
11
+ If you already have a local PostgreSQL installed, or know how to do so - you are free to go to the next section.
12
+
13
+ The easiest way to install a local database - is by using **Docker** - [Install Docker Desktop](https://www.docker.com/products/docker-desktop). After making sure **Docker** is installed and is available through command line as `docker` - we can proceed with installing and creating a local database.
14
+
15
+ Run the following commands (and replace `mysecretpassword` here and in the examples below with an actual password):
16
+
17
+ ```
18
+ docker pull postgres
19
+ docker run --name postgresql-local -e POSTGRES_USER=hitl-app -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=hitl-app-db -p 5432:5432 -d postgres
20
+ ```
21
+
22
+ You should be able to connect to this database using command (enter the password, if it is asked):
23
+
24
+ ```
25
+ docker exec -it postgresql-local psql hitl-app-db -U hitl-app -W
26
+ ```
27
+
28
+ #### Connecting to the local database
29
+
30
+ Create a file named `.env` in the project root directory with the following content:
31
+
32
+ ```
33
+ APP_DEV_PORT=8080
34
+ DB_USER=hitl-app
35
+ DB_PASSWORD=mysecretpassword
36
+ DB_HOST=localhost
37
+ DB_PORT=5432
38
+ DB_NAME=hitl-app-db
39
+ ```
40
+
41
+ You can change all the values above, if you want to, just make sure that the variables in `.env` file point to some valid PostgreSQL instance.
42
+
43
+ #### Installing packages and starting the application
44
+
45
+ After installing third party dependencies, we can finally run:
46
+
47
+ ```
48
+ echo "{ \"vars\": { \"SDK_API_URL\": \"\" } }" > config.json
49
+ npm install
50
+ npm start
51
+ ```
52
+
53
+ This will start the application in the development mode as a simple `express` server. Changes to the code will be tracked and server will restart automatically.
54
+
55
+ An almost empty `config.json` file is required to build the application. In order to run the application on AWS, we are going to need real env variables that we are going to retrieve later.
56
+
57
+ Server now is ready to accept requests, but it will probably fail on every attempt to access database. In order to read and write from database we need to send a request to create or update our SQL tables.
58
+
59
+ In order to run all migrations to the latest version, run the following request in the console (or in Postman):
60
+
61
+ ```
62
+ curl --location --request POST 'http://localhost:8080/api/v1/migrations' --header 'Authorization: user'
63
+ ```
64
+
65
+ After successful response you should be able to send all other requests.
66
+
67
+ #### Testings the application
68
+
69
+ In order to verify that (most of) the application logic works, you should run:
70
+
71
+ ```
72
+ npm test
73
+ ```
74
+
75
+ If all tests pass successfully - congratulations, this means that the local deployment was successful.
package/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@onereach/types-hitl-api",
3
+ "version": "0.0.1-rc.0",
4
+ "author": "OneReach.ai",
5
+ "main": "./dist/types/index.types.d.ts",
6
+ "files": [
7
+ "./dist/types/**/*"
8
+ ]
9
+ }