1.0.6 • Published 1 year ago

oasis-tools2 v1.0.6

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

oasis-tools

The tool for OASIS services

Prerequisites

  • NodeJS >= 14 (Recommend Node 16)
  • yarn@1.19.0 (Not using npm due to the workspaces feature)

How to use?

Create docker file

  import { createDocker } from 'oasis-tools'
  import path from 'path'

  /**
   * The directory where the functions are located.
   */
  const functionsDir: string = path.resolve('.', '..', 'functions')
  /**
   * Root directory where the Dockerfile will locate
   */
  const rootDir: string = path.resolve('.', '..', '..')

  createDocker({ functionsDir, rootDir })
    .then(() => console.log('Dockerfile created'))
    .catch((e) => console.error(e))

Create index.ts files for services

  import { createHandler } from 'oasis-tools'
  import path from 'path'

  /**
   * The name of the service should be excluded from the generated actions.
   */
  const excludes: string[] = ['auth', 'sendEmail']
  /**
   * The directory where the "functions" are located.
   */
  const functionsDir: string = path.resolve(__dirname, '..', 'functions')

  createHandler({ excludes, functionsDir })
    .then(() => console.log('Done'))
    .catch((e) => console.error(e))

Create actions for moleculer service

  import { createMoleculerService } from 'oasis-tools'
  import path from 'path'

  /**
   * The name of the service should be excluded from the generated actions.
   */
  const excludes = ['auth']
  /**
   * The directory where the "packages" are located.
   */
  const packagesDir = path.resolve(__dirname, '..')
  /**
   * The directory where the "functions" are located.
   */
  const functionsDir = path.join(packagesDir, 'functions')

  createMoleculerService({ excludes, functionsDir, packagesDir })
    .then(() => console.log('>> Done!'))
    .catch((err) => console.error(err))

Create a user or get token from existing user

  • Create a file create-user.ts
  import { createUser } from 'oasis-tools'

  createUser()
  • Define a script in the packages.json like this:
  "script": {
    ...,
    "create:user": "npx ts-node --transpile-only --prefer-ts-exts create-user.ts"
  }
  • Script to execute:
  yarn create:user --email your@mail.com --password test123456 --clientId xyz --poolId ap-southeast-1_AABBCC --region ap-southeast-1
1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago