View server.js
This file contains 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 express = require("express"); | |
const fs = require("fs"); | |
const app = require("./app"); | |
const server = express(); | |
// Load file config.json | |
const file = fs.readFileSync("./config.json"); | |
const config = JSON.parse(file); |
View app.js
This file contains 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 request = require("request"); | |
const getStream = require("get-stream"); | |
const API_KEY = "your-api-key"; | |
function authorize(authorization) { | |
if (authorization !== API_KEY) { | |
throw new Error("Your API key is invalid or incorrect."); | |
} | |
} |
View company.repository.js
This file contains 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 axios = require("axios"); | |
async function fetchUsers() { | |
const { data } = await axios.get("https://api.github.com/users"); | |
return data; | |
} | |
async function fetchEmployees() { | |
const { data: { data } } = |
View company.service.js
This file contains 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 companyRepository = require("../repositories/company.repository"); | |
async function fetchCompanyProfile() { | |
const users = await companyRepository.fetchUsers(); | |
const employees = await companyRepository.fetchEmployees(); | |
const companyUsers = []; | |
for (let user of users) { | |
companyUsers.push({ | |
id: user.id, |
View company.handler.js
This file contains 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 companyService = require("../services/company.service"); | |
async function fetchCompanyProfile(req, res) { | |
try { | |
const companyProfile = await companyService.fetchCompanyProfile(); | |
res.json(companyProfile); | |
} catch (e) { | |
errorResponse(e, res); | |
} |
View company.repository.test.js
This file contains 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 expect = require("chai").expect; | |
const nock = require("nock"); | |
const companyRepository = require("../src/repositories/company.repository"); | |
const usersMock = require("./mocks/users"); | |
describe("test company repository", function () { | |
after(function() { | |
nock.restore(); | |
}); |
View company.service.test.js
This file contains 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 expect = require("chai").expect; | |
const { stub } = require("sinon"); | |
const companyRepository = require("../src/repositories/company.repository"); | |
const companyService = require("../src/services/company.service"); | |
const usersMock = require("./mocks/users"); | |
const employeesMock = require("./mocks/employees"); | |
describe("test company service", function () { | |
afterEach(() => { |
View company.handler.test.js
This file contains 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 expect = require("chai").expect; | |
const { spy, stub } = require("sinon"); | |
const companyService = require("../src/services/company.service"); | |
const companyHandler = require("../src/handlers/company.handler"); | |
const companyProfileMock = { | |
companyName: 'Facebook Inc', | |
companyUsers: [ | |
{ id: 1, name: 'mojombo' }, |
View home-feed.json
This file contains 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
[ | |
{ | |
"id": "c-17", | |
"title": "Campaign and Activity", | |
"items": [ | |
{ | |
"id": "47", | |
"type": "link", | |
"saved": false, | |
"text": "Chef Siscaa", |
View recipe.proto
This file contains 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
syntax = "proto3"; | |
package grpc; | |
option go_package = "./grpc"; | |
service RecipeService { | |
rpc FetchRecipe(RecipeFilter) returns (RecipeResult) {} | |
} | |
service RecipeCategoryService { |
OlderNewer