Skip to content

Commit 235d4cb

Browse files
committed
Initial commit
Adaptation of MySQL connector for Postgres
0 parents  commit 235d4cb

22 files changed

+6325
-0
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
temp

.eslintrc.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
plugins: [
5+
'@typescript-eslint',
6+
],
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/eslint-recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
],
12+
"rules": {
13+
"@typescript-eslint/no-var-requires": 0,
14+
"@typescript-eslint/explicit-module-boundary-types": 0,
15+
"no-console": 0,
16+
"no-async-promise-executor": 0,
17+
"only-arrow-functions": 0,
18+
"interface-name": 0,
19+
"no-empty": 0,
20+
"max-line-length": 0,
21+
"max-classes-per-file": 0,
22+
"eqeqeq": 2,
23+
"indent": ["error", 4],
24+
"no-var-requires": 0,
25+
"@typescript-eslint/explicit-function-return-type": 0,
26+
"@typescript-eslint/no-explicit-any": 0,
27+
"@typescript-eslint/no-empty-function": 0,
28+
"@typescript-eslint/camelcase": 0,
29+
"object-literal-sort-keys": 0,
30+
"no-useless-escape": 0,
31+
"@typescript-eslint/no-unused-vars": 0,
32+
"@typescript-eslint/no-use-before-define": 0,
33+
},
34+
};

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Text files configuration
2+
3+
* text eol=lf
4+

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# .gitignore file
2+
3+
# Ignore downloaded dependencies
4+
5+
node_modules
6+
7+
# Ignore compiled files
8+
9+
dist
10+
11+
# Ignore temp files
12+
13+
temp
14+
15+
# Ignore .env
16+
17+
.env

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM node:alpine
2+
3+
RUN mkdir /app
4+
5+
WORKDIR /app
6+
7+
# Install dependencies
8+
9+
ADD package.json /app/package.json
10+
ADD package-lock.json /app/package-lock.json
11+
12+
RUN npm install
13+
14+
# Add source files
15+
16+
ADD src /app/src
17+
18+
# Build
19+
20+
ADD .eslintrc.js /app/.eslintrc.js
21+
ADD tsconfig.json /app/tsconfig.json
22+
23+
RUN npm run build
24+
25+
# Remove dev dependencies
26+
27+
RUN npm prune --production
28+
29+
# Expose ports
30+
31+
EXPOSE 80
32+
EXPOSE 443
33+
34+
# Entry point
35+
36+
CMD ["npm", "start"]

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Deep Intelligence External source: PostgreSQL + MQTT
2+
3+
This is an external source manager based on PostgreSQL for data storage and MQTT for real-time data fetching.
4+
5+
## Installation
6+
7+
Install depedendencies
8+
9+
```
10+
$ npm install
11+
```
12+
13+
Requirements:
14+
15+
- Node JS
16+
17+
To build the project type:
18+
19+
```
20+
$ npm run build
21+
```
22+
23+
To run the server type:
24+
25+
```
26+
$ npm start
27+
```
28+
29+
## Configuration
30+
31+
In order to configure this module, you have to set the following environment variables:
32+
33+
| Variable Name | Description |
34+
|---|---|
35+
| HTTP_PORT | HTTP listening port. Default is `80` |
36+
| SSL_PORT | HTTPS listening port. Default is `443` |
37+
| SSL_CERT | Path to SSL certificate. Required for HTTPS to work |
38+
| SSL_KEY | Path to SSL private key. Required for HTTPS to work |
39+
| LOG_MODE | Log Mode. values: DEFAULT, SILENT, DEBUG |
40+
| API_DOCS | Set it to `YES` to generate Swagger api documentation in the `/api-docs/` path. |
41+
| DEEPINT_API_URL | Deep Intelligence API URL, by default is `https://app.deepint.net/api/v1/` |
42+
43+
In order to configure the source, set the following variables:
44+
45+
| Variable Name | Description |
46+
|---|---|
47+
| PG_HOST | Postgre host |
48+
| PG_PORT | Postgre port. Default: `5432` |
49+
| PG_USER | Postgre username. |
50+
| PG_PASSWORD | Postgre password. |
51+
| PG_DB_NAME | Postgre database name. |
52+
| PG_MAX_CONNECTIONS | Max connections in the Postgre connection pool. |
53+
| TABLE_MAPPING_FILE | Path to the tables mapping file. Explained below. |
54+
55+
In order to configure the table mapping rules, create a JSON file and set its path into the `TABLE_MAPPING_FILE` variable.
56+
57+
The tables mapping file contains an array with the following structure:
58+
59+
```json
60+
[
61+
{
62+
"table": "Table of the PostgreSQL table",
63+
64+
"publicKey": "Public Key for the source (An unique identifier)",
65+
"secretKey": "Private Key to access the API for this source (A random string)",
66+
67+
"fields": [
68+
"name": "Feature name. Name of the field in the database",
69+
"type": "Feature type. Can be: NOMINAL, NUMERIC, LOGIC, DATE or TEXT"
70+
],
71+
}
72+
]
73+
```
74+

0 commit comments

Comments
 (0)