Skip to content

Instantly share code, notes, and snippets.

View vassalloandrea's full-sized avatar
🏔️
Sleeping atop a mountain

Andrea Vassallo vassalloandrea

🏔️
Sleeping atop a mountain
View GitHub Profile
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@vassalloandrea
vassalloandrea / logger.ts
Last active January 12, 2021 06:17
Winston logger configuration
import winston from 'winston'
const levels = {
error: 0,
warn: 1,
info: 2,
http: 3,
debug: 4,
}
@vassalloandrea
vassalloandrea / index.ts
Created January 9, 2021 08:29
Medium Morgan Winston Example - index TS
import express from "express";
import Logger from "./lib/logger";
const app = express();
const PORT = 3000;
app.get("/logger", (_, res) => {
Logger.error("This is an error log");
Logger.warn("This is a warn log");
@vassalloandrea
vassalloandrea / logger.ts
Last active January 12, 2021 06:16
Medium Morgan Winston Example - logger TS with comment
import winston from 'winston'
// Define your severity levels.
// With them, You can create log files,
// see or hide levels based on the running ENV.
const levels = {
error: 0,
warn: 1,
info: 2,
http: 3,
@vassalloandrea
vassalloandrea / morganMiddleware.ts
Last active January 16, 2021 07:37
Medium Morgan Winston Example - morganMiddleware TS
import morgan, { StreamOptions } from "morgan";
import Logger from "../lib/logger";
// Override the stream method by telling
// Morgan to use our custom logger instead of the console.log.
const stream: StreamOptions = {
// Use the http severity
write: (message) => Logger.http(message),
};
@vassalloandrea
vassalloandrea / morganMiddleware.ts
Created January 18, 2021 06:16
Medium Morgan Winston Example - morganMiddleware GraphQL TS
import morgan, { StreamOptions } from "morgan";
import { IncomingMessage } from "http";
import Logger from "../lib/logger";
interface Request extends IncomingMessage {
body: {
query: String;
};
@vassalloandrea
vassalloandrea / ci.yml
Last active August 5, 2021 01:00
React CI GH actions
# CI name
name: Run linters and specs
# The on key is used to define when
# the CI should be triggered, aka Event
on:
# When someone push or merge a pull request
# inside the main branch
push:
branches: