Skip to content

Commit

Permalink
add_logic (#1)
Browse files Browse the repository at this point in the history
* add_logic

* chore: save

* feat: middle

* chore: add tests

* chore: add validation for file name in linux

* chore(test): add another integration test

* fix: eslint

* chore: code review

* fix: prettier, readme
  • Loading branch information
AnguIar authored Nov 2, 2021
1 parent ba2f9a2 commit a37753d
Show file tree
Hide file tree
Showing 35 changed files with 2,305 additions and 512 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ typings/
.env
.env.test
config.json
local.json

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
166 changes: 40 additions & 126 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,40 @@
# Map Colonies typescript service template

----------------------------------

![badge-alerts-lgtm](https://img.shields.io/lgtm/alerts/github/MapColonies/ts-server-boilerplate?style=for-the-badge)

![grade-badge-lgtm](https://img.shields.io/lgtm/grade/javascript/github/MapColonies/ts-server-boilerplate?style=for-the-badge)

![snyk](https://img.shields.io/snyk/vulnerabilities/github/MapColonies/ts-server-boilerplate?style=for-the-badge)

----------------------------------

This is a basic repo template for building new MapColonies web services in Typescript.

### Template Features:

- eslint configuration by [@map-colonies/eslint-config](https://github.com/MapColonies/eslint-config)

- prettier configuration by [@map-colonies/prettier-config](https://github.com/MapColonies/prettier-config)

- jest

- .nvmrc

- Multi stage producton-ready Dockerfile

- commitlint

- git hooks

- logging by [@map-colonies/js-logger](https://github.com/MapColonies/js-logger)

- OpenAPI request validation

- config load with [node-config](https://www.npmjs.com/package/node-config)

- Tracing and metrics by [@map-colonies/telemetry](https://github.com/MapColonies/telemetry)

- github templates

- bug report

- feature request

- pull request

- github actions

- on pull_request

- LGTM

- test

- lint

- snyk

## API
Checkout the OpenAPI spec [here](/openapi3.yaml)

## Installation

Install deps with npm

```bash
npm install
```
### Install Git Hooks
```bash
npx husky install
```

## Run Locally

Clone the project

```bash

git clone https://link-to-project

```

Go to the project directory

```bash

cd my-project

```

Install dependencies

```bash

npm install

```

Start the server

```bash

npm run start

```

## Running Tests

To run tests, run the following command

```bash

npm run test

```

To only run unit tests:
```bash
npm run test:unit
```

To only run integration tests:
```bash
npm run test:integration
```
# Exporter Trigger
This service triggers export process from user's input.

# Usage
### For local development
Clone the repository, hit `npm install` & `npm start`. Make sure you have your configurations set right.
### Docker
Build an image with the provided `Dockerfile`, then run it.

# Environment Variables
**Service Specific**
* JOB_MANAGER_URL
* JOB_MANAGER_EXPIRATION_TIME - amount of days from creation till this job is expired
* RASTER_CATALOG_MANAGER_URL
* WORKER_TYPES_TILES_JOB_TYPE - configuration for exporter job type
* WORKER_TYPES_TILES_TASK_TYPE - configuration for exporter task type

**HTTP Requests**
* HTTP_RETRY_ATTEMPTS
* HTTP_RETRY_DELAY
* HTTP_RETRY_SHOULD_RESET_TIMEOUT

**Telemetry**
* TELEMETRY_SERVICE_NAME
* TELEMETRY_HOST_NAME
* TELEMETRY_SERVICE_VERSION
* TELEMETRY_TRACING_ENABLED
* TELEMETRY_TRACING_URL
* TELEMETRY_METRICS_ENABLED
* TELEMETRY_METRICS_URL
* TELEMETRY_METRICS_INTERVAL

**Logging**
* LOG_LEVEL
* LOG_PRETTY_PRINT_ENABLED

**Server**
* SERVER_PORT
* REQUEST_PAYLOAD_LIMIT
* RESPONSE_COMPRESSION_ENABLED
27 changes: 27 additions & 0 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,32 @@
}
}
}
},
"httpRetry": {
"attempts": {
"__name": "HTTP_RETRY_ATTEMPTS",
"__format": "number"
},
"delay": "HTTP_RETRY_DELAY",
"shouldResetTimeout": {
"__name": "HTTP_RETRY_SHOULD_RESET_TIMEOUT",
"__format": "boolean"
}
},
"jobManager": {
"url": "JOB_MANAGER_URL",
"expirationTime": {
"__name": "JOB_MANAGER_EXPIRATION_TIME",
"__format": "number"
}
},
"rasterCatalogManager": {
"url": "RASTER_CATALOG_MANAGER_URL"
},
"workerTypes": {
"tiles": {
"jobType": "WORKER_TYPES_TILES_JOB_TYPE",
"taskType": "WORKER_TYPES_TILES_TASK_TYPE"
}
}
}
18 changes: 18 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,23 @@
"options": null
}
}
},
"httpRetry": {
"attempts": 5,
"delay": "exponential",
"shouldResetTimeout": true
},
"jobManager": {
"url": "http://job-manager-job-manager",
"expirationTime": 30
},
"rasterCatalogManager": {
"url": "http://raster-catalog-manager"
},
"workerTypes": {
"tiles": {
"jobType": "rasterTilesExporter",
"taskType": "rasterTilesExporter"
}
}
}
Loading

0 comments on commit a37753d

Please sign in to comment.