Skip to content

Instantly share code, notes, and snippets.

Pavel PavelPolyakov

Block or report user

Report or block PavelPolyakov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@PavelPolyakov
PavelPolyakov / format-everything.py
Created Feb 16, 2020
format repo using git-filter-repo
View format-everything.py
#!/usr/bin/env python3
"""
This script is meant to format all java files in your repo using maven-formatter-plugin
"""
import argparse
import os
import sys
import subprocess
View error-logging-4
"err": {
"type": "Error",
"message": "Oh no, something bad happened, try to debug me",
"stack": "Error: Oh no, something bad happened, try to debug me\n at Object.<anonymous> (/app/src/modules/routes/error-thrower/index.ts:8:13)"
}
View index.ts
import * as sourceMapSupport from "source-map-support";
sourceMapSupport.install();
View error-logging-2
"err": {
"type": "Error",
"message": "Oh no, something bad happened, try to debug me",
"stack": "Error: Oh no, something bad happened, try to debug me\n at Object.<anonymous> (/app/dist/modules/routes/error-thrower/index.js:17:19)"
}
View error-logging-1.sh
docker-compose -f docker-compose.production.yaml build
docker-compose -f docker-compose.production.yaml up
View index.ts
// at the top
import errorThrowerRoutes from "./modules/routes/error-thrower";
// make server more verbose
const server: fastify.FastifyInstance<
Server,
IncomingMessage,
ServerResponse
> = fastify({logger:true});
View index.ts
import * as fp from "fastify-plugin";
export default fp(async (server, opts, next) => {
server.route({
url: "/error-thrower",
method: ["GET"],
handler: async (request, reply) => {
throw new Error("Oh no, something bad happened, try to debug me");
return reply.send({ date: new Date(), works: true });
}
View docker-compose.production.yaml
version: '3'
services:
my-project-ts:
build: .
depends_on:
- mongodb
ports:
- '3000:3000'
environment:
- NODE_ENV=production
View Dockerfile
FROM node:dubnium-alpine
WORKDIR /app
COPY . .
RUN npm install --no-progress --quiet
RUN npm run build
CMD [ "npm", "start", "--silent" ]
You can’t perform that action at this time.