Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • web-et-numerique/factory/llle_project/self-data-technical-doc
1 result
Select Git revision
Show changes
Showing
with 294 additions and 178 deletions
# Routes
This section explains the different API route. Descriptions are not currently up-to-date.
A swagger documentation can be consulted at [http://localhost:3000/api/doc/](http://localhost:3000/api/doc/)
# Auth
## Auth
- `api/auth/signin`: It is used for local and dev authentication. It is linked to two different password into the database.
- `api/auth/token` : It is used for generate one token. Only for internal process. This route is not call from another apps.
- `api/auth/token/check`: It is used for check one token. It is called from cozy-stack service of the usager.
- `api/auth/token`: It is used for generate one token. Only for internal process. This route is not call from another apps.
- `api/auth/login`: It is used for Sign&Go authentication. Linked to AuthStrategy.
- `login/callback`: Get the authentication from Sign&Go process.
# Beneficiary
## Beneficiary
- `/api/beneficiaire`: Get all usager known from Postgre database.
- `/api/beneficiaire/create'`: This route is used in order to store Usager domain and his trigger process from Cozy. This route is protected by a COZY_SECRET env variable token. This token is generated by us. If you change it, you need to inform Cozy team because this token is store in their side also.
- `/api/beneficiaire/remove'`: This route is used in order to remove Usager domain and his trigger process. Only available by POST. This route is not accessible from any part of TS FRONT application. Protected rout by the same token of create route.
## Add one beneficiary by Postman
- Create a POST request
- Entry the URL: http://localhost:3020/api/beneficiaire/create or https://pilote-agent-rec.grandlyon.com/api/beneficiaire/create
- Push in Authorization/ Bearer Token => the token use by "process.env.COZY_SECRET"
- In Body, as JSON format example :
- ``
{"cozy_name":"pilote-rec.cozy.self-data.alpha.grandlyon.com","trigger":"https://pilote-rec.cozy.self-data.alpha.grandlyon.com/jobs/webhooks/d010bf3fa2aed6f3c6584ea93a54affc"}
``
- Local : ``
{"cozy_name":"pilote.cozy.tools:8080","trigger":"http://pilote.cozy.tools:8080/jobs/webhooks/"}
``
- In Body, as JSON format example :
```json
{
"cozy_name":"pilote-rec.cozy.self-data.alpha.grandlyon.com",
"trigger":"https://pilote-rec.cozy.self-data.alpha.grandlyon.com/jobs/webhooks/d010bf3fa2aed6f3c6584ea93a54affc"
}
```
# Cozy
- Local :
```json
{
"cozy_name":"pilote.cozy.tools:8080",
"trigger":"http://pilote.cozy.tools:8080/jobs/webhooks/"
}
```
## Cozy
- `api/redirect/cozy`: Allow to send information to the cozy-stack in order to run smsProcess on cozy-stack side.
# Users
## Users
Authentication only used for local or dev environment because Sign&Go is only available for rec and prod env.
## Initialisation of the project
# Launch the application on local
### Clone the project repository
## Initialisation of the project
Use following command in your favorite terminal to clone the project:
Clone the project using the following command:
```
```sh
git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial-back.git
```
......@@ -12,38 +12,37 @@ git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travaille
### Start Pilote application
Copy the ```template.env``` into ```.env```
Copy the `template.env` into `.env`
To start Pilote application just launch the following command in a terminal :
```
```sh
yarn
docker-compose -f docker-compose.dev.yml up -d
```
If the application starts successfully you should obtain two containers running:
```sh
docker ps
# mps-travailleursocial-back_mps_1
# mps-travailleursocial-back_postgres_1
```
mps-travailleursocial-back_mps_1
mps-travailleursocial-back_postgres_1
```
You can access by: http://localhost:3020/api
It will be redirect to the Swagger UI. It allow to test the different API defined.
You can access by: <http://localhost:3020/api>
It will be redirect to the Swagger UI. It allow to test the different API defined.
### Run Jest test
### Run Jest test
To start test defined just run the command in a Powershell or Windows Powershell tool:
```
```sh
yarn test:watch
```
Don't forget to uncomment ending row into beneficiary.service.ts file before to run the above command.
### Useful docker command
- build : `docker build -t mps .`
......@@ -54,15 +53,15 @@ Don't forget to uncomment ending row into beneficiary.service.ts file before to
- delete image/containers: `docker system prune -a -f`
- enter container: `docker exec -it <id_container> bash`
- enter container: `docker exec -it <id_container> bash`
- remove container: `docker container rm -f <id_container>`
## Synapps environment
## Synapps environment
- check mps container : `docker ps --filter "name=mps"` or use this alias created : `dpm`
- docker stop <id_container>
- run a service from the docker-compose file: `docker-compose up -d <name_of_service>` |
example: `docker-compose up -d mps-prod` , `docker-compose up -d app` , ....
\ No newline at end of file
example: `docker-compose up -d mps-prod` , `docker-compose up -d app` , ....
# Techno used
# Architecture
- NestJS
## Techno used
- NestJS
- Jest for the tests
- Docker
- Docker
- PostgreSQL
## Docker-compose
# Docker-compose
Two docker-compose are available into the project:
Two docker-compose are available into the project:
- the general one
- the general one
- the local one
For the general one, all service are details. The env variable used are available on Synapps server.
The local one is used with the docker-compose_dev.yml
\ No newline at end of file
The local one is used with the docker-compose_dev.yml
# Deployment
For each environment, the CI-CD is implemented.
For each environment, the CI-CD is implemented.
Once, you commit on 'dev' branch or 'rec' branch, the pipeline liked is running.
\ No newline at end of file
Once, you commit on 'dev' branch or 'rec' branch, the pipeline liked is running.
# Routes
This section explains the different functionalities:
# Beneficiaries
## Beneficiaries
Once you are authenticated, you'll redirect into /liste-beneficiaire route.
You are getting all usager known.
# Sharing
## Sharing
For each beneficiary, you can ask the sharing. It means that you will be redirect into the public page of the cozy usager. In the same time, one process is running in order to send the sms. This sms contain one sharecode in order to provide some right on the cozy usager.
For each beneficiary, you can ask the sharing. It means that you will be redirect into the public page of the cozy usager. In the same time, one process is running in order to send the sms. This sms contain one sharecode in order to provide some right on the cozy usager.
In order to help you to understand this process, you can check : Pilote - TS - Back/project_architecture/share_sms.png
\ No newline at end of file
![share_sms.png](../../Pilote-TS-Back/project_architecture/share_sms.png)
## Initialisation of the project
# Launch the application on local
### Clone the project repository
## Initialisation of the project
Use following command in your favorite terminal to clone the project:
Clone the project using the following command :
```
```sh
git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial.git
```
......@@ -14,19 +14,18 @@ git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travaille
Before to start Pilote application, you need to run this command in order to install dependencies:
```
```sh
yarn
```
Copy the ```template.env``` into ```.env```
Copy the `template.env` into `.env`
To start Pilote application, make sure the server is running and launch the command in a terminal :
```
```sh
yarn start
```
If the application starts successfully you should access to:
> [http://localhost:4200/](http://localhost:4200/)
# Deploy
:construction: Section under Construction :construction:
This section will show you how to deploy your project on different environments.
## Setup
First of all you'll need to install [MobaXterm](https://mobaxterm.mobatek.net/download.html) in order to connect to the server.
Then, if you're on Linux you can skip the following section, otherwise if you are on Windows you'll have to install Windows Subsystem for Linux (WSL) since the deployment of the app is not working with windows commands.
## Deploy Pilote
### Deploy on Alpha
First open your terminal, write the following commands :
```sh
yarn build
```
After this, you can launch the deployment.
In order to deploy on pilote-dev-build (development environment) use the command :
```sh
yarn deploy-dev
# OR for branch build
yarn deploy
```
Then go on server and use scripts to update your instance
......@@ -4,8 +4,6 @@ Doctypes represent different types of data. Their primary use is for permissions
The following is a full description of the doctypes we use and their fields. Cozy doctypes won't be fully described. Instead, for every used one, we'll include a link to its official documentation.
## Used Cozy doctypes
- [`io.cozy.accounts`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.accounts): Konnector accounts
......@@ -18,91 +16,62 @@ The following is a full description of the doctypes we use and their fields. Coz
- [`io.cozy.triggers`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.triggers): Job triggers
## Used Cozy remote doctypes
This kind of doctype are set from the team. We have push two remote doctypes (each duplicate for rec and prod environment)
> Prod
- [`org.mps.store`]: Required to store information on back-end TS
- [`org.mps.share`]: Required to search on back-end TS
> Recette
> Recette
- [`org.mps.store.rec`]: Required to store information on rec back-end TS
- [`org.mps.share.rec`]: Required to search on rec back-end TS
If you need to target rec remote doctype, you need to change the request : client.getStackClient().fetchJSON('POST','...')
and change them into the manifest also.
and change them into the manifest also.
## Custom doctypes
- `com.grandlyon.mps.profile`
- `tutorial`: {`object`} contains `contacts`, `documents`, `actions`, and `notes`. They represent the state of tutorials. For example, `contacts: true` means the contacts tutorial hasn't been seen yet and will be visible to the user the next time he visits the contacts component.
- `notification`: {`boolean`} If equals true, the user has a notification
- `fullname`: {`string`} User's full name
- `introduction`: {`boolean`} If equals `true`, it means the user has already used the app and seen the introduction.
- `lastConnectionDate` : {`string`} When was the user last connected (ISO string).
- `hasPhone`: {`boolean`} Equals true if the current user has already a phone number
- `userID`: {`string`} Current user id
- `publicProfile`: {`object`} contains `fullname`, `endDate` (ISO string), and `isActive`
##### Attributes
- `tutorial`: {`object`} contains `contacts`, `documents`, `actions`, and `notes`. They represent the state of tutorials. For example, `contacts: true` means the contacts tutorial hasn't been seen yet and will be visible to the user the next time he visits the contacts component.
- `notification`: {`boolean`} If equals true, the user has a notification
- `fullname`: {`string`} User's full name
- `introduction`: {`boolean`} If equals `true`, it means the user has already used the app and seen the introduction.
- `lastConnectionDate` : {`string`} When was the user last connected (ISO string).
- `hasPhone`: {`boolean`} Equals true if the current user has already a phone number
- `userID`: {`string`} Current user id
- `publicProfile`: {`object`} contains `fullname`, `endDate` (ISO string), and `isActive`
- `com.grandlyon.mps.appointments`
- `id`: {`string`} the appointment id
- `appointmentDate`: {`string`} the appointment date (ISO string)
- `note`: {`Note`} A unique note for each appointment
- `objectives`: {`Array<Objective>`} The list of appointment's objectives
##### Attributes
- `id`: {`string`} the appointment id
- `appointmentDate`: {`string`} the appointment date (ISO string)
- `note`: {`Note`} A unique note for each appointment
- `objectives`: {`Array<Objective>`} The list of appointment's objectives
- `com.grandlyon.mps.objectives`
- `id`: {`string`} the objective id
- `title`: {`string`} the objective title
- `type`: {`string`} The id of the Objective type
- `subtype`: {`string`} The id of the Objective subType
- `tasks`: {`Array<Task>`} Array of Tasks ids
- `archived`: {`boolean`} If equals true, it mean the objective has been completed
##### Attributes
- `id`: {`string`} the objective id
- `title`: {`string`} the objective title
- `type`: {`string`} The id of the Objective type
- `subtype`: {`string`} The id of the Objective subType
- `tasks`: {`Array<Task>`} Array of Tasks ids
- `archived`: {`boolean`} If equals true, it mean the objective has been completed
- `com.grandlyon.mps.tasks`
- `id`: {`string`} The task id
- `name`: {`string`} The task name
- `description`: {`string`} The task description
- `state`: {`TaskState`} It could be one of the following: `'USER_TO_VALID', 'USER_VALID', 'PUBLIC_VALID', 'PUBLIC_INVALID'`
- `qualifications`: {`Array<string>`}
- `items`: {`Array<TaskItem>`}
##### Attributes
- `id`: {`string`} The task id
- `name`: {`string`} The task name
- `description`: {`string`} The task description
- `state`: {`TaskState`} It could be one of the following: `'USER_TO_VALID', 'USER_VALID', 'PUBLIC_VALID', 'PUBLIC_INVALID'`
- `qualifications`: {`Array<string>`}
- `items`: {`Array<TaskItem>`}
- `com.grandlyon.mps.task.items`
##### Attributes
- `id`: {`string`} Item id
- `file`: {`DocumentEntity`} The items' file
- `state`: {`TaskItemState`} It could be one of the following: `'USER_ITEM_PENDING', 'PUBLIC_ITEM_VALID', 'PUBLIC_ITEM_INVALID'`
- `com.grandlyon.mps.notes`
##### Attributes
- `id`: {`string`} Note's id
- `content`: {`string`} The content of the note.
- `createdAt`: {`string`} Date of creation (ISO string)
- `id`: {`string`} Item id
- `file`: {`DocumentEntity`} The items' file
- `state`: {`TaskItemState`} It could be one of the following: `'USER_ITEM_PENDING', 'PUBLIC_ITEM_VALID', 'PUBLIC_ITEM_INVALID'`
- `com.grandlyon.mps.notes`
- `id`: {`string`} Note's id
- `content`: {`string`} The content of the note.
- `createdAt`: {`string`} Date of creation (ISO string)
# Redux
We are using **Redux** for our application state management. it maintains the state of the entire application in a single immutable state tree (object), which can't be changed directly. When something changes, a new object is created (using actions and reducers). For more information about Redux, visit The [official documentation][https://redux.js.org/].
We are using **Redux** for our application state management. it maintains the state of the entire application in a single immutable state tree (object), which can't be changed directly. When something changes, a new object is created (using actions and reducers). For more information about Redux, visit The [official documentation](https://redux.js.org/).
## Store
The following are the existing store entities used by our application:
- `Profile`: Preserves the state of tutorials, user profile, public profile, introduction, and notifications (see initial state below).
- `Global`: Preserves the global state, which includes `isPublic` `toast` and `error`
- `Global`: Preserves the global state, which includes `isPublic` `toast` and `error`
- `Appointment`: Preserves the state of tutorials and notifications.
- `UploadDocument`: Manages the state of uploaded documents.
- `UploadDocument`: Manages the state of uploaded documents.
#### Initial states
### Initial states
##### Profile
#### Profile
```javascript
```js
{
tutorial: { // Tells if a tutorial has already been seen
contacts: true,
......@@ -40,9 +39,9 @@ The following are the existing store entities used by our application:
}
```
##### Global
#### Global
```javascript
```js
{
isPublic: false,
toast: null, // Manages global messages toasts
......@@ -50,9 +49,9 @@ The following are the existing store entities used by our application:
}
```
##### Appointment
#### Appointment
```javascript
```js
{
id: '',
appointmentDate: '', // ISO string
......@@ -65,9 +64,9 @@ The following are the existing store entities used by our application:
}
```
##### UploadDocument
#### UploadDocument
```javascript
```js
{
file: null,
qualification: null,
......@@ -76,11 +75,11 @@ The following are the existing store entities used by our application:
For each reducer file, a test file is associated testing the reducer.
All the actions are tested in a separate file with the same actions file name.
All the actions are tested in a separate file with the same actions file name.
## Used packages
- **react-redux**: Official React bindings for [Redux](https://github.com/reduxjs/redux).
- **react-redux**: [Thunk middleware](https://github.com/reduxjs/redux-thunk) for Redux.
- **redux-devtools-extension**: For application's state changes debugging.
- **@types/react-redux**: This package contains type definitions for react-redux.
\ No newline at end of file
- **@types/react-redux**: This package contains type definitions for react-redux.
......@@ -33,4 +33,3 @@ In this section, you will find information about the project file structure and
| tsconfig.json | Typescript config file |
| konnector-dev-config.json | To locally test konnectors |
| service-dev-config.json | To locally test services |
## Profile Service
# Services
### Functions
## Profile Service
- `getProfile`: Tries fetching the profile if it exists. If not, it creates a new one and returns it.
- `updateProfile`: Updates the profile.
- `parseProfile`: Returns the Profile passed as a parameter without the following properties: `_id, id, _type, _rev, cozyMetadata`.
## Notes Service
### Functions
## Notes Service
- `parseNote`: Returns the Note passed as a parameter without the following properties: `_id, _type, _rev, cozyMetadata`.
- `getNoteByIDs`: Returns a list of Notes from a list of ids.
......@@ -19,11 +15,7 @@
- `getCurrentNoteOrCreate`: Returns the Note linked to the current Appointment. If id does not exist, it creates and returns a new one.
- `getAllNotes`: Returns a list of all Notes.
## Appointments Service
### Functions
## Appointments Service
- `parseAppointment`: Returns an Appointment from an appointmentEntity.
- `getLastAppointment`: Returns the last Appointment, which a user can see first in /actions.
......@@ -32,12 +24,8 @@
- `createAppointment`: Creates a new Appointment.
- `updateAppointment`: Updates an Appointment.
## Documents Service
### Functions
- `getAllDocuments`: Returns the list of all documents.
- `getDocumentsByQualification`: Returns a document by a qualification.
- `getDocumentsByQualifications`: Uses `getDocumentsByQualification` to return a list of documents from a list of qualifications.
......@@ -54,12 +42,8 @@
- `replaceFile`: Replaces a file.
- `keepFile`: Changes a file's name and saves it.
## Contacts Service
### Functions
- `getCurrentUser`: Returns the contact with an existing `me` field, which represents the current user.
- `getAllContacts`: Returns a list of all contacts.
- `findContactById`: Returns a contact by its id.
......@@ -67,26 +51,16 @@
- `updateContact`: Updates an existing contact.
- `deleteContactById`: Deletes a contact by its id.
## Groups Service
## Function
- `createMetroGroup`: Creates a new group and returns it.
- `getMetroGroup`: Returns the group if it exists or creates it if it doesn't.
## Initialization Service
## Initialization Service
- `Initialization`: {`Object`} Initializes the profile, actions, and the appDirectory.
## Konnectors Service
### Functions
## Konnectors Service
- `getAllKonnectors`: Returns a list of all the Konnectors.
- `getAllKonnectorSlugs`: Returns a list of all the Konnectors' slugs.
......@@ -95,11 +69,7 @@
- `getKonnectorByName`: Returns a Konnector from its name.
- `getKonnectorsFromDocuments`: Returns a list of Konnectors from a passed documentEntity list.
## Objectives Service
### Functions
## Objectives Service
- `parseObjective`: Returns the Objective passed as a parameter without the following properties: `_type, _rev, _id, cozyMetadata, relationships`.
- `getObjectiveByIDs`: Returns a list of Objectives from a list of ids.
......@@ -107,11 +77,7 @@
- `createObjective`: Creates a new Objective.
- `updateObjective`: Updates an existing Objective.
## Tasks Service
### Functions
## Tasks Service
- `parseTaskJSONToTask`: Returns a Task from a TaskJSON.
- `parseTask`: Returns the Task passed as a parameter without the following properties: `_type, _rev, _id, cozyMetadata, relationships`.
......@@ -119,21 +85,13 @@
- `createTask`: Creates a new Task.
- `updateTask`: Updates a Task from its id.
## TaskItems Service
### Functions
## TaskItems Service
- `parseTaskItem`: Returns the TaskItem passed as a parameter without the following properties: `_type, _rev, _id, cozyMetadata, relationships`.
- `getTaskItemByIDs`: Returns a list of TaskItems from a list of ids.
- `createTaskItem`: Creates a new TaskItem.
- `updateTaskItem`: Updates a TaskItem from its id.
## Triggers Service
## Triggers Service
### Functions
- `getAllTriggers`: Returns All the triggers filtered by type if passed as parameter.
\ No newline at end of file
- `getAllTriggers`: Returns All the triggers filtered by type if passed as parameter.
## Description
# Contact
Pilote allow usager to add contact :
- You will always see your profile at the first contact. You can not delete it. Just edit it.
- Then, with the add concat button, you can add others contact
## Description
# Cozy registry
Pilote Usager is linked to a registry to allow a TS to find and connect to a user Pilote app.
A service is run every day to send instance information to the registry.
### Service Flow summarized
## Service Flow summarized
```plantuml
"Pilote Usager" -> "Cozy Registry": POST firstName, lastName, cozyURL, smsTriggerId
......@@ -16,8 +16,10 @@ A service is run every day to send instance information to the registry.
```
## Launch the service locally
- Switch to Node 16 (using nvm or n)
- install local remote doctypes (details [here](https://doc.self-data.alpha.grandlyon.com/ecolyo/project_architecture/remote_doctypes/#local-remote-doctype)), add a folder named org.mps.registry.dev, inside it add a file named request with the following content :
```
POST https://cozy-registry.poc.self-data.alpha.grandlyon.com/api/pilote
Authorization: Bearer {{secret_token}}
......@@ -25,13 +27,16 @@ Content-Type: application/json
{{data}}
```
- in the database, if it doesn't exist, create a table named secrets/io-cozy-remote-secrets and add a document with the following content :
```json
{
"_id": "org.mps.registry.dev",
"token": "pilotecozytoken"
}
```
- launch `docker-compose up` in a first terminal
- launch `yarn build` in a second terminal
- launch `yarn run cozy-konnector-dev -m ./manifest.webapp ./build/services/cozyRegistry/pilote.js` to execute the service
## Description
# Settings
Pilote has setting page. You can found :
- Notifications: Under construction
Pilote has setting page. You can found :
- Notifications: Under construction
- Tutorial: allow to view again one of the tutorial available
- FAQ: Different explication of the global application
- Legal Notice
# Launch local application
## Initialisation of the project
### Clone the project repository
Use the following command in your favorite terminal to clone the project:
```
```sh
git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager
```
......@@ -14,13 +16,13 @@ git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager
Before starting Pilote Usager application, you need to install dependencies:
```
```sh
yarn
```
To start Pilote Usager application, you first need start the application and start a cozy stack:
```
```sh
yarn start
docker-compose up
......@@ -29,7 +31,7 @@ docker-compose up
As the pilote application has been recently upgraded to NodeJS 16 version, you might need to install additional packages in order to be able to run the app. Make sure your have the following installed :
- Python3
- Microsoft Visual Studio tools 2017
- Microsoft Visual Studio tools 2017
- node-gyp
And wait for the success message.
......@@ -41,4 +43,4 @@ Once successful you can launch your local cozy with following url [Cozy local ur
To start a social worker instance, go to [**options page**](http://pilote.cozy.tools:8080/#/settings) and click '**Get sharecode**'.
Open the console and you'll see a link redirecting to a TS instance.
\ No newline at end of file
Open the console and you'll see a link redirecting to a TS instance.
## Use cozy-doctype in local
# Use cozy-doctype in local
In order to be able to use our own cozy-doctype, especially remote doctype here, we need to use them in local.
1/ clone [cozy-doctypes](https://github.com/cozy/cozy-doctypes) repository into your system.
......@@ -6,11 +7,12 @@ Then, push it into your root project.
2/ After that, add your own remote doctype into cozy-doctype folder:
- create a new folder ex: org.mps.share
- push into this folder request file: request
- create a new folder ex: org.mps.share
- push into this folder request file: request
You must declare this doctype into your manifest.webapp file like that :
```
```json
"share": {
"description": "Required for searching on back-endTS",
"type": "org.mps.share",
......@@ -18,21 +20,25 @@ You must declare this doctype into your manifest.webapp file like that :
},
```
3/ In cozy-app-dev-with-app.sh, you need to add another option when you serve the cozy-stack:
```
```sh
cozy-stack serve --allow-root (...) --doctypes /path/to/the/doctype
```
=> in this project :
```
```sh
cozy-stack serve (...) --doctypes /data/cozy-doctypes
```
!!! warning "warning"
You need to build and push the newest image on the forge registry when the step 3 is done.
You must have all files, into your docker folder, in LF mode of "End of Line Sequence" !
For this project:
```
```sh
cd docker
docker build .
docker tag <image_ID_created> registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes
......@@ -42,17 +48,21 @@ docker push registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager
4/ The path "/data/cozy-doctypes" is linked to the volume of the cozy-app-dev image.
In order to mount this volume, you need to add it when you run the 'docker run' command :
```
-v $PWD/cozy-doctypes:/data/cozy-doctypes
```
=> for this project :
```
```sh
docker run --rm -it -p 8080:8080 -p 5984:5984 -p 8025:8025 -v $PWD/build:/data/cozy-app/mps -v $PWD/data:/usr/local/couchdb/data -v $PWD/docker/disableCSP.yaml:/etc/cozy/cozy.yaml -v $PWD/cozy-doctypes:/data/cozy-doctypes registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes
```
# How to test your remote doctype ?
## GET
## How to test your remote doctype ?
### GET
1/ In the request file created. Specify the method and the route to your target URL :
GET https://pilote-agent-dev.grandlyon.com/api/cozy
......@@ -61,19 +71,20 @@ docker run --rm -it -p 8080:8080 -p 5984:5984 -p 8025:8025 -v $PWD/build:/data/c
GET https://pilote-agent-dev.grandlyon.com/api/auth/token/check?token={{token}}
2/ Then, you can test it by :
```
```js
await client.getStackClient().fetchJSON('GET','/remote/org.mps.share')
```
or with value in query :
```js
await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhb...')
```
await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhb...' )
```
## POST
### POST
1/ In the request file created. Specify the method and the route to your target URL :
POST https://pilote-agent-dev.grandlyon.com/api/auth/token/check
......@@ -81,9 +92,9 @@ await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhb
{{data}}
2/ Then, you can test it by :
```
```js
const parameters = {
data: JSON.stringify({
token: "eyJhb..."
......
### Use services in local
# Use services in local
## Configure the cozy-stack on local
In order to be able to use your service, follow these steps:
In order to be able to use your service, follow these steps:
1/ clone [cozy-doctypes](https://github.com/cozy/cozy-doctypes) repository into your system.
Then, push it into your root project.
2/ After that, add your own remote doctype into cozy-doctype folder:
- create a new folder ex: org.mps.share
- push into this folder request file: request
- create a new folder ex: org.mps.share
- push into this folder request file: request
You must declare this doctype into your manifest.webapp file like that :
```
```json
"share": {
"description": "Required for searching on back-endTS",
"type": "org.mps.share",
......@@ -20,20 +23,22 @@ You must declare this doctype into your manifest.webapp file like that :
```
3/ In cozy-app-dev-with-app.sh, you need to add another option when you serve the cozy-stack:
```
```sh
cozy-stack serve --allow-root (...) --doctypes /path/to/the/doctype
```
=> in this project :
```
```sh
cozy-stack serve (...) --doctypes /data/cozy-doctypes
```
4/ You need to add another option when you install apps in the cozy-stack (go to: docker\cozy-app-dev-with-app.sh)
In do_install_app():
In do_install_app():
```
```sh
#add symbolic link to mps for sms service
ln -s /data/cozy-app/mps /data/cozy-storage/cozy.tools\:8080/.cozy_apps/mps
if [ -d "data/cozy-app/mps/0.1.1" ]; then
......@@ -48,14 +53,17 @@ In do_install_app():
echo "service added"
```
5/ Then, add konnector-node-run.sh in docker folder. This file is a script to store the service logs. It should contain:
#!/bin/bash
5/ Then, add konnector-node-run.sh in docker folder. This file is a script to store the service logs. It should contain:
rundir="${1}"
cd $rundir
node index.js | tee /data/cozy-app/mps/services.log
```sh
#!/bin/bash
Then, add this following row into the Dockerfile:
rundir="${1}"
cd $rundir
node index.js | tee /data/cozy-app/mps/services.log
```
Then, add this following row into the Dockerfile:
COPY konnector-node-run.sh /etc/cozy/konnector-node-run.sh
......@@ -64,13 +72,13 @@ COPY konnector-node-run.sh /etc/cozy/konnector-node-run.sh
konnectors:
cmd: /etc/cozy/konnector-node-run.sh # run connectors with node
!!! warning "warning"
You need to build and push the newest image on the forge registry when the step 6 is done.
You must have all files, into your docker folder, in LF mode of "End of Line Sequence" !
Finally, you should rebuild the docker image of the cozy-stack:
```
```sh
cd docker
docker build .
docker tag <image_ID_created> registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes
......@@ -80,32 +88,35 @@ docker push registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager
7/ The path "/data/cozy-doctypes" is link to the volume of the cozy-app-dev image.
In order to mount this volume, you need to add it when you run the 'docker run' command :
```
```sh
-v $PWD/cozy-doctypes:/data/cozy-doctypes
```
=> for this project :
```
```sh
docker run --rm -it -p 8080:8080 -p 5984:5984 -p 8025:8025 -v $PWD/build:/data/cozy-app/mps -v $PWD/data:/usr/local/couchdb/data -v $PWD/docker/disableCSP.yaml:/etc/cozy/cozy.yaml -v $PWD/cozy-doctypes:/data/cozy-doctypes registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes
```
## How to test your service ?
In the manifest.webapp, you need to declare the service:
```
In the manifest.webapp, you need to declare the service:
```json
"services": {
"smsProcess": {
"type": "node",
"file": "services/smsProcess/pilote.js"
}
},
}
```
Then, in src\targets\services, you can add your service.
Then, in src\targets\services, you can add your service.
For this project, we have created a button in Home.component.tsx in order to generate trigger url to run the service:
For this project, we have created a button in Home.component.tsx in order to generate trigger url to run the service:
```
```js
const getTrigger = async () => {
const attrs = { type: '@webhook',
worker: 'service',
......@@ -120,7 +131,7 @@ const getTrigger = async () => {
}
```
It generates an trigger URL that we can call with our backend application :
It generates an trigger URL that we can call with our backend application :
> URL_COZY/job/webhook/{{trigger_id}}
......