94 Commits

Author SHA1 Message Date
Tom Wright
f29815757f Bump some versions 2023-08-29 17:51:39 +01:00
Tom Wright
c4e03f7d41 Merge pull request #122 from docker-parfum/improve_dockerfile
Improve Dockerfile to reduce image size
2023-01-11 12:17:13 +00:00
tdurieux
ebdbb8114d Improve Dockerfile to reduce image size 2023-01-11 11:37:56 +01:00
Tom Wright
8e60a78488 Merge pull request #109 from TomWright/dependabot/docker/golang-1.19.3-buster
Bump golang from 1.19.2-buster to 1.19.3-buster
2022-11-08 13:31:57 +00:00
dependabot[bot]
4f223cf2b6 Bump golang from 1.19.2-buster to 1.19.3-buster
Bumps golang from 1.19.2-buster to 1.19.3-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-07 07:01:26 +00:00
Tom Wright
c32a3f4e07 Merge pull request #102 from TomWright/dependabot/npm_and_yarn/mermaidcli/mermaid-js/mermaid-cli-9.1.7
Bump @mermaid-js/mermaid-cli from 9.1.3 to 9.1.7 in /mermaidcli
2022-10-11 16:08:38 +01:00
dependabot[bot]
28fcde504e Bump @mermaid-js/mermaid-cli from 9.1.3 to 9.1.7 in /mermaidcli
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 9.1.3 to 9.1.7.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/9.1.3...9.1.7)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-11 15:08:29 +00:00
Tom Wright
e1a05b7b9f Merge pull request #104 from TomWright/dependabot/docker/golang-1.19.2-buster
Bump golang from 1.18.3-buster to 1.19.2-buster
2022-10-11 16:08:22 +01:00
Tom Wright
2f8b051ee7 Merge pull request #100 from TomWright/dependabot/docker/node-18.10.0-buster-slim
Bump node from 18.5.0-buster-slim to 18.10.0-buster-slim
2022-10-11 16:08:09 +01:00
Tom Wright
fa659f08f5 Merge pull request #101 from TomWright/dependabot/npm_and_yarn/mermaidcli/d3-color-and-mermaid-js/mermaid-cli--removed
Bump d3-color and @mermaid-js/mermaid-cli in /mermaidcli
2022-10-11 16:07:51 +01:00
Tom Wright
2a9b4e6b86 Merge pull request #105 from TomWright/dependabot/github_actions/actions/cache-3.0.10
Bump actions/cache from 3.0.4 to 3.0.10
2022-10-11 16:07:39 +01:00
dependabot[bot]
b9c837ecde Bump golang from 1.18.3-buster to 1.19.2-buster
Bumps golang from 1.18.3-buster to 1.19.2-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 07:08:16 +00:00
dependabot[bot]
1aaab54ad4 Bump actions/cache from 3.0.4 to 3.0.10
Bumps [actions/cache](https://github.com/actions/cache) from 3.0.4 to 3.0.10.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.0.4...v3.0.10)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 07:08:16 +00:00
dependabot[bot]
ffbec0401d Bump d3-color and @mermaid-js/mermaid-cli in /mermaidcli
Removes [d3-color](https://github.com/d3/d3-color). It's no longer used after updating ancestor dependency [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli). These dependencies need to be updated together.


Removes `d3-color`

Updates `@mermaid-js/mermaid-cli` from 9.1.3 to 9.1.6
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/9.1.3...9.1.6)

---
updated-dependencies:
- dependency-name: d3-color
  dependency-type: indirect
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-30 03:11:09 +00:00
dependabot[bot]
a4917536eb Bump node from 18.5.0-buster-slim to 18.10.0-buster-slim
Bumps node from 18.5.0-buster-slim to 18.10.0-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-29 15:37:33 +00:00
Tom Wright
f37d02c6a7 Merge pull request #99 from TomWright/cors
Add --allow-all-origins arg
2022-09-29 16:36:41 +01:00
Tom Wright
849a3a2f0a Add --allow-all-origins arg 2022-09-29 16:29:44 +01:00
Tom Wright
33f80ef0d8 Merge pull request #81 from TomWright/dependabot/docker/node-18.5.0-buster-slim
Bump node from 18.4.0-buster-slim to 18.5.0-buster-slim
2022-07-13 23:15:36 +01:00
dependabot[bot]
d1b333d7df Bump node from 18.4.0-buster-slim to 18.5.0-buster-slim
Bumps node from 18.4.0-buster-slim to 18.5.0-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-11 07:12:56 +00:00
Tom Wright
e5d3225709 Merge pull request #80 from TomWright/dependabot/npm_and_yarn/mermaidcli/mermaid-js/mermaid-cli-9.1.3
Bump @mermaid-js/mermaid-cli from 9.1.2 to 9.1.3 in /mermaidcli
2022-06-29 21:23:36 +01:00
dependabot[bot]
812bfba433 Bump @mermaid-js/mermaid-cli from 9.1.2 to 9.1.3 in /mermaidcli
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 9.1.2 to 9.1.3.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/9.1.2...9.1.3)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-27 07:01:51 +00:00
Tom Wright
6bbe9f5f92 Merge pull request #72 from TomWright/dependabot/npm_and_yarn/mermaidcli/mermaid-js/mermaid-cli-9.1.2
Bump @mermaid-js/mermaid-cli from 8.14.0 to 9.1.2 in /mermaidcli
2022-06-21 21:44:00 +01:00
Tom Wright
6ae4d0fd58 Merge pull request #79 from TomWright/dependabot/docker/node-18.4.0-buster-slim
Bump node from 17.7.2-buster-slim to 18.4.0-buster-slim
2022-06-21 21:43:45 +01:00
Tom Wright
febfc84fab Merge pull request #75 from TomWright/dependabot/docker/golang-1.18.3-buster
Bump golang from 1.18.0-buster to 1.18.3-buster
2022-06-21 21:43:26 +01:00
Tom Wright
eb4571ef23 Merge pull request #77 from TomWright/dependabot/github_actions/actions/cache-3.0.4
Bump actions/cache from 2.1.6 to 3.0.4
2022-06-21 21:43:10 +01:00
dependabot[bot]
10fa5a0e28 Bump node from 17.7.2-buster-slim to 18.4.0-buster-slim
Bumps node from 17.7.2-buster-slim to 18.4.0-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-20 07:10:10 +00:00
dependabot[bot]
d52a5ad579 Bump actions/cache from 2.1.6 to 3.0.4
Bumps [actions/cache](https://github.com/actions/cache) from 2.1.6 to 3.0.4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v2.1.6...v3.0.4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-13 07:13:43 +00:00
dependabot[bot]
6508b25d50 Bump golang from 1.18.0-buster to 1.18.3-buster
Bumps golang from 1.18.0-buster to 1.18.3-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-06 07:10:22 +00:00
dependabot[bot]
07d10fc197 Bump @mermaid-js/mermaid-cli from 8.14.0 to 9.1.2 in /mermaidcli
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 8.14.0 to 9.1.2.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/8.14.0...9.1.2)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-23 07:02:17 +00:00
Tom Wright
a99ff22c5e Merge pull request #51 from TomWright/dependabot/npm_and_yarn/mermaidcli/mermaid-js/mermaid-cli-8.14.0
Bump @mermaid-js/mermaid-cli from 8.13.2 to 8.14.0 in /mermaidcli
2022-03-26 17:30:33 +00:00
dependabot[bot]
da00637d41 Bump @mermaid-js/mermaid-cli from 8.13.2 to 8.14.0 in /mermaidcli
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 8.13.2 to 8.14.0.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/8.13.2...8.14.0)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 17:29:36 +00:00
Tom Wright
a71f6decd7 Merge pull request #58 from TomWright/dependabot/docker/node-17.7.2-buster-slim
Bump node from 16.10.0-buster-slim to 17.7.2-buster-slim
2022-03-26 17:29:06 +00:00
Tom Wright
14b7031d12 Merge pull request #59 from TomWright/dependabot/docker/golang-1.18.0-buster
Bump golang from 1.17.8-buster to 1.18.0-buster
2022-03-26 17:28:42 +00:00
Tom Wright
2b8079cd5b Merge pull request #60 from TomWright/dependabot/npm_and_yarn/mermaidcli/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6 in /mermaidcli
2022-03-26 17:28:25 +00:00
dependabot[bot]
2d503ced38 Bump minimist from 1.2.5 to 1.2.6 in /mermaidcli
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 11:27:59 +00:00
dependabot[bot]
3d415c5ab9 Bump golang from 1.17.8-buster to 1.18.0-buster
Bumps golang from 1.17.8-buster to 1.18.0-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-21 07:15:07 +00:00
dependabot[bot]
3cf48080b5 Bump node from 16.10.0-buster-slim to 17.7.2-buster-slim
Bumps node from 16.10.0-buster-slim to 17.7.2-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-21 07:15:05 +00:00
Tom Wright
a6e62da53a Merge pull request #54 from TomWright/dependabot/github_actions/actions/setup-go-3
Bump actions/setup-go from 2.1.4 to 3
2022-03-07 07:52:33 +00:00
Tom Wright
9d365f94fe Merge pull request #55 from TomWright/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2.3.4 to 3
2022-03-07 07:52:24 +00:00
Tom Wright
3a40f31774 Merge pull request #56 from TomWright/dependabot/docker/golang-1.17.8-buster
Bump golang from 1.17.2-buster to 1.17.8-buster
2022-03-07 07:52:17 +00:00
dependabot[bot]
36e077b516 Bump golang from 1.17.2-buster to 1.17.8-buster
Bumps golang from 1.17.2-buster to 1.17.8-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 07:11:08 +00:00
dependabot[bot]
327543ebd8 Bump actions/checkout from 2.3.4 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.4 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.3.4...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 07:11:02 +00:00
dependabot[bot]
6da130e231 Bump actions/setup-go from 2.1.4 to 3
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2.1.4 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2.1.4...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 07:11:00 +00:00
Tom Wright
510c861e17 Merge pull request #22 from TomWright/dependabot/npm_and_yarn/mermaidcli/mermaid-js/mermaid-cli-8.13.2
Bump @mermaid-js/mermaid-cli from 8.13.0 to 8.13.2 in /mermaidcli
2021-10-11 11:49:13 +01:00
Tom Wright
ba9d03c873 Merge pull request #23 from TomWright/dependabot/docker/golang-1.17.2-buster
Bump golang from 1.17.1-buster to 1.17.2-buster
2021-10-11 11:49:04 +01:00
dependabot[bot]
00f2df4f81 Bump golang from 1.17.1-buster to 1.17.2-buster
Bumps golang from 1.17.1-buster to 1.17.2-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 07:06:59 +00:00
dependabot[bot]
67cef06deb Bump @mermaid-js/mermaid-cli from 8.13.0 to 8.13.2 in /mermaidcli
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 8.13.0 to 8.13.2.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/8.13.0...8.13.2)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 07:01:45 +00:00
Tom Wright
f1f12e3731 Merge pull request #21 from TomWright/dependabot/npm_and_yarn/mermaidcli/mermaid-js/mermaid-cli-8.13.0
Bump @mermaid-js/mermaid-cli from 8.12.1 to 8.13.0 in /mermaidcli
2021-10-05 15:44:47 +01:00
dependabot[bot]
f13db848b1 Bump @mermaid-js/mermaid-cli from 8.12.1 to 8.13.0 in /mermaidcli
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 8.12.1 to 8.13.0.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/8.12.1...8.13.0)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-04 07:01:43 +00:00
Tom Wright
5b7b545227 Merge pull request #20 from TomWright/dependabot/docker/node-16.10.0-buster-slim
Bump node from 16.9.0-buster-slim to 16.10.0-buster-slim
2021-09-29 12:55:39 +01:00
dependabot[bot]
b181e122f8 Bump node from 16.9.0-buster-slim to 16.10.0-buster-slim
Bumps node from 16.9.0-buster-slim to 16.10.0-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 07:07:44 +00:00
Tom Wright
f63a4d97f6 Merge pull request #18 from TomWright/dependabot/docker/node-16.9.0-buster-slim
Bump node from 16.8.0-buster-slim to 16.9.0-buster-slim
2021-09-18 09:01:01 +02:00
Tom Wright
5068c588d5 Merge pull request #17 from TomWright/dependabot/docker/golang-1.17.1-buster
Bump golang from 1.17.0-buster to 1.17.1-buster
2021-09-18 09:00:47 +02:00
dependabot[bot]
a6ebc88210 Bump node from 16.8.0-buster-slim to 16.9.0-buster-slim
Bumps node from 16.8.0-buster-slim to 16.9.0-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 07:08:23 +00:00
dependabot[bot]
85b3855a3b Bump golang from 1.17.0-buster to 1.17.1-buster
Bumps golang from 1.17.0-buster to 1.17.1-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 07:08:20 +00:00
Tom Wright
07b2be93ab Merge pull request #16 from TomWright/dependabot/npm_and_yarn/mermaidcli/mermaid-js/mermaid-cli-8.12.1
Bump @mermaid-js/mermaid-cli from 8.12.0 to 8.12.1 in /mermaidcli
2021-09-06 11:54:35 +01:00
dependabot[bot]
702fdc5524 Bump @mermaid-js/mermaid-cli from 8.12.0 to 8.12.1 in /mermaidcli
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 8.12.0 to 8.12.1.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/8.12.0...8.12.1)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-06 07:01:41 +00:00
Tom Wright
b0c44b76a2 Merge pull request #12 from TomWright/dependabot/docker/golang-1.17.0-buster
Bump golang from 1.16.7-buster to 1.17.0-buster
2021-08-30 16:27:08 +01:00
Tom Wright
5cfa2c77ad Merge pull request #13 from TomWright/dependabot/npm_and_yarn/mermaidcli/mermaid-js/mermaid-cli-8.12.0
Bump @mermaid-js/mermaid-cli from 8.11.4 to 8.12.0 in /mermaidcli
2021-08-30 16:26:56 +01:00
Tom Wright
ad0177a0df Merge pull request #15 from TomWright/dependabot/docker/node-16.8.0-buster-slim
Bump node from 16.6.2-buster-slim to 16.8.0-buster-slim
2021-08-30 16:26:41 +01:00
Tom Wright
358c476bc5 Merge pull request #14 from TomWright/dependabot/github_actions/actions/setup-go-2.1.4
Bump actions/setup-go from 2.1.3 to 2.1.4
2021-08-30 16:26:26 +01:00
dependabot[bot]
7781c4827e Bump node from 16.6.2-buster-slim to 16.8.0-buster-slim
Bumps node from 16.6.2-buster-slim to 16.8.0-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-30 07:06:18 +00:00
dependabot[bot]
284da03a2c Bump actions/setup-go from 2.1.3 to 2.1.4
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2.1.3 to 2.1.4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2.1.3...v2.1.4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-30 07:06:17 +00:00
dependabot[bot]
4ead1ea02e Bump @mermaid-js/mermaid-cli from 8.11.4 to 8.12.0 in /mermaidcli
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 8.11.4 to 8.12.0.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/8.11.4...8.12.0)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-30 07:01:35 +00:00
dependabot[bot]
65a132cdec Bump golang from 1.16.7-buster to 1.17.0-buster
Bumps golang from 1.16.7-buster to 1.17.0-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-23 07:07:59 +00:00
Tom Wright
c23c29bd9e Update github action go version 2021-08-14 16:37:41 +01:00
Tom Wright
d252a491e4 Use grace instead of lifetime 2021-08-14 16:34:07 +01:00
Tom Wright
0b061ec570 Merge pull request #9 from TomWright/dependabot/docker/golang-1.16.7-buster
Bump golang from 1.16.6-buster to 1.16.7-buster
2021-08-14 16:18:25 +01:00
Tom Wright
e51d488c9f Merge pull request #10 from TomWright/dependabot/docker/node-16.6.2-buster-slim
Bump node from 16.5.0-buster-slim to 16.6.2-buster-slim
2021-08-14 16:18:09 +01:00
dependabot[bot]
ba7c8be38a Bump node from 16.5.0-buster-slim to 16.6.2-buster-slim
Bumps node from 16.5.0-buster-slim to 16.6.2-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-14 15:17:30 +00:00
dependabot[bot]
047e47c138 Bump golang from 1.16.6-buster to 1.16.7-buster
Bumps golang from 1.16.6-buster to 1.16.7-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-14 15:17:24 +00:00
Tom Wright
dc5bca1962 Merge pull request #8 from mmorel-35/master
Update Dependencies
2021-08-14 16:16:46 +01:00
Tom Wright
750e8c7ea9 Upgrade mermaid cli and add missing package in Dockerfile 2021-08-14 16:15:36 +01:00
Matthieu MOREL
a35e3d7085 Merge branch 'master' into master 2021-07-31 14:32:32 +02:00
Tom Wright
f7459c7d89 Merge pull request #7 from TomWright/dependabot/npm_and_yarn/mermaidcli/ws-7.4.6
Bump ws from 7.3.1 to 7.4.6 in /mermaidcli
2021-07-30 22:46:16 +01:00
dependabot[bot]
90359524c5 Bump actions/cache from 1 to 2.1.6 (#3)
Bumps [actions/cache](https://github.com/actions/cache) from 1 to 2.1.6.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v1...v2.1.6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-28 22:17:27 +02:00
dependabot[bot]
f95701f228 Bump golang from 1.15-buster to 1.16.6-buster (#5)
Bumps golang from 1.15-buster to 1.16.6-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-28 22:15:51 +02:00
dependabot[bot]
19a86c6774 Bump @mermaid-js/mermaid-cli from 8.6.4 to 8.11.0 in /mermaidcli (#6)
Bumps [@mermaid-js/mermaid-cli](https://github.com/mermaid-js/mermaid-cli) from 8.6.4 to 8.11.0.
- [Release notes](https://github.com/mermaid-js/mermaid-cli/releases)
- [Commits](https://github.com/mermaid-js/mermaid-cli/compare/8.6.4...8.11.0)

---
updated-dependencies:
- dependency-name: "@mermaid-js/mermaid-cli"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-28 22:15:17 +02:00
dependabot[bot]
20b9a399b0 Bump github.com/tomwright/lifetime from 1.0.0 to 1.0.1 (#7)
Bumps [github.com/tomwright/lifetime](https://github.com/tomwright/lifetime) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/tomwright/lifetime/releases)
- [Commits](https://github.com/tomwright/lifetime/compare/v1.0.0...v1.0.1)

---
updated-dependencies:
- dependency-name: github.com/tomwright/lifetime
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-28 22:14:52 +02:00
dependabot[bot]
65ceba9e32 Bump node from 12.12.0-buster-slim to 16.5.0-buster-slim (#4)
Bumps node from 12.12.0-buster-slim to 16.5.0-buster-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-28 22:13:48 +02:00
dependabot[bot]
65bbc334f5 Bump actions/setup-go from 1 to 2.1.3 (#2)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 1 to 2.1.3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v1...v2.1.3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-28 22:12:24 +02:00
dependabot[bot]
ae587caf8e Bump actions/checkout from 1 to 2.3.4 (#1)
Bumps [actions/checkout](https://github.com/actions/checkout) from 1 to 2.3.4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v1...v2.3.4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-28 22:11:49 +02:00
Matthieu MOREL
57684645cc Create dependabot.yml 2021-07-28 22:08:15 +02:00
dependabot[bot]
57cfd74df7 Bump ws from 7.3.1 to 7.4.6 in /mermaidcli
Bumps [ws](https://github.com/websockets/ws) from 7.3.1 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.3.1...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-30 06:42:05 +00:00
Tom Wright
4bd13d8620 Delete FUNDING.yml 2021-01-11 17:45:10 +00:00
Tom Wright
5d8b7c961b Create FUNDING.yml 2020-11-06 15:12:02 +00:00
Tom Wright
ec2ff8dc25 Use go v1.15 2020-10-02 14:48:02 +01:00
Tom Wright
baa1327214 Update build workflow 2020-10-02 14:46:48 +01:00
Tom Wright
44f409a807 Merge pull request #6 from TomWright/png-functionality
Cleanup and Makefile
2020-10-02 14:39:02 +01:00
Tom Wright
8b9a6a3f7d Merge pull request #5 from Umaaz/master
feat(png): add support for generating the images as png
2020-10-02 14:37:41 +01:00
Tom Wright
aac3f97894 Do some cleanup and add a Makefile 2020-10-02 14:33:34 +01:00
Ben Donnelly
bfa4d5076b feat(png): add support for generating the images as png 2020-10-01 19:25:40 +02:00
Tom Wright
90c34db593 Merge pull request #4 from TomWright/dependabot/npm_and_yarn/mermaidcli/bl-4.0.3
Bump bl from 4.0.2 to 4.0.3 in /mermaidcli
2020-09-02 20:52:31 +01:00
dependabot[bot]
9d6c6cecc7 Bump bl from 4.0.2 to 4.0.3 in /mermaidcli
Bumps [bl](https://github.com/rvagg/bl) from 4.0.2 to 4.0.3.
- [Release notes](https://github.com/rvagg/bl/releases)
- [Commits](https://github.com/rvagg/bl/compare/v4.0.2...v4.0.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-02 19:46:27 +00:00
17 changed files with 1007 additions and 435 deletions

18
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
- package-ecosystem: docker
directory: /
schedule:
interval: weekly
- package-ecosystem: npm
directory: /mermaidcli
schedule:
interval: weekly

View File

@@ -7,16 +7,16 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
go-version: [1.13.x] go-version: [1.21.x]
platform: [ubuntu-latest] platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v1 uses: actions/checkout@v3
- name: Set env - name: Set env
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10} run: echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV
- name: Build - name: Build
run: docker build --ssh default -t tomwright/mermaid-server:latest -t tomwright/mermaid-server:${{ env.RELEASE_VERSION }} -f Dockerfile . run: docker build -t tomwright/mermaid-server:latest -t tomwright/mermaid-server:${{ env.RELEASE_VERSION }} -f Dockerfile .
- name: Login - name: Login
run: echo ${{ secrets.DOCKER_PASS }} | docker login -u${{ secrets.DOCKER_USER }} --password-stdin run: echo ${{ secrets.DOCKER_PASS }} | docker login -u${{ secrets.DOCKER_USER }} --password-stdin
- name: Push - name: Push

View File

@@ -4,17 +4,17 @@ jobs:
test: test:
strategy: strategy:
matrix: matrix:
go-version: [1.13.x] go-version: [1.21.x]
platform: [ubuntu-latest] platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:
- name: Install Go - name: Install Go
uses: actions/setup-go@v1 uses: actions/setup-go@v3
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- name: Checkout code - name: Checkout code
uses: actions/checkout@v1 uses: actions/checkout@v3
- uses: actions/cache@v1 - uses: actions/cache@v3.0.10
with: with:
path: ~/go/pkg/mod path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

View File

@@ -1,5 +1,5 @@
# This stage builds the go executable. # This stage builds the go executable.
FROM golang:1.13-buster as go FROM golang:1.21.0-alpine as go
WORKDIR /root WORKDIR /root
COPY ./ ./ COPY ./ ./
@@ -10,14 +10,14 @@ RUN go build -o bin/app cmd/app/main.go
# Final stage that will be pushed. # Final stage that will be pushed.
FROM debian:buster-slim FROM debian:buster-slim
FROM node:12.12.0-buster-slim as node FROM node:18.10.0-buster-slim as node
WORKDIR /root WORKDIR /root
# copy the mermaidcli node package into the container and install # copy the mermaidcli node package into the container and install
COPY ./mermaidcli/* ./ COPY ./mermaidcli/* ./
RUN npm install RUN npm install && npm cache clean --force;
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update 2>/dev/null && \ RUN apt-get update 2>/dev/null && \
@@ -64,7 +64,8 @@ RUN apt-get update 2>/dev/null && \
lsb-release \ lsb-release \
xdg-utils \ xdg-utils \
wget \ wget \
2>/dev/null libxshmfence1 \
2>/dev/null && rm -rf /var/lib/apt/lists/*;
COPY --from=go /root/bin/app ./app COPY --from=go /root/bin/app ./app
@@ -73,5 +74,5 @@ RUN mkdir -p ./out
RUN chmod 0777 ./in RUN chmod 0777 ./in
RUN chmod 0777 ./out RUN chmod 0777 ./out
CMD ["./app", "--mermaid=./node_modules/.bin/mmdc", "--in=./in", "--out=./out", "--puppeteer=./puppeteer-config.json"] CMD ["./app", "--mermaid=./node_modules/.bin/mmdc", "--in=./in", "--out=./out", "--puppeteer=./puppeteer-config.json", "--allow-all-origins=true"]

21
Makefile Normal file
View File

@@ -0,0 +1,21 @@
DOCKER_IMAGE=tomwright/mermaid-server:latest
CONTAINER_NAME=mermaid-server
docker-image:
docker build --platform linux/x86_64 -t ${DOCKER_IMAGE} .
docker-run:
docker run -d --platform linux/x86_64 --name ${CONTAINER_NAME} -p 80:80 ${DOCKER_IMAGE}
docker-stop:
docker stop ${CONTAINER_NAME} || true
docker-rm:
make docker-stop
docker rm ${CONTAINER_NAME} || true
docker-logs:
docker logs -f ${CONTAINER_NAME}
docker-push:
docker push ${DOCKER_IMAGE}

View File

@@ -10,7 +10,7 @@ While this currently serves the diagrams via HTTP, it could easily be manipulate
Run the container: Run the container:
``` ```
docker run -d --name mermaid-server -p 80:80 tomwright/mermaid-server:latest docker run -d --name mermaid-server -p 80:80 tomwright/mermaid-server:latest --allow-all-origins=true
``` ```
### Manually as a go command ### Manually as a go command
@@ -22,6 +22,8 @@ go run cmd/app/main.go --mermaid=./mermaidcli/node_modules/.bin/mmdc --in=./in -
### Diagram creation ### Diagram creation
Use the query param 'type' to change between 'png' and 'svg' defaults to 'svg'.
#### POST #### POST
Send a CURL request to generate a diagram via `POST`: Send a CURL request to generate a diagram via `POST`:

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"flag" "flag"
"fmt" "fmt"
"github.com/tomwright/lifetime" "github.com/tomwright/grace"
"github.com/tomwright/mermaid-server/internal" "github.com/tomwright/mermaid-server/internal"
"os" "os"
) )
@@ -14,6 +14,7 @@ func main() {
in := flag.String("in", "", "Directory to store input files.") in := flag.String("in", "", "Directory to store input files.")
out := flag.String("out", "", "Directory to store output files.") out := flag.String("out", "", "Directory to store output files.")
puppeteer := flag.String("puppeteer", "", "Full path to optional puppeteer config.") puppeteer := flag.String("puppeteer", "", "Full path to optional puppeteer config.")
allowAllOrigins := flag.Bool("allow-all-origins", false, "True to allow all request origins")
flag.Parse() flag.Parse()
if *mermaid == "" { if *mermaid == "" {
@@ -31,19 +32,16 @@ func main() {
os.Exit(1) os.Exit(1)
} }
g := grace.Init(context.Background())
cache := internal.NewDiagramCache() cache := internal.NewDiagramCache()
generator := internal.NewGenerator(cache, *mermaid, *in, *out, *puppeteer) generator := internal.NewGenerator(cache, *mermaid, *in, *out, *puppeteer)
httpService := internal.NewHTTPService(generator) httpRunner := internal.NewHTTPRunner(generator, *allowAllOrigins)
cleanupService := internal.NewCleanupService(generator) cleanupRunner := internal.NewCleanupRunner(generator)
lt := lifetime.New(context.Background()).Init() g.Run(httpRunner)
g.Run(cleanupRunner)
// Start the http service. g.Wait()
lt.Start(httpService)
// Start the cleanup service.
lt.Start(cleanupService)
// Wait for all routines to stop running.
lt.Wait()
} }

7
go.mod
View File

@@ -1,5 +1,8 @@
module github.com/tomwright/mermaid-server module github.com/tomwright/mermaid-server
go 1.13 go 1.21
require github.com/tomwright/lifetime v1.0.0 require (
github.com/tomwright/grace v0.1.2
github.com/tomwright/gracehttpserverrunner v0.1.0
)

6
go.sum
View File

@@ -1,2 +1,4 @@
github.com/tomwright/lifetime v1.0.0 h1:Yzj+Td38eUUdZ1ewvOegywFBmKyaCh+8HjKBmeXw6OM= github.com/tomwright/grace v0.1.2 h1:8kH+S2GLqnwgWqUzi9CcjNoWJANZQnw9Xw65NPUr6WA=
github.com/tomwright/lifetime v1.0.0/go.mod h1:GUCHgRaR/zStvtJiOd3B4gIZayeiz3TgApC9kNYAOQI= github.com/tomwright/grace v0.1.2/go.mod h1:RKqz4gB3sQJpyas/CuiiriQQfUxSXhtWRfYtE7MG+Ok=
github.com/tomwright/gracehttpserverrunner v0.1.0 h1:n4iafOnJQEmRn05i1QzU+FPS0CU4ybxilyEdBEH/Ulk=
github.com/tomwright/gracehttpserverrunner v0.1.0/go.mod h1:FFHjVUgXu7KygMn+QlaoCesVlPOhaCnCvw35nvgzt5I=

46
internal/cleanup.go Normal file
View File

@@ -0,0 +1,46 @@
package internal
import (
"context"
"github.com/tomwright/grace"
"log"
"time"
)
// NewCleanupRunner returns a runner that can be used cleanup old diagrams.
func NewCleanupRunner(generator Generator) grace.Runner {
return &cleanupService{
generator: generator,
runEvery: time.Minute * 5,
cleanupLast: time.Hour,
}
}
// cleanupService is a runner that is used cleanup old diagrams.
type cleanupService struct {
generator Generator
runEvery time.Duration
cleanupLast time.Duration
}
// Run starts the cleanup process.
func (s *cleanupService) Run(ctx context.Context) error {
for {
select {
case <-ctx.Done():
return nil
default:
}
if err := s.generator.CleanUp(s.cleanupLast); err != nil {
log.Printf("error when cleaning up: %s", err.Error())
}
select {
case <-time.After(s.runEvery):
continue
case <-ctx.Done():
return nil
}
}
}

View File

@@ -1,41 +0,0 @@
package internal
import (
"log"
"time"
)
// NewCleanupService returns a service that can be used cleanup old diagrams.
func NewCleanupService(generator Generator) *cleanupService {
return &cleanupService{
generator: generator,
stopCh: make(chan struct{}),
}
}
// cleanupService is a service that can be used cleanup old diagrams.
type cleanupService struct {
generator Generator
stopCh chan struct{}
}
// Start starts the cleanup service.
func (s *cleanupService) Start() error {
for {
if err := s.generator.CleanUp(time.Hour); err != nil {
log.Printf("error when cleaning up: %s", err.Error())
}
select {
case <-time.After(time.Minute * 5):
continue
case <-s.stopCh:
return nil
}
}
}
// Stop stops the cleanup service.
func (s *cleanupService) Stop() {
close(s.stopCh)
}

View File

@@ -10,11 +10,12 @@ import (
) )
// NewDiagram returns a new diagram. // NewDiagram returns a new diagram.
func NewDiagram(description []byte) *Diagram { func NewDiagram(description []byte, imgType string) *Diagram {
return &Diagram{ return &Diagram{
description: []byte(strings.TrimSpace(string(description))), description: []byte(strings.TrimSpace(string(description))),
lastTouched: time.Now(), lastTouched: time.Now(),
mu: &sync.RWMutex{}, mu: &sync.RWMutex{},
imgType: imgType,
} }
} }
@@ -30,6 +31,8 @@ type Diagram struct {
mu *sync.RWMutex mu *sync.RWMutex
// lastTouched is the time that the diagram was last used. // lastTouched is the time that the diagram was last used.
lastTouched time.Time lastTouched time.Time
// the type of image to generate svg or png
imgType string
} }
// Touch updates the last touched time of the diagram. // Touch updates the last touched time of the diagram.
@@ -55,7 +58,7 @@ func (d *Diagram) ID() (string, error) {
encoded := base64.StdEncoding.EncodeToString(d.description) encoded := base64.StdEncoding.EncodeToString(d.description)
hash := md5.Sum([]byte(encoded)) hash := md5.Sum([]byte(encoded))
d.id = hex.EncodeToString(hash[:]) d.id = hex.EncodeToString(hash[:]) + d.imgType
return d.id, nil return d.id, nil
} }

View File

@@ -79,7 +79,7 @@ func (c cachingGenerator) generate(diagram *Diagram) error {
} }
inPath := fmt.Sprintf("%s/%s.mmd", c.inPath, id) inPath := fmt.Sprintf("%s/%s.mmd", c.inPath, id)
outPath := fmt.Sprintf("%s/%s.svg", c.outPath, id) outPath := fmt.Sprintf("%s/%s.%s", c.outPath, id, diagram.imgType)
if err := ioutil.WriteFile(inPath, diagram.description, 0644); err != nil { if err := ioutil.WriteFile(inPath, diagram.description, 0644); err != nil {
return fmt.Errorf("could not write to input file [%s]: %w", inPath, err) return fmt.Errorf("could not write to input file [%s]: %w", inPath, err)

View File

@@ -3,13 +3,48 @@ package internal
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/tomwright/grace"
"github.com/tomwright/gracehttpserverrunner"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
"time"
) )
// NewHTTPRunner returns a grace runner that runs a HTTP server.
func NewHTTPRunner(generator Generator, allowAllOrigins bool) grace.Runner {
httpHandler := generateHTTPHandler(generator)
if allowAllOrigins {
httpHandler = allowAllOriginsMiddleware(httpHandler)
}
r := http.NewServeMux()
r.Handle("/generate", httpHandler)
return &gracehttpserverrunner.HTTPServerRunner{
Server: &http.Server{
Addr: ":80",
Handler: r,
},
ShutdownTimeout: time.Second * 5,
}
}
// allowAllOriginsMiddleware sets appropriate CORS headers to allow requests from any origin.
func allowAllOriginsMiddleware(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
origin := r.Header.Get("Origin")
if origin == "" {
origin = "*"
}
w.Header().Set("Access-Control-Allow-Origin", origin)
h.ServeHTTP(w, r)
})
}
func writeJSON(rw http.ResponseWriter, value interface{}, status int) { func writeJSON(rw http.ResponseWriter, value interface{}, status int) {
bytes, err := json.Marshal(value) bytes, err := json.Marshal(value)
if err != nil { if err != nil {
@@ -22,12 +57,20 @@ func writeJSON(rw http.ResponseWriter, value interface{}, status int) {
} }
} }
func writeSVG(rw http.ResponseWriter, data []byte, status int) { func writeImage(rw http.ResponseWriter, data []byte, status int, imgType string) error {
switch imgType {
case "png":
rw.Header().Set("Content-Type", "image/png")
case "svg":
rw.Header().Set("Content-Type", "image/svg+xml") rw.Header().Set("Content-Type", "image/svg+xml")
default:
return fmt.Errorf("unhandled image type: %s", imgType)
}
rw.WriteHeader(status) rw.WriteHeader(status)
if _, err := rw.Write(data); err != nil { if _, err := rw.Write(data); err != nil {
panic("could not write bytes to response: " + err.Error()) return fmt.Errorf("could not write image bytes: %w", err)
} }
return nil
} }
func writeErr(rw http.ResponseWriter, err error, status int) { func writeErr(rw http.ResponseWriter, err error, status int) {
@@ -41,59 +84,72 @@ func writeErr(rw http.ResponseWriter, err error, status int) {
// URLParam is the URL parameter getDiagramFromGET uses to look for data. // URLParam is the URL parameter getDiagramFromGET uses to look for data.
const URLParam = "data" const URLParam = "data"
func getDiagramFromGET(rw http.ResponseWriter, r *http.Request) *Diagram { func getDiagramFromGET(r *http.Request, imgType string) (*Diagram, error) {
if r.Method != http.MethodGet { if r.Method != http.MethodGet {
writeErr(rw, fmt.Errorf("expected HTTP method GET"), http.StatusBadRequest) return nil, fmt.Errorf("expected HTTP method GET")
return nil
} }
queryVal := strings.TrimSpace(r.URL.Query().Get(URLParam)) queryVal := strings.TrimSpace(r.URL.Query().Get(URLParam))
if queryVal == "" { if queryVal == "" {
writeErr(rw, fmt.Errorf("missing data"), http.StatusBadRequest) return nil, fmt.Errorf("missing data")
return nil
} }
data, err := url.QueryUnescape(queryVal) data, err := url.QueryUnescape(queryVal)
if err != nil { if err != nil {
writeErr(rw, fmt.Errorf("could not read query param: %s", err), http.StatusBadRequest) return nil, fmt.Errorf("could not read query param: %s", err)
return nil
} }
// Create a diagram from the description // Create a diagram from the description
d := NewDiagram([]byte(data)) d := NewDiagram([]byte(data), imgType)
return d return d, nil
} }
func getDiagramFromPOST(rw http.ResponseWriter, r *http.Request) *Diagram { func getDiagramFromPOST(r *http.Request, imgType string) (*Diagram, error) {
if r.Method != http.MethodPost { if r.Method != http.MethodPost {
writeErr(rw, fmt.Errorf("expected HTTP method POST"), http.StatusBadRequest) return nil, fmt.Errorf("expected HTTP method POST")
return nil
} }
// Get description from request body // Get description from request body
bytes, err := ioutil.ReadAll(r.Body) bytes, err := ioutil.ReadAll(r.Body)
if err != nil { if err != nil {
writeErr(rw, fmt.Errorf("could not read body: %s", err), http.StatusInternalServerError) return nil, fmt.Errorf("could not read body: %s", err)
return nil
} }
// Create a diagram from the description // Create a diagram from the description
d := NewDiagram(bytes) d := NewDiagram(bytes, imgType)
return d return d, nil
} }
const URLParamImageType = "type"
// generateHTTPHandler returns a HTTP handler used to generate a diagram. // generateHTTPHandler returns a HTTP handler used to generate a diagram.
func generateHTTPHandler(generator Generator) func(rw http.ResponseWriter, r *http.Request) { func generateHTTPHandler(generator Generator) http.Handler {
return func(rw http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
var diagram *Diagram var diagram *Diagram
imgType := r.URL.Query().Get(URLParamImageType)
switch imgType {
case "png", "svg":
case "":
imgType = "svg"
default:
writeErr(rw, fmt.Errorf("unsupported image type (%s) use svg or png", imgType), http.StatusBadRequest)
return
}
var err error
switch r.Method { switch r.Method {
case http.MethodGet: case http.MethodGet:
diagram = getDiagramFromGET(rw, r) diagram, err = getDiagramFromGET(r, imgType)
case http.MethodPost: case http.MethodPost:
diagram = getDiagramFromPOST(rw, r) diagram, err = getDiagramFromPOST(r, imgType)
default: default:
writeErr(rw, fmt.Errorf("unexpected HTTP method %s", r.Method), http.StatusBadRequest) writeErr(rw, fmt.Errorf("unexpected HTTP method %s", r.Method), http.StatusBadRequest)
return return
} }
if err != nil {
writeErr(rw, err, http.StatusBadRequest)
return
}
if diagram == nil { if diagram == nil {
writeErr(rw, fmt.Errorf("could not create diagram"), http.StatusInternalServerError) writeErr(rw, fmt.Errorf("could not create diagram"), http.StatusInternalServerError)
return return
@@ -112,6 +168,8 @@ func generateHTTPHandler(generator Generator) func(rw http.ResponseWriter, r *ht
writeErr(rw, fmt.Errorf("could not read diagram bytes: %s", err), http.StatusInternalServerError) writeErr(rw, fmt.Errorf("could not read diagram bytes: %s", err), http.StatusInternalServerError)
return return
} }
writeSVG(rw, diagramBytes, http.StatusOK) if err := writeImage(rw, diagramBytes, http.StatusOK, imgType); err != nil {
writeErr(rw, fmt.Errorf("could not write diagram: %w", err), http.StatusInternalServerError)
} }
})
} }

View File

@@ -1,47 +0,0 @@
package internal
import (
"net/http"
)
// NewHTTPService returns a service that can be used to start a http server
// that will generate diagrams.
func NewHTTPService(generator Generator) *httpService {
return &httpService{
generator: generator,
}
}
// httpService is a service that can be used to start a http server
// that will generate diagrams.
type httpService struct {
httpServer *http.Server
generator Generator
}
// Start starts the HTTP server.
func (s *httpService) Start() error {
httpHandler := generateHTTPHandler(s.generator)
r := http.NewServeMux()
r.Handle("/generate", http.HandlerFunc(httpHandler))
s.httpServer = &http.Server{
Addr: ":80",
Handler: r,
}
if err := s.httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
if err != http.ErrServerClosed {
return err
}
}
return nil
}
func (s *httpService) Stop() {
if s != nil {
_ = s.httpServer.Close()
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,6 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@mermaid-js/mermaid-cli": "^8.6.4" "@mermaid-js/mermaid-cli": "^10.3.1"
} }
} }