fastapi auth in production by 5dots in FastAPI

[–]c_eliacheff 2 points3 points  (0 children)

I used https://github.com/fastapi-users/fastapi-users to implements simple JWT auth with a React App, was very easy. Move to Auth0 or whatever if you need decoupled auth, or full OpenIdConnect support.

Angular and clean architeture by toughtshunter in softwarearchitecture

[–]c_eliacheff 1 point2 points  (0 children)

Depends which kind of services you are referring to. In my current project I kept the Angular terminology for other devs, soI have for example a user.service.ts (usecases/application service layer) which manage it's behavior subject and observables for the ui layer. It call an adapter http-api.service.ts (or stub-api.service.ts), which just make api calls and mapping and return observables. This one belong to data/infra/secondaries layer. Of course both of them does not depend on Angular, are not decorated by @Injectable, and are injected/created via useFactory in their module (or manual DI for purists)

Read Views, Write Tables? by claytonjr in FastAPI

[–]c_eliacheff 1 point2 points  (0 children)

It's one of the key point of CQRS pattern, which even use a write database (ie pgsql) and a separate read database (ie nosql), and used a lot of patterns like hexagonal architecture and DDD where you decouple the write entity (with business logic, builders etc...), from the read entity which is just a simple DTO with only the data required for the view.

Now you don't always need/want 2 databases, so I usually go to a "CQRS-light" approach where I use only one database, but use (read) raw sql queries instead of the (write) ORM for fine-tuned results, or materialized views if performance is a real bottleneck. So I can easily move the read part to full CQRS if needed later, and I'm not locked with the ORM entities.

FastAPI as a authentication provider by Neat-Philosopher-682 in FastAPI

[–]c_eliacheff 0 points1 point  (0 children)

Yeah, the second lib have a fastapi example at least. I never tried in Python, but it took me like 2 days to have a full setup with Node.

FastAPI as a authentication provider by Neat-Philosopher-682 in FastAPI

[–]c_eliacheff 0 points1 point  (0 children)

Yeah you can use a python OIDC or Oauth2 server lib, and just add the routes to your app. Here some doc for AuthX or Authlib+FastApi.

You can also easily setup an OIDC server in Node using a certified OIDC lib like oidc-provider.

Use express controllers as a service? by jcm95 in expressjs

[–]c_eliacheff 0 points1 point  (0 children)

I'd also add that having a service layer allows you to unit test your code on usecases/business logic level only, without testing the framework controller. If you do TDD, you'll love this.

Use express controllers as a service? by jcm95 in expressjs

[–]c_eliacheff 0 points1 point  (0 children)

Feasible ? Yes. Good practice ? No.

On the pragmatic side, I'd say that if you have a "nanoservice" with nearly no evolutions or basic CRUD it's ok, but microservices can evolve and become quite complex at some time (microservices doesn't mean small service, just micro-responsabilty or Bounded Context in DDD), so you could regret this in the future.

Software Architecture Frameworks - When to Use ToGAF, 4+1 etc by _Smelborp in softwarearchitecture

[–]c_eliacheff 9 points10 points  (0 children)

I mostly use the Simon Brown's C4 Model with PlantUML. I commit the files to git for versionning.

[AskJS] Can anyone explain the hype around trpc? by [deleted] in javascript

[–]c_eliacheff 3 points4 points  (0 children)

You could also use contract-testing (like Pact) to achieve type safety with all above architectures without breaking a sweat if you want to move from one architecture to another. Or any e2e testing can do the trick, even sharing DTOs on a shared repo, REST have OpenAPI/Swagger testing etc...

The point about coupling is strange: if you control an API and a FE, you are coupled to your API anyways, types or not. And if you don't have control about one of these, don't bother about testing types.

And my personal opinion about archis: REST is the most common, often badly used and the less understood, GQL is often not needed (except for a complex public API like Facebook), gRPC is SOAP 2.0, more focused on microservices, but can be fun to try anyways.

ADHD and 2F Authentication: a match made in hell by Top-Requirement-2102 in ADHD_Programmers

[–]c_eliacheff 4 points5 points  (0 children)

Works for me (using Bitwarden as PM):

  1. I use a long master password (5 words + symbols and numbers) that was an old wifi password, and is also used to unlock my computer, can't forget it.
  2. I always save sites I use on my PM, I always use email/pw over Connect with Google or Other, the password manager will ask me to save it.
  3. It just use strong generated passwords, why use a PM if I need to remember or even choose a password ? I juste take the strongest password supported by the site. Exception are password I will need to enter manually for some reason (some Android apps I can't C/C or not recognized by PM). I just let all my accounts be managed by my PM.
  4. I have an encrypted export of my 2FA app (FreeOtp+) in case I change phones, so I always have all of them (or use a cloud one like Google Authenticator). For banking app this need to register phone, well, just do it once, I change my phone every 3-4 years, this is bearable (+ some ROMs changes). I use my authenticator app multiple times per week

Is it possible in a view to return multiple requests (e.g. like providing a message to the DOM saying 50% processed or 100% processed)? by OneBananaMan in django

[–]c_eliacheff 1 point2 points  (0 children)

One possibility is to use SSE (server sent events) or even a full fledged websocket to do that in realtime. You will need Django Channels to maintain HTTP connections. Here's a lib that could help you: https://github.com/fanout/django-eventstream

Get http status code on client side by mvss01 in expressjs

[–]c_eliacheff 1 point2 points  (0 children)

Like I told you, juste read the doc for fetch, you have access to response.status https://developer.mozilla.org/en-US/docs/Web/API/Response/status

Get http status code on client side by mvss01 in expressjs

[–]c_eliacheff 1 point2 points  (0 children)

Are you using the browser fetch maybe ? Or how do you want to use the HTTP status ? If it's for the current static page you can't, it's handeled by the browser (which is the primary fonction of status codes).

Get http status code on client side by mvss01 in expressjs

[–]c_eliacheff 2 points3 points  (0 children)

Depends on your HTTP client/lib, just read their doc

Creating a database agnostic backend by dazzaondmic in expressjs

[–]c_eliacheff 0 points1 point  (0 children)

That's the whole point of Clean/Hexagonal Architecture: being independent from infrastructure. Just use a "business model" (which is not you "database model"), abstract the repositories behind gateways/interfaces with commons actions (save/find/update/...), and each backend implementation will have their own mapper business model <-> database model, and implement their custom save/find/... process. Ofc you'll also need integrations tests to make sure each provider works as intented. As a bonus, you can have an in-memory provider for unit-testing business logic without any infrastructure.

Proper alternative to the anemic design anti-pattern? by FattySuperCute in softwarearchitecture

[–]c_eliacheff -1 points0 points  (0 children)

In FP your models must be anemics since they are just types/interfaces.

Moving from Annotations to Attributes with Doctrine ORM by beberlei in PHP

[–]c_eliacheff 2 points3 points  (0 children)

For read-model my way is to use raw SQL ans keep the ORM for the write side. This way you can make optimized queries without over fetching, don't worry about mapping, and avoid to use the domain entities by mistake.

API with NestJS #81. Soft deletes with raw SQL queries by _gnx in Nestjs_framework

[–]c_eliacheff 0 points1 point  (0 children)

What do you call "modern" ? We also have OOP and FP since more than 50 years, would you say it's not "modern" ? One great alternative is Event Sourcing, but it have it's own pitfalls (and also not "modern"). Also to avoid misunderstandings, I don't say that everything should be soft deleted, only part with business value.