From 7a3b8cebcf3de450b0c825a1aa068ed3ecde2be3 Mon Sep 17 00:00:00 2001 From: RA341 Date: Thu, 22 Feb 2024 15:40:06 -0500 Subject: [PATCH 1/2] updated readme for shared modules and added a note for running postgres locally --- devU-api/README.md | 43 ++++++++++++++++++++++++++++--------------- devu-shared/README.md | 2 ++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/devU-api/README.md b/devU-api/README.md index f8c2438c..3f5bafad 100644 --- a/devU-api/README.md +++ b/devU-api/README.md @@ -15,6 +15,20 @@ For now the only reason we're including docker is to more easily control the dev Once you've got these installed, we can build our container and run it +#### Note to run the postgres container locally using the command below + +You have to modify ``devU-api/src/environment.ts`` + +change + +``dbHost: (load('database.host') || 'localhost') as string`` + +to + +``dbHost: 'localhost'`` + +This will probably be fixed in the future but for now the above steps are necessary + ``` docker run \ --name typeorm-postgres \ @@ -145,29 +159,28 @@ The database models live outside of this control flow as they don't deal with an ### Shared Modules -This project uses shared modules between it and it's client. What this means is that there exists code that operates in both this project and it's client. That project is being imported here as `devu-shared-modules`. +This project uses shared modules to share types between the api and the client. What this means is that there exists +code that operates in both this project and it's client. That project is being imported here as `devu-shared-modules`. -The project can be found [here](https://github.com/UBAutograding/devu-shared). +To generate types for local development you must go to the ``/devu-shared`` directory -When developing if you need to update the modules, you can do so by updating the branch or SHA on the package url in the `package.json`. As an example, if you wanted to use shared modules from the `auth` branch, you could change the dependency line in the `package.json` to: +1. run ```npm install``` (if you haven't already) +2. run ```npm run build-local``` -``` -"devu-shared-modules": "github:UBAutograding/devu-shared#auth", -``` +This command will create a ``devu-shared-modules`` folder in api and client dir -then rerun +When developing if you need to update the modules, -``` -npm install -``` +1. create the type in ``devu-shared/src/types/example.type.ts`` +2. export the type in ``devu-shared/src/index.ts`` +3. rerun ``npm run build-local`` -to install the updated package +This will update the types in the api and client folders. -If you were to make changes to your shared branch and push it to the remote, you can update what version your local files are looking at via +#### Note if the types are not being detected by your IDE -``` -npm update devu-shared-modules -``` +Go to the ``devU-api/`` and ``devU-client/`` and run ``npm install`` to update the shared modules for the individual +project ### Testing diff --git a/devu-shared/README.md b/devu-shared/README.md index 34b159a0..56f1fcf9 100644 --- a/devu-shared/README.md +++ b/devu-shared/README.md @@ -2,6 +2,8 @@ This project exists as a shared resource between the DevU api and client projects +For usage [see](/devu-shared/README.md#devu-shared-modules) + ## Project Dependencies (install these) - [Node](https://nodejs.org/en/) - A javascript interpreter to run JS outside of the browser From 5945b71d1c40b13af8848eeb0d713e64d2fa501e Mon Sep 17 00:00:00 2001 From: RA341 Date: Thu, 22 Feb 2024 21:33:42 -0500 Subject: [PATCH 2/2] formatting --- devU-api/README.md | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/devU-api/README.md b/devU-api/README.md index 3f5bafad..c976ec94 100644 --- a/devU-api/README.md +++ b/devU-api/README.md @@ -162,25 +162,34 @@ The database models live outside of this control flow as they don't deal with an This project uses shared modules to share types between the api and the client. What this means is that there exists code that operates in both this project and it's client. That project is being imported here as `devu-shared-modules`. -To generate types for local development you must go to the ``/devu-shared`` directory +To generate types for local development run the following commands (all commands assume you are in project root) -1. run ```npm install``` (if you haven't already) -2. run ```npm run build-local``` +1. ```bash + cd ./devu-shared + ``` +2. ```bash + npm install + ``` +3. ```bash + npm run build-local + ``` -This command will create a ``devu-shared-modules`` folder in api and client dir +This will create a ``devu-shared-modules`` folder in ``devU-api`` and ``devU-client`` dir -When developing if you need to update the modules, +When developing if you need to create a new type, -1. create the type in ``devu-shared/src/types/example.type.ts`` -2. export the type in ``devu-shared/src/index.ts`` -3. rerun ``npm run build-local`` +1. create the type file in ``devu-shared/src/types/example.type.ts`` +2. export the new type in ``devu-shared/src/index.ts`` +3. rerun + ```bash + npm run build-local + ``` -This will update the types in the api and client folders. +This will update the types in ``devU-api`` and ``devU-client`` folders. -#### Note if the types are not being detected by your IDE +**Note if the types are not being detected by your IDE** -Go to the ``devU-api/`` and ``devU-client/`` and run ``npm install`` to update the shared modules for the individual -project +**Go to the ``devU-api/`` and ``devU-client/`` and run ``npm install`` in each folder to update the shared modules.** ### Testing