Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 26 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,124 +1,53 @@
# Map Colonies typescript service template
# 3D Operations Trigger

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

This is a basic repo template for building new MapColonies web services in Typescript.
Entry point for 3D operations — **ingest, delete, update, publish/unpublish**. It validates incoming requests (light & fast) and triggers the corresponding [Jobnik](https://mapcolonies.github.io/infra-portal/docs/knowledge-base/jobnik) jobs. Successor to the legacy `3d-gateway` (and, in the near future, `store-trigger`).

> [!IMPORTANT]
> To regenerate the types on openapi change run the command `npm run generate:openapi-types`.
> Epic: MAPCO-11833 · Design: [3D Ingestion High level architecture](https://mapcolonies.atlassian.net/wiki/spaces/MAPConflicResolution/pages/3342172161) · See [docs/PRD.md](./docs/PRD.md)

> [!WARNING]
> After creating a new repo based on this template, you should delete the CODEOWNERS file.


## Development
When in development you should use the command `npm run start:dev`. The main benefits are that it enables offline mode for the config package, and source map support for NodeJS errors.

### 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 production-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
## API

- test
| Endpoint | Method | Summary |
| --- | --- | --- |
| `/record` | POST | Start an ingestion flow (validate, create Jobnik ingestion job) |
| `/record/{id}` | DELETE | Validate deletability, create Jobnik delete job |
| `/record/{id}` | PATCH | Update metadata for a record |
| `/record/status/{id}` | PATCH | Publish / unpublish a record |

- lint
Full OpenAPI spec: [openapi3.yaml](/openapi3.yaml). Regenerate types on spec change with `npm run generate:openapi-types`.

- snyk
## Requirements

## API
Checkout the OpenAPI spec [here](/openapi3.yaml)
- **Node.js ≥ 24** (required by `@map-colonies/jobnik-sdk`). Use the pinned version via `nvm use`.

## Installation

Install deps with npm

```bash
npm install
```

## Run Locally

Clone the project

```bash

git clone https://link-to-project

```

Go to the project directory

```bash

cd my-project

```

Install dependencies
> During development this service consumes `@map-colonies/3d-shared` (and, later, mc-models v2) via local `file:` links until those packages are published to npm.

```bash

npm install

```

Start the server
## Run Locally

```bash

npm run start

npm run start # build + run
npm run start:dev # offline config + source maps
```

## Running Tests

To run tests, run the following command

```bash

npm run test

npm run test # all
npm run test:unit # unit only
npm run test:integration # integration only
```

To only run unit tests:
```bash
npm run test:unit
```
## Development notes

To only run integration tests:
```bash
npm run test:integration
```
- eslint / prettier via `@map-colonies/eslint-config` and `@map-colonies/prettier-config`
- vitest for tests
- OpenAPI request validation at the middleware layer
- config via [node-config](https://www.npmjs.com/package/node-config)
- tracing & metrics via `@map-colonies/telemetry`
10 changes: 5 additions & 5 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: ts-server-boilerplate
description: A boilerplate github repo for a REST API service in NodeJS for MapColonies
name: 3d-ops-trigger
description: Entry point for 3D operations (ingest, delete, update, publish/unpublish) — validates requests and triggers Jobnik jobs
annotations:
github.com/project-slug: MapColonies/ts-server-boilerplate
github.com/project-slug: MapColonies/3d-ops-trigger
tags:
- nodejs
- typescript
- expressjs
- boilerplate
- 3d
spec:
type: service
lifecycle: production
owner: DevInfra
system: boilerplate
system: 3d
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: ts-server-boilerplate
description: A Helm chart for ts-server-boilerplate service
name: 3d-ops-trigger
description: A Helm chart for the 3d-ops-trigger service
type: application
version: 1.0.0
appVersion: 1.0.0
Expand Down
6 changes: 3 additions & 3 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ global:

mclabels:
component: backend
partOf: boilerplates
partOf: 3d
owner: common
prometheus:
enabled: true
Expand All @@ -23,7 +23,7 @@ fullnameOverride: ""

configManagement:
offlineMode: false
name: 'service-name'
name: '3d-ops-trigger'
version: 'latest'
serverUrl: 'http://localhost:8080/api'

Expand Down Expand Up @@ -66,7 +66,7 @@ caPath: '/usr/local/share/ca-certificates'
caKey: 'ca.crt'

image:
repository: ts-server-boilerplate
repository: 3d-ops-trigger
# If commented, appVersion will be taken. See: _helpers.tpl
# tag: 'latest'
pullPolicy: IfNotPresent
Expand Down
4 changes: 2 additions & 2 deletions openapi3.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.1
info:
title: service-name
description: basic template for map colonies service
title: 3d-ops-trigger
description: Entry point for 3D operations — validates requests and triggers Jobnik jobs
version: 1.0.0
license:
name: MIT
Expand Down
Loading
Loading