This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

oasis-tools2
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i oasis-tools2

Weekly Downloads

1

Version

1.0.6

License

none

Unpacked Size

34.9 kB

Total Files

11

Last publish

Collaborators

  • huynhkha8295