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
| // router | |
| router.post( | |
| '/sms', | |
| auth, | |
| awaitHandler(async (req, res) => { | |
| const user = await UsersController.getUserById(req.user._id); | |
| const mobileNumber = req.body.mobileNumber; | |
| await SMSService.onSMSShare(mobileNumber, 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
| Most of my projects are considered private and spread accross multiple github/bitbucket/gitlab accounts so I can't share them as a whole but I can share some of the standalone files (controllers, services, components, etc). | |
| I understand some people might be suspicious of the code ownership but I guarantee that all (or at least the large majority) of the code in these examples were written personally by me. | |
| Some of my latest work (9/6/2019): | |
| This feature allows sharing of referral codes via sms (supports other forms such as copy, facebook, twitter, email) | |
| but I don't consider them good of a reference ( nothing special ). SMS sending was implemented using Twilio and | |
| proved very confusing mostly due to very little documentation and technical support from their side (requires | |
| configuration on the client before api can be used). |
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
| public static async addLead(lead: ILead) { | |
| if (await ValidationService.validate(lead, ["name", "surname", "company"]) && await ValidationService.checkIfLeadExists(lead, ["name", "surname", "company"], Lead)) { | |
| lead.lastUpdate = new Date().toISOString(); | |
| // Create new lead | |
| const createdLead: ILead = await Lead.create(lead); | |
| // Get company from lead | |
| const populatedLead: ILead = await Lead.findById(createdLead._id).populate('company').exec(); | |
| // Generate emails | |
| createdLead.emails = await EmailService.generateEmails(lead, <ICompany>populatedLead.company); | |
| // Add emails |
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
| app.use(async (req, res, next) => { | |
| if (req.url === '/user/login' || req.url === '/user/register' || req.url === '/user/register-fb') { | |
| next(); | |
| } else { | |
| try { | |
| const accessToken = req.headers['access-token']; | |
| if (accessToken) { | |
| const user = await User.findOne({ accessToken }); |
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
| import { Response, Request } from 'express'; | |
| import { NextFunction } from 'connect'; | |
| import { FieldValidationError, DuplicateKeyError } from './validation.errors'; | |
| /** | |
| * Error handler for routes | |
| * @param callback : `any` - callback(req, res) which calls metohod from service and sends a responose | |
| */ | |
| export function errorHandler(callback: any) { | |
| return async (req: Request, res: Response, next: NextFunction) => { |
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
| import { CompanyService } from './../../services/company/company.service'; | |
| import express, { Router, Request, Response } from "express"; | |
| import { errorHandler } from "../../errors/error.handler"; | |
| import { ICompany } from '../../models'; | |
| import { ServiceResponse } from '../../models/service.response.model'; | |
| export const companyRouter: Router = express.Router(); | |
| companyRouter.get("", errorHandler(async (req: Request, res: Response) => { | |
| const response: ServiceResponse = await CompanyService.getCompanies(); |
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
| { | |
| "data": { | |
| "emails": [{ | |
| "_id": "5d59d54ecf67de14d4252d63", | |
| "address": "david@setter.com", | |
| "validationTimestamp": "2019-08-18T22:46:38.477Z", | |
| "valid": true, | |
| "__v": 0 | |
| }, { | |
| "_id": "5d59d550cf67de14d4252d66", |
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 people = [ | |
| { | |
| name: 'Ante', | |
| age: 25, | |
| knownLanguages: [ | |
| { | |
| name: 'HTML', | |
| platform: 'browser', | |
| category: 'web' | |
| }, |
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
| { | |
| "itemId": 22210456, | |
| "parentItemId": 22210456, | |
| "name": "Tyson® Premium Chunk White Chicken Breast, 12.5 oz. (Twin Pack)", | |
| "salePrice": 4.98, | |
| "upc": "023700028877", | |
| "categoryPath": "Food/Meal Solutions, Grains & Pasta/Canned Goods/Meat & Poultry", | |
| "shortDescription": "Simplify lunch time with Tyson® Premium Chunk White Chicken Breast. Premium white meat chicken is lightly seasoned and cooked to perfection, cut into chunks, and canned in water for the convenience of ready-to-eat chicken anytime. With 13 grams of protein per serving, our chicken is juicy, flavorful, and 98% fat-free. Simply mix drained chicken with mayonnaise and sweet relish, then serve with crackers for a quick and simple lunch. Includes two 12.5 oz. cans. Everything seems to turn out a whole lot better when you just keep it simple. No nonsense. Just stick to the good stuff. The 100% real stuff that make life, and chicken, great. With high quality farm raised chicken, we keep it real in everything we do. Keep it real. Keep it Tyson |
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
| { | |
| "success": true, | |
| "data": [ | |
| { | |
| "id": 6, | |
| "name": "Pureća prsa file", | |
| "photo": "http://img.thefoodin.com/s4jpyvwm2c.png", | |
| "unit": { | |
| "id": 1, | |
| "shortName": "Gra", |
NewerOlder