Skip to content
Chris Chen

Work Journal - RACV 2020 - 2021

Journal1 min read

I was contracting to RACV Home Emergency as a senior full-stack engineer for about a year.

Nontechnical

  • Finally I met an awesome tech lead - Asheesh Karwal, who:
    • has no big ego, does not try to be the loudest or smartest voice in the room
    • thinks through tasks beforehand, assesses technical solutions and challenges
    • kicks off tasks with individual engineers, hashes out ideas and concerns
    • writes code review comments with respect, usually proposes alternative code snippet
    • is willing to work on the not so glorious tech debts in the background
    • walks through his code changes with fellow engineers

Technical

  • Technical decisions that caused high codebase maintenance overhead and steep learning curve for newcomers:

    • Dependency Injection in Javascript codebase, without a typing system
    • Hand-crafted GraphQL resolvers, without a convenient framework
  • How to write a comprehensive system architecture design document

  • Infra / DevOps

  • Node.js backend

    • use AWS SSM and Secrets Manager for deployment configuration and env vars ⭐️
    • modularise and isolate data model CRUD operation around the domain
    • npm ci
      1# yarn equivalent
      2yarn install --frozen-lockfile
    • eslint-no-return-await
    • sanitize-html ⭐️
    • lodash.template - lightweight than handlebars ⭐️
    • http://npm.broofa.com/ - see npm dependencies graph
    • optional chaining - available in node.js
    • umzug - framework-agnostic SQL-like DB migration tool for Node ⭐️
    • use key-value pairs to replace large switch-case-return ⭐️
    • knex.js - lightweight than TypeORM, suitable for Lambda function
  • SQL

    1INSERT IGNORE INTO ...
    2
    3INSERT INTO ... ON DUPLICATE KEY
    4
    5START TRANSACTIONS ... COMMIT
    6
    7DELETE/UPDATE ... WHERE ... LIMIT 1 ⭐️
  • React/React Native frontend

    1const TimeContext = createContext({
    2 now: new Date(),
    3 updateTimeContext: () => {},
    4});
    5
    6const TimeProvider = ({ children }) => {
    7 const FORTY_SECONDS = 40000;
    8 const [now, setNow] = useState(new Date());
    9
    10 const updateTimeContext = () => setNow(new Date());
    11 useInterval(updateTimeContext, FORTY_SECONDS);
    12
    13 return (
    14 <TimeContext.Provider value={{ now, updateTimeContext }}>
    15 {children}
    16 </TimeContext.Provider>
    17 );
    18};
    19
    20export default TimeProvider;
    21export { TimeContext };
  • GraphQL

  • serverless

    • Authenticate API Gateway with Cognito User Pool, using Amplify libs on frontend
    • serverless-jetpack - speed up serverless framework deployment
    • fine-tune deployment package, example:
    1package:
    2 exclude:
    3 - '*'
    4 - '*/**'
    5 - '!node_modules/**'
    6 include:
    7 - package.json
    8 - 'src/**'
    9 - '!src/**/__tests__'
    10 - '!src/**/__mocks__'
    • locally invoke Lambda function to perform tasks like RDS migrations, ad-hoc data reporting ⭐️
    • npm chrome-aws-lambda - so we could render React component as PDF ⭐️