Skip to content

Instantly share code, notes, and snippets.

View waldemarnt's full-sized avatar
⌨️
typing...

Waldemar Neto waldemarnt

⌨️
typing...
View GitHub Profile
@waldemarnt
waldemarnt / thiago.ts
Last active July 17, 2022 23:59
Thiago TS exemplo
export type Result<E, S> = Failure<E, S> | Success<E, S>;
export class Failure<E, S> {
constructor(private _value: E) {}
isError(): this is Failure<E, S> {
return true;
}
value(): E {
require("@std/esm")
module.exports = require("./main.mjs").default
@waldemarnt
waldemarnt / math.mjs
Created August 21, 2017 16:56
std esm
const math = {
sum(n1,n2) {
return n1+n2;
}
};
export default math;
@waldemarnt
waldemarnt / main.mjs
Last active August 21, 2017 16:55
std esm
import Math from './math';
import express from 'express';
const app = express();
app.get('/sum', function (req, res) {
res.send(`The sum is ${Math.sum(1,1)}`)
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
@waldemarnt
waldemarnt / classes.js
Last active October 13, 2020 19:01
Fake,Spy,Stub, Mock
const Database = {
findAll() {}
}
class UsersController {
constructor(Database) {
this.Database = Database;
}
getAll() {
@waldemarnt
waldemarnt / tdd doubles
Created January 30, 2017 23:32
test-doubles.js
import sinon from 'sinon';
const Database = {
findAll() {}
}
class UsersController {
constructor(Database) {
this.Database = Database;
}
const loop = (gen, interval) => {
const point = gen.next();
if(!point.done) {
return setTimeout(() => {
console.log(point.value);
loop(gen, interval);
}, interval);
} else {
console.log('done');
@waldemarnt
waldemarnt / docker-compose.prod.yml
Created August 30, 2016 01:58
docker compose to be used in production
version: '2'
services:
library:
build: .
environment:
NODE_ENV: production
ports:
- '3000:3000'
@waldemarnt
waldemarnt / docker-compose.yml
Created August 30, 2016 01:53
Docker and node.js docker-compose example
version: '2'
services:
library:
build:
context: .
dockerfile: Dockerfile
command: node_modules/.bin/nodemon --exec npm start
environment:
NODE_ENV: development
ports:
@waldemarnt
waldemarnt / Dockerfile
Last active February 10, 2021 08:52
Dockerfile to build a Node.js app
FROM node:4.3.2
RUN useradd --user-group --create-home --shell /bin/false app &&\
npm install --global npm@3.7.5
ENV HOME=/home/app
COPY package.json npm-shrinkwrap.json $HOME/library/
RUN chown -R app:app $HOME/*