Skip to content

visualjeff/donutShop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DonutShop (exercises @xstate/store)

Usage:

  1. npm i
  2. npm run buld
  3. npm run start

SETUP a new TSUP-NODE project:

  1. mkdir donutStore && cd donutStore && npm init -y

  2. npm i tsup typescript @xstate/store

  3. mkdir src && touch src/index.tsx

    Pasted in code into src/index.tsx

  4. Update package.json added the follow:

    "type": "module"

    "scripts": {
        "build": "tsup-node src/index.tsx --format esm --dts",
        "start": "node dist/index.js",
        "tsc": "tsc --noEmit"
      },
  1. npm run tsc -- --init
  2. npm run build
  3. npm run start

Add PINO Log Aggregator to project:

  1. npm i pino pino-pretty
  2. Setup a src/logger.ts file:
    import pino from 'pino';

    // Configure Pino logger with info level and pretty printing
    const logger = pino({
      level: 'info',
      transport: {
        target: 'pino-pretty',
        options: {
          colorize: true,
          translateTime: 'SYS:standard',
          ignore: 'pid,hostname',
        },
      },
    });

    export default logger;

NOTE: Each logging method has the following signature: ([mergingObject], [message], [...interpolationValues])

The message string may contain a printf style string with support for the following placeholders:

%s – string placeholder
%d – digit placeholder
%O, %o and %j – object placeholder

Example:

logger.info('%o hello %s', {worldly: 1}, 'world')

// {"level":30,"time":1531257826880,"msg":"{"worldly":1} hello world","pid":55956,"hostname":"x"}

About

@xstate/store testing in nodejs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published