This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker-compose.yml | |
version: '3.8' | |
services: | |
user: | |
build: | |
context: ./userService | |
image: microservice/demo/user | |
restart: "no" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# userService/Dockerfile | |
FROM node:15 | |
WORKDIR /app | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
EXPOSE 50051 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// userService/api.js | |
const bcrypt = require('bcrypt'); | |
const auth = require("./auth"); | |
const messages = require('./proto/user_pb'); | |
const ObjectId = require('mongodb').ObjectID; | |
module.exports = class API { | |
constructor(db, grpc) { | |
this.db = db; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// userService/index.js | |
require('dotenv').config(); | |
const grpc = require('@grpc/grpc-js'); | |
const { MongoClient } = require("mongodb"); | |
const services = require('./proto/user_grpc_pb'); | |
const API = require("./api"); | |
// Mongo Connection | |
const dbClient = new MongoClient(process.env.DB_URI, { useUnifiedTopology: true }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// protos/user/user.proto | |
syntax = "proto3"; | |
package demo_user; | |
option go_package = "github.com/Joker666/microservice-demo/protos/user"; | |
service UserSvc { | |
rpc register (RegisterRequest) returns (UserResponse); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
var theThing = null; | |
var replaceThing = function () { | |
var originalThing = theThing; | |
var unused = function () { | |
if (originalThing) console.log("hi"); | |
}; | |
theThing = { | |
longStr: new Array(10000).join("*"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
var theThing = null; | |
var replaceThing = function () { | |
var originalThing = theThing; | |
var unused = function () { | |
if (originalThing) console.log("hi"); | |
}; | |
theThing = { | |
longStr: new Array(10000).join("*"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const server = http.createServer((req, res) => { | |
const requestLogs = []; | |
requestLogs.push({ url: req.url, array: new Array(10000).join("*") | |
res.end(JSON.stringify(requestLogs)); | |
}); | |
server.listen(3000); | |
console.log("Server listening to port 3000. Press Ctrl+C to stop it."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const requestLogs = []; | |
const server = http.createServer((req, res) => { | |
requestLogs.push({ url: req.url, array: new Array(10000).join("*") | |
res.end(JSON.stringify(requestLogs)); | |
}); | |
server.listen(3000); | |
console.log("Server listening to port 3000. Press Ctrl+C to stop it."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"net/http" | |
"sync" | |
_ "net/http/pprof" |