Skip to content

Instantly share code, notes, and snippets.

@Yengas
Yengas / 01-usage-example.html
Created February 20, 2020 20:00
Micro-frontend architecture and React with Web Components
<html>
<head>
<!-- Seller Partner Panel related code -->
<script src="$public-url/seller-store.vendor.min.js" type="text/javascript"></script>
<script src="$public-url/seller-store.min.js" type="text/javascript"></script>
</head>
<body>
<!-- Seller Partner Panel related code -->
<seller-store-editor />
<!-- Seller Partner Panel related code -->
@Yengas
Yengas / 02-render-with-css-example.tsx
Last active February 20, 2020 20:13
Micro-frontend architecture and React with Web Components
import root from 'react-shadow';
import styles from './components/index.scss';
class SellerStoreEditorWebComponent extends HTMLElement {
// ...
private getComponentToRender() {
return (
<root.div>
<SellerStoreEditor />
<style type="text/css">{styles}</style>
import React from 'react'
import TitleInput from './TitleInput';
import OptionInput from './OptionInput';
import {withLogic} from "../../utilities/with-logic";
import DataLogic from "./data-logic";
type Option = {
id: string;
text: string;
};
@Yengas
Yengas / jest-testcontainers-config.js
Created December 12, 2020 19:00
testing database layer with node.js
module.exports = {
postgre: {
image: 'postgres',
tag: '12.3-alpine',
ports: [5432],
env: {
POSTGRES_PASSWORD: 'integration-pass',
},
wait: {
type: 'text',
@Yengas
Yengas / 01-gitlab-ci.yml
Last active October 12, 2022 13:56
Gitlab CI YML for running Testcontainers tests in Gitlab
stages:
- test
integration-test:
extends: .node-cache
stage: test
image: node:14-alpine
services:
- name: docker:20.10.1-dind
name: 'Lint and Tests'
on: push
jobs:
test:
name: Lint and Test Code Base
runs-on: ubuntu-latest
strategy:
const postgreSQLAdapter: PostgreSQLAdapter = (global as any).postgreSQLAdapter;
const adRepository = new AdvertisementRepository(postgreSQLAdapter);
const repository = new ProductIntersectionRepository(postgreSQLAdapter);
describe('ProductIntersectionRepository', () => {
const UUID_PREFIX = 'f4f4c9e3-a077-4f3c-bf73-9c54cb57ffa';
beforeEach(async () => {
await postgreSQLAdapter.query('DELETE FROM advertisements');
await postgreSQLAdapter.query('DELETE FROM advertisement_products');
export class ProductIntersectionRepository {
constructor(private readonly postgreSQLAdapter: PostgreSQLAdapter)
async getActiveAdvertisementProducts(
query: ProductIntersectionQuery
): Promise<AdvertisementWithProducts[]>
}
type ProductIntersectionQuery = {
sellerID: number;
@Yengas
Yengas / 01-request.js
Last active March 18, 2021 01:03
a simple promise returning request function for http and https get, post
const http = require("http");
const https = require("https");
function request(options) {
return new Promise((resolve, reject) => {
const { url, data, ...rest } = options;
const parsedURL = new URL(url);
const isHTTPS = parsedURL.protocol === "https:";
const lib = isHTTPS ? https : http;