-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Caresle/dev
Version 1
- Loading branch information
Showing
14 changed files
with
629 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[*.{js,ts,tsx,jsx,json}] | ||
|
||
end_of_line = lf | ||
charset = utf-8 | ||
indent_size = 2 | ||
indent_style = tab | ||
tab_width = 2 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# General config | ||
PORT= | ||
# DB Instance | ||
PGUSER= | ||
PGHOST= | ||
PGPASSWORD= | ||
PGDATABASE= | ||
PGPORT= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM node:20-alpine3.19 | ||
|
||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
COPY package.json /usr/src/app/ | ||
|
||
RUN npm install | ||
|
||
COPY . /usr/src/app/ | ||
|
||
COPY .env .env | ||
|
||
RUN npm i -g typescript | ||
RUN npm --prefix /usr/src/app run build | ||
|
||
CMD [ "npm run start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,102 @@ | |
A simple microservice for getting information about employees from the | ||
ERP odoo. | ||
|
||
## Table of contents | ||
|
||
- [List of endpoints](#list-of-endpoints) | ||
- [Employees](#employees) | ||
- [Deploy](#deploy) | ||
- [Requirements](#requirements) | ||
- [Steps to install the project](#steps-to-install-the-project) | ||
- [Docker](#docker) | ||
|
||
## List of endpoints | ||
|
||
The current available endpoint for the api are the next one: | ||
|
||
### Employees | ||
|
||
`/employees` : GET | ||
|
||
```bash | ||
# Request params | ||
id - numeric (optional) | ||
name - string (optional) | ||
email - string (optional) | ||
company - string (optional) | ||
``` | ||
|
||
### JSON Response | ||
|
||
```json | ||
{ | ||
"status": 200, | ||
"msg": "success", | ||
"data": [ | ||
{ | ||
"id": 1, | ||
"name": "Administrator", | ||
"job_id": null, | ||
"job_title": null, | ||
"department_id": 1, | ||
"department": "Administration", | ||
"parent_id": null, | ||
"parent_name": null, | ||
"coach_id": null, | ||
"company_id": 1, | ||
"company": "Caresle Company", | ||
"work_email": "[email protected]", | ||
"work_phone": null, | ||
"mobile_phone": null, | ||
"pin": null | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Deploy | ||
|
||
### Requirements | ||
|
||
You need to have a odoo database for the project to work, also see [Docker](#docker) if you want to deploy the project using docker. | ||
|
||
### Steps to install the project | ||
|
||
1. Clone the repository | ||
2. Install the dependencies with: | ||
|
||
```bash | ||
npm i | ||
``` | ||
|
||
3. Copy `.env.example` and rename for `.env` | ||
4. Set up the `.env` variables | ||
5. Build the project with: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
6. Start the project with: | ||
|
||
```bash | ||
npm run start | ||
``` | ||
|
||
### Docker | ||
|
||
If you want to use docker follow the previous step, just run these additional commands. | ||
|
||
1. For building the docker image | ||
|
||
```bash | ||
docker build -t odoo_microservice ./ | ||
``` | ||
|
||
2. For start the container (remember that the odoo db need to be running) | ||
|
||
```bash | ||
docker run --name employees_microservice -p 3005:3005 -d odoo_microservice | ||
``` | ||
|
||
> Replace the -p with <PORT_HOST>:<PORT_IN_THE_ENV_FILE> for the app to run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
{ | ||
"name": "microservice-employees-odoo-1", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"dotenv": "^16.4.5", | ||
"express": "^4.19.2" | ||
}, | ||
"devDependencies": { | ||
"nodemon": "^3.1.0", | ||
"typescript": "^5.4.5" | ||
} | ||
"name": "microservice-employees-odoo-1", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "build/app.js", | ||
"scripts": { | ||
"start": "node build/app.js", | ||
"dev": "nodemon src/app.ts", | ||
"build": "tsc -p ." | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"dotenv": "16.4.5", | ||
"express": "4.19.2", | ||
"pg": "8.11.5" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "4.17.21", | ||
"@types/node": "20.12.7", | ||
"@types/pg": "^8.11.5", | ||
"nodemon": "3.1.0", | ||
"ts-node": "10.9.2", | ||
"typescript": "5.4.5" | ||
} | ||
} |
Oops, something went wrong.