Skip to content

Instantly share code, notes, and snippets.

View suciuvlad's full-sized avatar

Vlad Suciu suciuvlad

View GitHub Profile
@suciuvlad
suciuvlad / ApiConfigurator.ts
Created November 9, 2023 20:28
Open API Typescript Client - Simplified Example
// ApiConfiguration.ts
export class ApiConfiguration {
public static readonly BASE_URL: string = 'https://api.example.com';
// possibly include API keys, custom headers, etc.
}
@suciuvlad
suciuvlad / bonus.go
Created October 27, 2022 09:02
Go Generics Repository
// BonusRepository implements bonus.Repository
// backed by a psql database.
type BonusRepository[M GormModel[E], E any] struct {
GormRepository[M, E]
}
type bonusRepository struct {
db *gorm.DB
}
@suciuvlad
suciuvlad / 1_simple.go
Created July 8, 2022 06:26 — forked from sosedoff/1_simple.go
Golang Custom Struct Tags Example
package main
import (
"fmt"
"reflect"
)
// Name of the struct tag used in examples
const tagName = "validate"
@suciuvlad
suciuvlad / rules for good testing.md
Created March 7, 2022 11:24 — forked from Integralist/rules for good testing.md
Sandi Metz advice for writing tests

Rules for good testing

Look at the following image...

...it shows an object being tested.

You can't see inside the object. All you can do is send it messages. This is an important point to make because we should be "testing the interface, and NOT the implementation" - doing so will allow us to change the implementation without causing our tests to break.

@suciuvlad
suciuvlad / cloud-run.yml
Created February 21, 2022 16:28 — forked from jmaicaaan/cloud-run.yml
[Tutorial] Setting up cloud-run.yml for Github Actions
name: nextjs-cloud-run
on:
push:
branches:
- master
- main
env:
CLOUD_RUN_PROJECT_ID: ${{ secrets.CLOUD_RUN_PROJECT_NAME }}
@suciuvlad
suciuvlad / consumer.go
Last active January 5, 2021 16:59
RabbitMQ Multiple Consumers
package main
import (
"log"
"github.com/streadway/amqp"
)
func failOnError(err error, msg string) {
if err != nil {
app.use(
'/graphql',
bodyParser.json(),
graphqlExpress(async (req, res) => {
//afterware to attach the headers to current request object
const addCookiesLink = new ApolloLink((operation, forward) => {
return forward(operation).map(response => {
const context = operation.getContext();
const cookies = context.response.headers.get('set-cookie');
@suciuvlad
suciuvlad / main-service-engine-resolvers.ts
Last active July 15, 2018 17:32
Main Service with Apollo Engine & Cache Hints
import { ApolloEngine } from 'apollo-engine';
const app = express();
app.use(
'/graphql',
bodyParser.json(),
graphqlExpress(async (req, res) => {
...
const schema; // created previously
@suciuvlad
suciuvlad / main-service-engine.ts
Last active July 15, 2018 16:38
Main Service with Apollo Engine
import { ApolloEngine } from 'apollo-engine';
const app = express();
app.use(
'/graphql',
bodyParser.json(),
graphqlExpress(async (req, res) => {
...
const schema; // created previously
@suciuvlad
suciuvlad / running-the-app.ts
Created July 13, 2018 18:49
graphql-microservices-example
git checkout 1-basic-app
lerna bootstrap
lerna run start:dev --parallel --concurrent