Skip to content

Instantly share code, notes, and snippets.

View ajoshi31's full-sized avatar
🤥
Git Push Origin Master

Atul Joshi ajoshi31

🤥
Git Push Origin Master
  • Nthgram Technologies Private Limited
  • Bangalore
View GitHub Profile

Rough Notes about CQRS and ES

Once upon a time…

I once took notes (almost sentence by sentence with not much editing) about the architectural design concepts - Command and Query Responsibility Segregation (CQRS) and Event Sourcing (ES) - from a presentation of Greg Young and published it as a gist (with the times when a given sentence was heard).

I then found other summaries of the talk and the gist has since been growing up. See the revisions to know the changes and where they came from (aka the sources).

It seems inevitable to throw Domain Driven Design (DDD) in to the mix.

@ajoshi31
ajoshi31 / read-csv-and-process.py
Last active December 22, 2023 03:22
Python read csv and post url
import csv
import aiohttp
import asyncio
from concurrent.futures import ThreadPoolExecutor
import time
from datetime import datetime
async def process_row(session, sem, executor, row):
url = 'https://your_domain_url'
payload = {
@ajoshi31
ajoshi31 / index.ts
Last active December 22, 2023 03:21
Specifications
specification oattern, #ddd, #typescript
interface Specification<T> {
isSatisfiedBy(candidate: T): boolean;
and(other: Specification<T>): Specification<T>;
or(other: Specification<T>): Specification<T>;
not(): Specification<T>;
}
abstract class CompositeSpecification<T> implements Specification<T> {
@ajoshi31
ajoshi31 / rest-api-response-format.md
Created February 25, 2023 10:33 — forked from igorjs/rest-api-response-format.md
REST API response format based on some of the best practices
@ajoshi31
ajoshi31 / auth.middle.ts
Created November 27, 2022 13:31
Middleware In Inversify
You can implement it like this:
Pass functions to endpoint decorator
@httpPost('/', authenticateToken(), authorizeUser(['administrator']))
Function example
export const authenticateToken = (/* PARAMS HERE */) => {
return async (req: Request, res: Response, next: NextFunction) => {
const authHeader = req.headers.authorization;
@ajoshi31
ajoshi31 / billing.controller.ts
Created November 24, 2022 08:26
Business Logic With Service Class
import * as express from 'express';
interface DecodedExpressRequest {}
class CourseController {
private models: any;
constructor(models: any) {
this.models = models;
}
@ajoshi31
ajoshi31 / student-typeorm.model.js
Created November 24, 2022 06:55
ORM Slim Model
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
@Entity()
export class Student {
@PrimaryGeneratedColumn()
student_id: number;
@Column()
studentFirstName: string;
@ajoshi31
ajoshi31 / anemic.design.refactored.ts
Last active December 22, 2023 03:20
Anemic Design Model
namespace AnemicModelPart2 {
class Bill {
static create(title: any, billNo: any) {
return new Bill();
}
}
class MyValidator {
static validateBillNo(billNo: any): boolean {
throw new Error('Method not implemented.');
@ajoshi31
ajoshi31 / index.js
Last active September 20, 2020 08:30
Roman King Sorting
/*
Sort the roman kings names in acending order
*/
const romanNumerals = ['xl', 'l', 'xxx', 'xx', 'ix', 'x', 'iv', 'v', 'iii', 'ii', 'i'];
const romanDecMap = {
i: 1,
ii: 2,
iii: 3,
iv: 4,
@ajoshi31
ajoshi31 / prepareElastic.js
Created April 28, 2020 13:36 — forked from stekhn/prepareElastic.js
Creates and prepares an Elasticsearch index, using the Node.js client. Closes the index before putting settings and mappings. The response and error handlers are optional, remove them if necessary.
var elastic = require('elasticsearch');
var client = new elastic.Client({ host: 'localhost:9200' });
var index = 'myindex';
var type = 'document';
(function init() {
Promise.resolve()
.then(deleteIndex, handleError)