Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

feat: create code snippets for api (#342) #396

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

kacper-cyra
Copy link
Contributor

Closes #342

@vercel
Copy link

vercel bot commented Oct 18, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

coderscamp-website – ./

🔍 Inspect: https://vercel.com/coderscamp/coderscamp-website/2Uf2LQhPfEbSLzryvNdV6uTss64b
✅ Preview: https://coderscamp-website-git-issue-342-createcodesn-1520a2-coderscamp.vercel.app

coderscamp-storybook – ./

🔍 Inspect: https://vercel.com/coderscamp/coderscamp-storybook/A94PiDybNbq16p6aXG8t9HzY1Cca
✅ Preview: https://coderscamp-storybook-git-issue-342-createcode-6467b1-coderscamp.vercel.app

coderscamp-docs – ./

🔍 Inspect: https://vercel.com/coderscamp/coderscamp-docs/3wDnrfxBcqpdVGYLHCsDa7jV7CN1
✅ Preview: https://coderscamp-docs-git-issue-342-createcodesnipp-9d12bb-coderscamp.vercel.app

@KonradSzwarc KonradSzwarc temporarily deployed to coderscamp-issue-342-cr-glpvf9 October 18, 2021 18:03 Inactive
@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2021

Codecov Report

Merging #396 (d8c2bf2) into main (23a9f2c) will increase coverage by 0.04%.
The diff coverage is n/a.

❗ Current head d8c2bf2 differs from pull request most recent head dafd9a4. Consider uploading reports for the commit dafd9a4 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #396      +/-   ##
==========================================
+ Coverage   87.87%   87.92%   +0.04%     
==========================================
  Files         150      151       +1     
  Lines        1806     1830      +24     
  Branches      236      243       +7     
==========================================
+ Hits         1587     1609      +22     
- Misses        218      220       +2     
  Partials        1        1              
Flag Coverage Δ
api 85.60% <ø> (ø)
ui 98.48% <ø> (-0.54%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ckages/ui/src/components/EventsCard/EventsCard.tsx 91.66% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 23a9f2c...dafd9a4. Read the comment docs.

@MateuszNaKodach
Copy link
Member

@kacper-cyra Could you write in README or docs how to use it :) ?

templates/domain-function/domain-function.hbs Outdated Show resolved Hide resolved
templates/command/command.hbs Outdated Show resolved Hide resolved
templates/domain-function/domain-function.hbs Outdated Show resolved Hide resolved
Comment on lines 27 to 28
(pastEvents) => {{camelCase domainFunction}}(pastEvents, command),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change snippet like I suggested below, then you can change that snippet to this:

Suggested change
(pastEvents) => {{camelCase domainFunction}}(pastEvents, command),
);
{{camelCase domainFunction}}(command),
);

Copy link
Contributor

@hkawalek hkawalek Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, we can go even further and change applicationService.execute interface to sth like this.

this.applicationService.execute<{{properCase event}}>(
      eventStream,
      command,
      {{camelCase domainFunction}},
    );

Then inside execute we can map command to metadata and we don't need extra currying of domainFunction as proposed by @KrystianKjjk .
What do you think @nowakprojects ?

@KrystianKjjk
Copy link
Contributor

It will be good to add automationModule generator which add this 4 required files ;)

Copy link
Contributor

@hkawalek hkawalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good (it's cross-platform and it uses CLI, so it meets our requirements). If I were you, I would add some tests to give some kind of documentation, and what is more important, to protect from bugs if someone would like to change or add a new template. I would recommend you to use snapshot-testing and tmp.dir for that.

templates/module/generator.ts Outdated Show resolved Hide resolved
templates/utils/runActionConditionally.ts Outdated Show resolved Hide resolved
templates/utils/runActionConditionally.ts Outdated Show resolved Hide resolved
Comment on lines 27 to 28
(pastEvents) => {{camelCase domainFunction}}(pastEvents, command),
);
Copy link
Contributor

@hkawalek hkawalek Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, we can go even further and change applicationService.execute interface to sth like this.

this.applicationService.execute<{{properCase event}}>(
      eventStream,
      command,
      {{camelCase domainFunction}},
    );

Then inside execute we can map command to metadata and we don't need extra currying of domainFunction as proposed by @KrystianKjjk .
What do you think @nowakprojects ?

Copy link
Member

@MateuszNaKodach MateuszNaKodach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good for me :)
Big thank you for initiative and implementation.
We can introduce change proposed by @HTK4 in ApplicationService. Of course it could be done in another task.
Snapshot testing for that would be awesome!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create code snippets for api
6 participants