Skip to content

Instantly share code, notes, and snippets.

@alvag
alvag / pasos-node-ts-jest.md
Created October 13, 2023 11:21 — forked from Klerith/pasos-node-ts-jest.md
Note + TypeScript + Jest = Testing

Pasos para configurar Jest con TypeScript, en Node

Documentación oficial sobre Jest

  1. Instalaciones de desarrollo (super test es útil para probar Express)
npm install -D jest @types/jest ts-jest supertest
@alvag
alvag / configurar-node-ts.md
Created October 13, 2023 11:19 — forked from Klerith/configurar-node-ts.md
Node con TypeScript - TS-Node-dev simplificado

Node con TypeScript - TS-Node-dev (preferido)

  1. Instalar TypeScript y demás dependencias
npm i -D typescript @types/node ts-node-dev rimraf
  1. Inicializar el archivo de configuración de TypeScript ( Se puede configurar al gusto)
npx tsc --init --outDir dist/ --rootDir src
@alvag
alvag / pasos-node-typescript.md
Created October 12, 2023 09:59 — forked from Klerith/pasos-node-typescript.md
Configurar proyecto de Node con TypeScript

Pasos para usar Node con TypeScript con Nodemon

Más información - Docs Oficiales

  1. Instalar TypeScript y tipos de Node, como dependencia de desarrollo
npm i -D typescript @types/node
  1. Inicializar el archivo de configuración de TypeScript ( Se puede configurar al gusto)
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
@alvag
alvag / mixins.scss
Created December 5, 2019 15:02
Mixins scss
@mixin min-width-576 {
@media (min-width: 576px) {
@content;
}
}
@mixin min-width-768 {
@media (min-width: 768px) {
@content;
}
@alvag
alvag / index.html
Created November 29, 2019 22:27
Toggle switch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.switch {
position: relative;
@alvag
alvag / serverClass.js
Created July 4, 2019 20:44 — forked from Yuribenjamin/serverClass.js
Express.js simple server written using ECMAScript 2015 => JavaScript classes, tested and working.
const express = require('express');
const path = require('path');
const open = require('open');
class Server {
constructor(port, app) {
this.port = port;
this.app = app;
}
get() {
@alvag
alvag / smoothScroll.js
Created June 17, 2019 19:12
smoothScroll
const smoothScroll = element =>
document.querySelector(element).scrollIntoView({
behavior: 'smooth'
});
smoothScroll('#fooBar'); // scrolls smoothly to the element with the id fooBar
smoothScroll('.fooBar'); // scrolls smoothly to the first element with a class of fooBar
@alvag
alvag / required-param.js
Last active May 8, 2019 21:31
Useful JavaScript Tricks
const isRequired = () => { throw new Error('param is required'); };
const hello = (name = isRequired()) => { console.log(`hello ${name}`) };
// This will throw an error because no name is provided
hello();
// This will also throw an error
hello(undefined);
@alvag
alvag / index.html
Created March 7, 2019 19:16
spinner
<div class="donut"></div>