The tool for OASIS services
- NodeJS >= 14 (Recommend Node 16)
- yarn@1.19.0 (Not using npm due to the workspaces feature)
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))
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))
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 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