Skip to content

Instantly share code, notes, and snippets.

View jayisaac0's full-sized avatar

Joshua Isaac jayisaac0

View GitHub Profile
@jayisaac0
jayisaac0 / machineId.js
Created February 23, 2020 01:27 — forked from 19h/machineId.js
Generates IRC compatible unique machine-ID. Node.js (tested with 0.11.10)
var machineId = (function() {
var n = require("os").networkInterfaces(),
x = {};
return Object.keys(n).filter(function(v) {
return !n[v].forEach(function(v) {
v.mac.substr(0, v.mac.indexOf(":")) !== "00" && (x[v.mac] = 1)
})
}), Object.keys(x)
})().split(":").filter(function(v) {
@jayisaac0
jayisaac0 / package.json
Created October 21, 2020 18:20
gateway packages
{
"name": "gateway",
"version": "1.0.0",
"description": "",
"main": "src/server.ts",
"scripts": {
"start": "ts-node src/server.ts",
"build:watch": "onchange 'src/**/*.ts' -- npm run build",
"build": "tsc"
},
{
"compilerOptions": {
"module": "commonjs",
"resolveJsonModule": true,
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": false,
"sourceMap": false,
"outDir": "build",
"experimentalDecorators": true,
@jayisaac0
jayisaac0 / routeschema.ts
Last active October 21, 2020 19:15
interface
import fastify from 'fastify';
export interface RouteSchema extends fastify.RouteSchema {
tags?: string[];
body?: object;
data?: object;
params?: object;
response?: any;
description?: string;
summary?: string;
@jayisaac0
jayisaac0 / server.ts
Created October 21, 2020 19:56
server
import fastify from 'fastify';
import { Server, IncomingMessage, ServerResponse } from 'http';
import fastifyFormbody from 'fastify-formbody';
import dotenv from 'dotenv';
import helmet from 'fastify-helmet';
import fastswagger from 'fastify-swagger';
dotenv.config({ path: __dirname + '/../.env' });
import routes from './routes';
@jayisaac0
jayisaac0 / requests.ts
Last active October 22, 2020 19:12
requests
class Requests {
static requestBody(itemInterface, requiredValues ) {
return {
type: 'object',
additionalProperties: false,
properties: itemInterface,
required: requiredValues
}
}
@jayisaac0
jayisaac0 / responses.ts
Last active October 22, 2020 19:21
responses
class Responses {
static errorResponseObj(){
return {
type: 'object',
properties: {
code: { type: 'number' },
message: { type: 'string' },
error: {type: 'string'}
}
}
import * as fastify from 'fastify';
import Responses from '../../../utils/responses';
import {RouteSchema} from '../../../@types/routeschema';
import Requests from '../../../utils/requests';
import requestmaker from '../../../utils/requestmaker';
export default (app: fastify.FastifyInstance, options, done) => {
const action = 'Auth';
version: '3.7'
services:
app:
build:
context: .
dockerfile: Dockerfile-build
image: gateway
container_name: gateway
restart: unless-stopped
FROM node:12-alpine as builder
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
COPY package*.json ./
RUN npm config set unsafe-perm true
RUN npm install -g typescript
RUN npm install -g ts-node
USER node
RUN npm install
COPY --chown=node:node . .