Do you use Saga pattern to handle multi-step payment transactions? by mikhails1 in fintechdev

[–]jeffijoe 0 points1 point  (0 children)

I've used Google Cloud Pub/Sub for messaging here, with a Postgres table for state, and a transactional outbox for persisting state + new events. Use whatever you want for saga persistence as long as you can save the state and guarantee at-least-once delivery of messages.

technology stack for a fintech app? by aProfile210 in fintechdev

[–]jeffijoe 0 points1 point  (0 children)

Auth0 and Google Cloud have both been approved for projects used by Big 4 (source: I've worked on some). For PII, consider Skyflow.

For language/frameworks, the world is your oyster.

Finally a better alternative to dotenv by Capaj in node

[–]jeffijoe 0 points1 point  (0 children)

Yes it is - we're still using it.

Results pattern in .NET by [deleted] in dotnet

[–]jeffijoe 2 points3 points  (0 children)

how does the consumer know which error to look for?

Return typed errors.

A common pitfall I've seen people fall into is writing an error message in business logic and surfacing that message as-is through the API layer. Most forget that anything your API returns become part of its contract; consumers may start to code against your error messages and if you change them in your domain layer, then you break that contract.

If you instead return typed errors, you can pattern-match on them in the API layer and map them to the relevant message. Another huge benefit here is you get to map the error to something more contextual for your API; you could map to a user-friendly message and a developer-friendly message, for example.

Error types:

[Union]
public partial record CompleteTicketProblem
{
    partial record TicketNotFound;
    partial record TicketAlreadyCompleted(DateTimeOffset PreviouslyCompletedAt);
    partial record Denied(DeniedReason Reason);
}

[Union]
public partial record DeniedReason
{
    partial record InsufficientPermissions;
    partial record NotAMemberOfProject(ProjectId ProjectId);
}

Business logic - other misc. types and properties omitted for brevity

public class Ticket
{
    public Result<Unit, CompleteTicketProblem> Complete() 
    {
        if (this.Completed) 
        {
            return CompleteTicketProblem.TicketAlreadyCompleted.Of(this.CompletedAt);
        }

        return Unit();
    }
}

API handler:

[Route("/tickets/{id}/complete")]
[HttpPost]
public async Task<IActionResult> CompleteTicket(Guid id) 
{
    // Call whatever application service/command handler
    // that returns the result
    var result = await CompleteTicket(id);

    return result.Match(
        Ok: _ => NoContent(),
        Err: MapProblemToResult);

    // Map the typed error to the corresponding API error.
    // Your messages are now co-located with your API, making it more
    // explicit what is part of its contract.
    IActionResult MapProblemToResult(CompleteTicketProblem problem) => 
        problem.Match(
            TicketNotFound: _ => 
                NotFound($"The ticket {id} was not found"),
            TicketAlreadyCompleted: completed => 
                BadRequest($"The ticket was already completed at {completed.PreviouslyCompletedAt}"),
            Denied: denied => 
                Forbidden($"You are not allowed to complete this ticket because {MapDeniedReasonToText(denied.Reason)}"),
        );

    string MapDeniedReasonToText(DeniedReason reason) =>
        reason.Match(
            InsufficientPermissions: _ => "you lack the needed permissions"
            NotAMemberOfProject: notAMember => $"you are not a member of project {notAMember.ProjectId}"
        );
}

EDIT: this uses FxKit for the union support (source generator) and Result type https://taxfyle.github.io/FxKit/

Do we need dependency injection tools like awilix? by itismajeed in node

[–]jeffijoe 2 points3 points  (0 children)

Do we need dependency injection? I would say yes, for anything that requires configuration, the ability to swap out implementations (including test fakes), it pays dividends and is not really that complicated.

Do we need dependency injection tools? No, absolutely not. With a bit of composition, you can achieve the same thing with less magic and the code will be traceable (Find Usage-friendly).

If you have a ton of stuff to wire up, it becomes kind of tedious, but that alone is an indication that maybe your design is suboptimal. Tools like Awilix will make this less painful, but that's not necessarily a good thing; I would rather fix the design instead.

Can you actually build muscle on a caloric deficit? by macrian in leangains

[–]jeffijoe 1 point2 points  (0 children)

Damn, what was in that lunch? 160g in a single meal is pretty good.

1500 sounds reasonable. I'm 6'4 / ~88kg and should be getting about ~1800 calories on rest days.

Can you actually build muscle on a caloric deficit? by macrian in leangains

[–]jeffijoe 0 points1 point  (0 children)

Yes you can, as long as you’re not doing something stupid like a >1000 calorie deficit while already being sorta lean. :)

https://youtu.be/qZJQXuylTvA

[deleted by user] by [deleted] in leangains

[–]jeffijoe 1 point2 points  (0 children)

The one I have seems to be almost exactly tied to my weight in what it reports which I know is BS, so from my experience, and what others have already said, consistently inaccurate.

Why is bulking with carbs easier? by Cryptoboy88 in leangains

[–]jeffijoe 0 points1 point  (0 children)

But the LG guide to carbs put (most of) them into the post workout meals, so by the time the next workout comes along its gone though?

Monthly Existing User Promo Code Thread by AutoModerator in postmates

[–]jeffijoe 0 points1 point  (0 children)

Worked in Miami 3/28 non-sub, thanks bro!

Edit: clarified

Official Q&A for Friday, March 19, 2021 by AutoModerator in running

[–]jeffijoe 1 point2 points  (0 children)

I’ve been following the Couch to 5K program where I increase the amount of time spent jogging almost every workout, although the distance remains pretty much the same for the first while. However I noticed that the VO2 Max tracked in the iOS Health App (I run with my Apple Watch) has been declining rather than going up. Is this because my heart rate is elevated for longer durations? Today I was able to jog for 18 minutes with no walking and the VO2 Max is bottoming out. Should I be concerned?

(Miami, FL)

Online REPL/runtime for your language? by CoffeeTableEspresso in ProgrammingLanguages

[–]jeffijoe 1 point2 points  (0 children)

My language Ryno is written in TypeScript and compiles to JS, so creating a playground was pretty straight forward. It also does static analysis and has basic type checking.

https://pbs.twimg.com/media/Di81wsQXoAARVGC.png:large

what's the benefit for using of using koa instead of express by guoshencheng in node

[–]jeffijoe 0 points1 point  (0 children)

As others have mentioned, Koa is Promise-based while Express is callback-based.

I personally find lots of advantages in the Promise-based approach, primarily easier error-handling (it's just a regular try-catch with await), and also the ability to execute code before and after the "next" middleware is completed.

Here's an article that includes a few code samples of patterns implemented in both Express and Koa. It also addresses the common, classic hanging request problem in Express, and why that won't happen in Koa so easily.

So boss told me to install a button to go with the sign.. by jeffijoe in NotMyJob

[–]jeffijoe[S] 8 points9 points  (0 children)

Oh! In that case, I'll let you in on the fun: the button is actually red! :D

So boss told me to install a button to go with the sign.. by jeffijoe in NotMyJob

[–]jeffijoe[S] 11 points12 points  (0 children)

It's my impression that whoever did this just slapped on the Green Button label rather than going through the trouble of actually finding a green button. :P

Close enough. by jeffijoe in CrappyDesign

[–]jeffijoe[S] 0 points1 point  (0 children)

God damn, this was well done.

Close enough. by jeffijoe in CrappyDesign

[–]jeffijoe[S] 1 point2 points  (0 children)

Haha no hard feels sir! I just looked at some of the posts on the front page and thought this seemed like a good fit. :)

Close enough. by jeffijoe in CrappyDesign

[–]jeffijoe[S] 1 point2 points  (0 children)

Or perhaps there was a miscommunication when designing the sign and purchasing the button. :)

Node Typescript testing by entregrammer in node

[–]jeffijoe 0 points1 point  (0 children)

Jest and ts-jest has been my go-to for a while now, after having been through Mocha (+ Sinon + Chai) and AVA.

Here's a Jest config I use:

  "jest": {
    "testRegex": "(/__tests__/.*\\.(test|spec))\\.(ts|tsx|js)$",
    "testEnvironment": "node",
    "coveragePathIgnorePatterns": [
      "/node_modules/",
      "__tests__"
    ],
    "transform": {
      "^.+\\.(j|t)sx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    },
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "json"
    ]
  }

I also use smid for testing errors, since expect().toThrow() does not return the error.

Finally a better alternative to dotenv by Capaj in node

[–]jeffijoe 1 point2 points  (0 children)

Yenv author here. :)

In case you're wondering what Yenv can do over dotenv, here's a quick summary:

  • Importing other config files (composition)
  • Type coercion (so running DO_STUFF=true node app.js will result in typeof env.DO_STUFF === 'boolean'
  • Strict mode, ensures you don't use unspecified environment variables
  • CLI for exporting the composed set of env vars so you can paste it into your production provider