Socket
Book a DemoInstallSign in
Socket

oasis-tools2

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oasis-tools2

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 ```js import { createDocker } from 'oasis-tools' import path from 'path'

latest
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 25 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts