Skip to content

Commit

Permalink
Merge pull request #1 from Caresle/dev
Browse files Browse the repository at this point in the history
Version 1
  • Loading branch information
Caresle authored Apr 20, 2024
2 parents 7f0c1f4 + dd3efb6 commit f18ede0
Show file tree
Hide file tree
Showing 14 changed files with 629 additions and 24 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
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
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# General config
PORT=
# DB Instance
PGUSER=
PGHOST=
PGPASSWORD=
PGDATABASE=
PGPORT=
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ dist

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
Expand All @@ -163,4 +163,6 @@ dist
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,dotenv
# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,dotenv

build/
17 changes: 17 additions & 0 deletions Dockerfile
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" ]
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 25 additions & 18 deletions package.json
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"
}
}
Loading

0 comments on commit f18ede0

Please sign in to comment.