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
| //Initialize redis and create a client. | |
| const redis = require('redis'); | |
| const client = redis.createClient(); | |
| //Error handler | |
| client.on('error',(err)=>{ | |
| console.log("error",err); | |
| return err; | |
| }); | |
| //Check if errors occured while connecting to the db. | |
| const initializationOptions = { |
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 fs = require('fs'); | |
| const path = require('path'); | |
| const { promisify } = require("util"); | |
| const readFile = promisify(fs.readFile); | |
| const crud = {}; | |
| crud.baseDir = path.join(__dirname,'./database'); | |
| //Write data to a file |
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 {ApolloServer, gql} = require('apollo-server') | |
| const typeDefs = gql` | |
| type User { | |
| email: String! | |
| password: String! | |
| } | |
| type Mutation { | |
| imapMutation(email: String!, password: String!): User! | |
| } | |
| ` |
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 typeDefs = gql` | |
| scalar Date | |
| # Make a type user | |
| type User { | |
| email: String! | |
| password: String! | |
| data: [Graph!] | |
| } |
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 newCategory = { | |
| Thumbnail: undefined, | |
| checkFile (category, file) { | |
| file ? | |
| category.categoryThumbnail = {name: file.public_id, url: file.url} | |
| : category.categoryThumbnail = null | |
| this.Thumbnail = category.categoryThumbnail; | |
| return this; | |
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 { expect } = require('chai') | |
| const createCategoryFactory = require('../create-category') | |
| const ProductCategory = require('./mocks/product-category.mock') | |
| const req = require('./mocks/req.mock') | |
| const res = require('./mocks/res.mock') | |
| describe('create-category', () => { | |
| const createCategory = createCategoryFactory({ ProductCategory }) | |
| beforeEach(() => { |
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 https = require("https"); | |
| const monthNames = [ | |
| "January", | |
| "February", | |
| "March", | |
| "April", | |
| "May", | |
| "June", | |
| "July", |
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
| /******************** HELPER FUNCTION **********************/ | |
| //Filter array for any distinct values --- STACKOVERFLOW | |
| function isDistinct(array) { | |
| return new Set(array).size === array.length; | |
| } | |
| // Use combination sum to get all the possible combinations | |
| function combinationSum(candidates, target) { | |
| var result = []; |
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
| interface IEdge { | |
| key: string | |
| from: string | |
| to: string | |
| } | |
| interface IVertex { | |
| key: string | |
| label: string | |
| } |
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
| let str = "i am a boy and i am happy to be in your midst" | |
| const final = {} | |
| str.split(" ").map((s, index, arr) => { | |
| // remove the commas | |
| // make lowercase | |
| // console.log({s}) | |
| if(s == "am") { | |
| if(!final[s]) { |
OlderNewer