Change build setup of JS clients, reintroduce beta publishing after losing it due to unmerged code (#238)

This commit is contained in:
Janos Dobronszki
2021-10-22 09:49:47 +01:00
committed by GitHub
parent 7cc2a86d0f
commit 293d5ecdde
140 changed files with 13946 additions and 643 deletions

View File

@@ -60,8 +60,10 @@ jobs:
go run cmd/publisher/main.go . go run cmd/publisher/main.go .
env: env:
MICRO_ADMIN_TOKEN: ${{ secrets.MICRO_ADMIN_TOKEN }} MICRO_ADMIN_TOKEN: ${{ secrets.MICRO_ADMIN_TOKEN }}
- name: Generate package - name: Generate package
working-directory: services working-directory: services
if: github.ref == 'refs/heads/master'
env: env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: | run: |
@@ -70,6 +72,19 @@ jobs:
go install; go install;
cd ../..; cd ../..;
clients . clients .
- name: Generate beta package
working-directory: services
if: github.ref == 'refs/heads/beta'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
IS_BETA: yup
run: |
pwd
cd cmd/clients;
go install;
cd ../..;
clients .
- uses: EndBug/add-and-commit@v7 - uses: EndBug/add-and-commit@v7
with: with:
@@ -84,3 +99,13 @@ jobs:
npm install npm install
npm run build npm run build
npm publish --access public npm publish --access public
- name: npm install beta
working-directory: services
if: github.ref == 'refs/heads/beta'
run: |
git status
cd clients/ts;
npm install
npm run build
npm publish --access public --tag beta

53
clients/ts/.gitignore vendored
View File

@@ -1 +1,54 @@
node_modules
dist dist
es
lib
types
tmp
index.js
index.d.ts
esmesm
index.js
index.d.ts
address
answer
cache
cmd
crypto
currency
db
email
emoji
evchargers
file
forex
function
geocoding
gifs
helloworld
holidays
id
image
ip
location
notes
otp
pkg
postcode
prayer
qr
quran
routing
rss
sentiment
sms
stock
stream
sunnah
test
thumbnail
time
twitter
url
user
vehicle
weather

91
clients/ts/build.js Normal file
View File

@@ -0,0 +1,91 @@
const chalk = require('chalk');
const path = require('path');
const fs = require('fs');
const rimraf = require('rimraf');
const { ncp } = require('ncp');
function getTmpEsmDirectories() {
return fs
.readdirSync('./tmp/esm')
.filter(file => fs.statSync(`./tmp/esm/${file}`).isDirectory());
}
function log(text) {
console.log(`${chalk.cyan('M3O JS:')} ${text}`);
}
function writeModulePackageJsonFile(location) {
fs.writeFileSync(
`${location}/package.json`,
`{"module": "./esm/index.js"}`,
'utf8'
);
}
function deleteDirectory(directory) {
return new Promise(resolve => {
rimraf(directory, err => {
resolve();
});
});
}
function copyAllTmpFolders() {
return new Promise((resolve, reject) => {
// Now copy to root level
ncp(path.join(__dirname, 'tmp'), __dirname, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
function moveToLocalEsmFolders() {
return new Promise((resolve, reject) => {
const esmDirs = getTmpEsmDirectories();
// Move the files around in tmp...
esmDirs.forEach(dir => {
const currentPath = path.join(__dirname, 'tmp/esm', dir);
fs.readdirSync(currentPath).forEach(async file => {
const currentFilePath = path.join(currentPath, file);
const newFilePath = path.join(__dirname, 'tmp', dir, 'esm', file);
const esmFolderLocation = path.join(__dirname, 'tmp', dir, 'esm');
try {
if (!fs.existsSync(esmFolderLocation)) {
fs.mkdirSync(esmFolderLocation);
}
fs.renameSync(currentFilePath, newFilePath);
writeModulePackageJsonFile(`./tmp/${dir}`);
await deleteDirectory(`./tmp/esm/${dir}`);
} catch (err) {
reject(err);
}
});
});
log('Moved local esm folders');
resolve();
});
}
async function build() {
log('Moving to correct folders');
try {
await moveToLocalEsmFolders();
await copyAllTmpFolders();
writeModulePackageJsonFile('./tmp/esm');
await deleteDirectory('./tmp');
} catch (e) {
console.log(e);
}
}
build();

File diff suppressed because it is too large Load Diff

View File

@@ -1,70 +1,78 @@
{ {
"author": "", "author": "",
"dependencies": { "dependencies": {
"@m3o/m3o-node": "^0.0.24" "@m3o/m3o-node": "^0.0.24",
"@types/estree": "^0.0.47",
"chalk": "^2.4.2",
"move-file": "^3.0.0",
"ncp": "^2.0.0",
"rimraf": "^3.0.2"
}, },
"description": "",
"devDependencies": { "devDependencies": {
"prettier": "^2.4.1",
"typescript": "^3.5.1" "typescript": "^3.5.1"
}, },
"exports": { "files": [
"./address": "./dist/address/index.js", "esm",
"./answer": "./dist/answer/index.js", "index.js",
"./cache": "./dist/cache/index.js", "index.d.ts",
"./cmd": "./dist/cmd/index.js", "address",
"./crypto": "./dist/crypto/index.js", "answer",
"./currency": "./dist/currency/index.js", "cache",
"./db": "./dist/db/index.js", "cmd",
"./email": "./dist/email/index.js", "crypto",
"./emoji": "./dist/emoji/index.js", "currency",
"./evchargers": "./dist/evchargers/index.js", "db",
"./file": "./dist/file/index.js", "email",
"./forex": "./dist/forex/index.js", "emoji",
"./function": "./dist/function/index.js", "evchargers",
"./geocoding": "./dist/geocoding/index.js", "file",
"./gifs": "./dist/gifs/index.js", "forex",
"./helloworld": "./dist/helloworld/index.js", "function",
"./holidays": "./dist/holidays/index.js", "geocoding",
"./id": "./dist/id/index.js", "gifs",
"./image": "./dist/image/index.js", "helloworld",
"./ip": "./dist/ip/index.js", "holidays",
"./location": "./dist/location/index.js", "id",
"./notes": "./dist/notes/index.js", "image",
"./otp": "./dist/otp/index.js", "ip",
"./pkg": "./dist/pkg/index.js", "location",
"./postcode": "./dist/postcode/index.js", "notes",
"./prayer": "./dist/prayer/index.js", "otp",
"./qr": "./dist/qr/index.js", "pkg",
"./quran": "./dist/quran/index.js", "postcode",
"./routing": "./dist/routing/index.js", "prayer",
"./rss": "./dist/rss/index.js", "qr",
"./sentiment": "./dist/sentiment/index.js", "quran",
"./sms": "./dist/sms/index.js", "routing",
"./stock": "./dist/stock/index.js", "rss",
"./stream": "./dist/stream/index.js", "sentiment",
"./sunnah": "./dist/sunnah/index.js", "sms",
"./test": "./dist/test/index.js", "stock",
"./thumbnail": "./dist/thumbnail/index.js", "stream",
"./time": "./dist/time/index.js", "sunnah",
"./twitter": "./dist/twitter/index.js", "test",
"./url": "./dist/url/index.js", "thumbnail",
"./user": "./dist/user/index.js", "time",
"./vehicle": "./dist/vehicle/index.js", "twitter",
"./weather": "./dist/weather/index.js" "url",
}, "user",
"vehicle",
"weather"
],
"license": "ISC", "license": "ISC",
"main": "dist", "main": "index.js",
"module": "esm/index.js",
"name": "m3o", "name": "m3o",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/micro/services" "url": "https://github.com/micro/services"
}, },
"scripts": { "scripts": {
"build": "tsc", "build": "npm run clean \u0026\u0026 tsc \u0026\u0026 tsc --p tsconfig.es.json \u0026\u0026 node build.js",
"prepare": "npm run build", "clean": "rimraf ./tmp",
"test": "echo \"Error: no test specified\" \u0026\u0026 exit 1" "prepare": "npm run build"
}, },
"type": "module", "types": "index.d.ts",
"types": "dist/index.d.ts", "version": "1.0.556-beta3"
"version": "1.0.555"
} }

View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "ES2015",
"target": "ES6",
"declaration": true,
"lib": ["es2015", "dom"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "./tmp/esm",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true
},
"include": ["src/index.ts", "src/**/*"],
"exclude": ["./dist", "./node_modules"]
}

View File

@@ -1,16 +1,16 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "es6", "module": "CommonJS",
"target": "es5", "target": "es5",
"declaration": true, "declaration": true,
"lib": ["es2015", "dom"], "lib": ["es2015", "dom"],
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"outDir": "./dist", "outDir": "./tmp",
"strict": true, "strict": true,
"moduleResolution": "node", "moduleResolution": "node",
"esModuleInterop": true "esModuleInterop": true
}, },
"include": ["index.ts", "./*"], "include": ["src/index.ts", "src/**/*"],
"exclude": ["src/**/*.spec.*", "./dist", "./node_modules"] "exclude": ["./dist", "./node_modules"]
} }

View File

@@ -6,9 +6,36 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/Masterminds/semver/v3"
"github.com/getkin/kin-openapi/openapi3" "github.com/getkin/kin-openapi/openapi3"
) )
func TestSemver(t *testing.T) {
v, _ := semver.NewVersion("0.0.0-beta1")
if incBeta(*v).String() != "0.0.0-beta2" {
t.Fatal(v)
}
v1, _ := semver.NewVersion("0.0.1")
if !v1.GreaterThan(v) {
t.Fatal("no good")
}
v2, _ := semver.NewVersion("0.0.0")
if !v2.GreaterThan(v) {
t.Fatal("no good")
}
if v.String() != "0.0.0-beta1" {
t.Fatal("no good")
}
v3, _ := semver.NewVersion("0.0.0-beta2")
if !v3.GreaterThan(v) {
t.Fatal("no good")
}
}
type tspec struct { type tspec struct {
openapi string openapi string
tsresult string tsresult string

View File

@@ -13,6 +13,7 @@ import (
"path/filepath" "path/filepath"
"regexp" "regexp"
"sort" "sort"
"strconv"
"strings" "strings"
"text/template" "text/template"
@@ -110,15 +111,14 @@ func main() {
}, },
} }
services := []service{} services := []service{}
tsExportsMap := map[string]string{} tsFileList := []string{"esm", "index.js", "index.d.ts"}
for _, f := range files { for _, f := range files {
if strings.Contains(f.Name(), "clients") || strings.Contains(f.Name(), "examples") { if strings.Contains(f.Name(), "clients") || strings.Contains(f.Name(), "examples") {
continue continue
} }
if f.IsDir() && !strings.HasPrefix(f.Name(), ".") { if f.IsDir() && !strings.HasPrefix(f.Name(), ".") {
serviceName := f.Name() serviceName := f.Name()
// see https://stackoverflow.com/questions/44345257/import-from-subfolder-of-npm-package tsFileList = append(tsFileList, serviceName)
tsExportsMap["./"+serviceName] = "./dist/" + serviceName + "/index.js"
serviceDir := filepath.Join(workDir, f.Name()) serviceDir := filepath.Join(workDir, f.Name())
cmd := exec.Command("make", "api") cmd := exec.Command("make", "api")
cmd.Dir = serviceDir cmd.Dir = serviceDir
@@ -187,12 +187,12 @@ func main() {
os.Exit(1) os.Exit(1)
} }
err = os.MkdirAll(filepath.Join(tsPath, serviceName), 0777) err = os.MkdirAll(filepath.Join(tsPath, "src", serviceName), 0777)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)
} }
f, err := os.OpenFile(filepath.Join(tsPath, serviceName, "index.ts"), os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0744) f, err := os.OpenFile(filepath.Join(tsPath, "src", serviceName, "index.ts"), os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0744)
if err != nil { if err != nil {
fmt.Println("Failed to open schema file", err) fmt.Println("Failed to open schema file", err)
os.Exit(1) os.Exit(1)
@@ -204,7 +204,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
cmd = exec.Command("prettier", "-w", "index.ts") cmd = exec.Command("prettier", "-w", "index.ts")
cmd.Dir = filepath.Join(tsPath, serviceName) cmd.Dir = filepath.Join(tsPath, "src", serviceName)
outp, err = cmd.CombinedOutput() outp, err = cmd.CombinedOutput()
if err != nil { if err != nil {
fmt.Println(fmt.Sprintf("Problem formatting '%v' client: %v %s", serviceName, string(outp), err.Error())) fmt.Println(fmt.Sprintf("Problem formatting '%v' client: %v %s", serviceName, string(outp), err.Error()))
@@ -449,7 +449,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
tsFiles := filepath.Join(workDir, "cmd", "clients", "ts") tsFiles := filepath.Join(workDir, "cmd", "clients", "ts")
cmd = exec.Command("cp", filepath.Join(tsFiles, "package.json"), filepath.Join(tsFiles, ".gitignore"), filepath.Join(tsFiles, "package-lock.json"), filepath.Join(tsFiles, "tsconfig.json"), filepath.Join(workDir, "clients", "ts")) cmd = exec.Command("cp", filepath.Join(tsFiles, "package.json"), filepath.Join(tsFiles, ".gitignore"), filepath.Join(tsFiles, "package-lock.json"), filepath.Join(tsFiles, "package-lock.json"), filepath.Join(tsFiles, "build.js"), filepath.Join(tsFiles, "tsconfig.es.json"), filepath.Join(tsFiles, "package-lock.json"), filepath.Join(tsFiles, "tsconfig.json"), filepath.Join(workDir, "clients", "ts"))
cmd.Dir = filepath.Join(tsPath) cmd.Dir = filepath.Join(tsPath)
outp, err = cmd.CombinedOutput() outp, err = cmd.CombinedOutput()
if err != nil { if err != nil {
@@ -526,6 +526,14 @@ func main() {
type npmVers struct { type npmVers struct {
Versions []string `json:"versions"` Versions []string `json:"versions"`
} }
beta := os.Getenv("IS_BETA") != ""
if beta {
fmt.Println("creating beta version")
} else {
fmt.Println("creating live version")
}
npmOutput := &npmVers{} npmOutput := &npmVers{}
var latest *semver.Version var latest *semver.Version
if len(outp) > 0 { if len(outp) > 0 {
@@ -535,6 +543,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
} }
fmt.Println("npm output version: ", npmOutput.Versions)
for _, version := range npmOutput.Versions { for _, version := range npmOutput.Versions {
v, err := semver.NewVersion(version) v, err := semver.NewVersion(version)
@@ -548,11 +557,37 @@ func main() {
if v.GreaterThan(latest) { if v.GreaterThan(latest) {
latest = v latest = v
} }
} }
if latest == nil { if latest == nil {
latest, _ = semver.NewVersion("0.0.0") fmt.Println("found no semver version")
os.Exit(1)
}
var newV semver.Version
if beta {
// bump a beta version
if strings.Contains(latest.String(), "beta") {
newV = incBeta(*latest)
} else {
// make beta out of latest non beta version
v, _ := semver.NewVersion(latest.IncPatch().String() + "-beta1")
newV = *v
}
} else {
newV = latest.IncPatch()
}
// add file list to gitignore
f, err = os.OpenFile(filepath.Join(tsPath, ".gitignore"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0744)
for _, sname := range tsFileList {
_, err := f.Write([]byte(sname + "\n"))
if err != nil {
fmt.Println("failed to append service to gitignore", err)
os.Exit(1)
}
} }
newV := latest.IncPatch()
// bump package to latest version // bump package to latest version
fmt.Println("Bumping to ", newV.String()) fmt.Println("Bumping to ", newV.String())
@@ -576,7 +611,7 @@ func main() {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)
} }
m["exports"] = tsExportsMap m["files"] = tsFileList
pakJS, err := json.MarshalIndent(m, "", " ") pakJS, err := json.MarshalIndent(m, "", " ")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@@ -594,6 +629,24 @@ func main() {
} }
} }
func incBeta(ver semver.Version) semver.Version {
s := ver.String()
parts := strings.Split(s, "beta")
if len(parts) < 2 {
panic("not a beta version " + s)
}
i, err := strconv.ParseInt(parts[1], 10, 64)
if err != nil {
panic(err)
}
i++
v, err := semver.NewVersion(parts[0] + "beta" + fmt.Sprintf("%v", i))
if err != nil {
panic(err)
}
return *v
}
func schemaToType(language, serviceName, typeName string, schemas map[string]*openapi3.SchemaRef) string { func schemaToType(language, serviceName, typeName string, schemas map[string]*openapi3.SchemaRef) string {
var recurse func(props map[string]*openapi3.SchemaRef, level int) string var recurse func(props map[string]*openapi3.SchemaRef, level int) string

View File

@@ -1 +1,9 @@
node_modules
dist dist
es
lib
types
tmp
index.js
index.d.ts
esm

91
cmd/clients/ts/build.js Normal file
View File

@@ -0,0 +1,91 @@
const chalk = require('chalk');
const path = require('path');
const fs = require('fs');
const rimraf = require('rimraf');
const { ncp } = require('ncp');
function getTmpEsmDirectories() {
return fs
.readdirSync('./tmp/esm')
.filter(file => fs.statSync(`./tmp/esm/${file}`).isDirectory());
}
function log(text) {
console.log(`${chalk.cyan('M3O JS:')} ${text}`);
}
function writeModulePackageJsonFile(location) {
fs.writeFileSync(
`${location}/package.json`,
`{"module": "./esm/index.js"}`,
'utf8'
);
}
function deleteDirectory(directory) {
return new Promise(resolve => {
rimraf(directory, err => {
resolve();
});
});
}
function copyAllTmpFolders() {
return new Promise((resolve, reject) => {
// Now copy to root level
ncp(path.join(__dirname, 'tmp'), __dirname, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
function moveToLocalEsmFolders() {
return new Promise((resolve, reject) => {
const esmDirs = getTmpEsmDirectories();
// Move the files around in tmp...
esmDirs.forEach(dir => {
const currentPath = path.join(__dirname, 'tmp/esm', dir);
fs.readdirSync(currentPath).forEach(async file => {
const currentFilePath = path.join(currentPath, file);
const newFilePath = path.join(__dirname, 'tmp', dir, 'esm', file);
const esmFolderLocation = path.join(__dirname, 'tmp', dir, 'esm');
try {
if (!fs.existsSync(esmFolderLocation)) {
fs.mkdirSync(esmFolderLocation);
}
fs.renameSync(currentFilePath, newFilePath);
writeModulePackageJsonFile(`./tmp/${dir}`);
await deleteDirectory(`./tmp/esm/${dir}`);
} catch (err) {
reject(err);
}
});
});
log('Moved local esm folders');
resolve();
});
}
async function build() {
log('Moving to correct folders');
try {
await moveToLocalEsmFolders();
await copyAllTmpFolders();
writeModulePackageJsonFile('./tmp/esm');
await deleteDirectory('./tmp');
} catch (e) {
console.log(e);
}
}
build();

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +1,31 @@
{ {
"name": "m3o", "name": "m3o",
"version": "1.0.1", "version": "1.0.1",
"description": "", "types": "index.d.ts",
"main": "dist", "main": "index.js",
"types": "dist/index.d.ts", "module": "esm/index.js",
"type": "module", "files": [],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/micro/services" "url": "https://github.com/micro/services"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"scripts": { "scripts": {
"build": "tsc", "clean": "rimraf ./tmp",
"prepare": "npm run build", "build": "npm run clean && tsc && tsc --p tsconfig.es.json && node build.js",
"test": "echo \"Error: no test specified\" && exit 1" "prepare": "npm run build"
}, },
"devDependencies": { "dependencies": {
"typescript": "^3.5.1" "@m3o/m3o-node": "^0.0.24",
}, "@types/estree": "^0.0.47",
"dependencies": { "chalk": "^2.4.2",
"@m3o/m3o-node": "^0.0.24" "move-file": "^3.0.0",
}, "ncp": "^2.0.0",
"exports": {} "rimraf": "^3.0.2"
},
"devDependencies": {
"prettier": "^2.4.1",
"typescript": "^3.5.1"
}
} }

View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "ES2015",
"target": "ES6",
"declaration": true,
"lib": ["es2015", "dom"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "./tmp/esm",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true
},
"include": ["src/index.ts", "src/**/*"],
"exclude": ["./dist", "./node_modules"]
}

View File

@@ -1,16 +1,16 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "es6", "module": "CommonJS",
"target": "es5", "target": "es5",
"declaration": true, "declaration": true,
"lib": ["es2015", "dom"], "lib": ["es2015", "dom"],
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"outDir": "./dist", "outDir": "./tmp",
"strict": true, "strict": true,
"moduleResolution": "node", "moduleResolution": "node",
"esModuleInterop": true "esModuleInterop": true
}, },
"include": ["index.ts", "./*"], "include": ["src/index.ts", "src/**/*"],
"exclude": ["src/**/*.spec.*", "./dist", "./node_modules"] "exclude": ["./dist", "./node_modules"]
} }

View File

@@ -35,12 +35,12 @@ export interface {{ title $typeName }}{{ "{" }}
{{end}} {{end}}
` `
const tsExampleTemplate = `{{ $service := .service }}import * as {{ $service.ImportName }} from 'm3o/{{ $service.Name }}'; const tsExampleTemplate = `{{ $service := .service }}const { {{ title $service.Name }}Service } = require('m3o/{{ $service.Name }}');
{{ if endpointComment .endpoint $service.Spec.Components.Schemas }}{{ endpointComment .endpoint $service.Spec.Components.Schemas }}{{ end }}async function {{ .funcName }}() { {{ if endpointComment .endpoint $service.Spec.Components.Schemas }}{{ endpointComment .endpoint $service.Spec.Components.Schemas }}{{ end }}async function {{ untitle .funcName }}() {
let {{ $service.Name }}Service = new {{ $service.ImportName }}.{{ title $service.Name }}Service(process.env.MICRO_API_TOKEN) let {{ $service.Name }}Service = new {{ title $service.Name }}Service(process.env.MICRO_API_TOKEN)
let rsp = await {{ $service.Name }}Service.{{ .endpoint }}({{ tsExampleRequest $service.Name .endpoint $service.Spec.Components.Schemas .example.Request }}) let rsp = await {{ $service.Name }}Service.{{ .endpoint }}({{ tsExampleRequest $service.Name .endpoint $service.Spec.Components.Schemas .example.Request }})
console.log(rsp) console.log(rsp)
} }
await {{ .funcName }}()` {{ untitle .funcName }}()`

View File

@@ -1,12 +1,12 @@
import * as address from "m3o/address"; const { AddressService } = require("m3o/address");
// Lookup a list of UK addresses by postcode // Lookup a list of UK addresses by postcode
async function LookupPostcode() { async function lookupPostcode() {
let addressService = new address.AddressService(process.env.MICRO_API_TOKEN); let addressService = new AddressService(process.env.MICRO_API_TOKEN);
let rsp = await addressService.lookupPostcode({ let rsp = await addressService.lookupPostcode({
postcode: "SW1A 2AA", postcode: "SW1A 2AA",
}); });
console.log(rsp); console.log(rsp);
} }
await LookupPostcode(); lookupPostcode();

View File

@@ -1,12 +1,12 @@
import * as answer from "m3o/answer"; const { AnswerService } = require("m3o/answer");
// Ask a question and receive an instant answer // Ask a question and receive an instant answer
async function AskAquestion() { async function askAquestion() {
let answerService = new answer.AnswerService(process.env.MICRO_API_TOKEN); let answerService = new AnswerService(process.env.MICRO_API_TOKEN);
let rsp = await answerService.question({ let rsp = await answerService.question({
query: "microsoft", query: "microsoft",
}); });
console.log(rsp); console.log(rsp);
} }
await AskAquestion(); askAquestion();

View File

@@ -1,8 +1,8 @@
import * as cache from "m3o/cache"; const { CacheService } = require("m3o/cache");
// Decrement a value (if it's a number) // Decrement a value (if it's a number)
async function DecrementAvalue() { async function decrementAvalue() {
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); let cacheService = new CacheService(process.env.MICRO_API_TOKEN);
let rsp = await cacheService.decrement({ let rsp = await cacheService.decrement({
key: "counter", key: "counter",
value: 2, value: 2,
@@ -10,4 +10,4 @@ async function DecrementAvalue() {
console.log(rsp); console.log(rsp);
} }
await DecrementAvalue(); decrementAvalue();

View File

@@ -1,12 +1,12 @@
import * as cache from "m3o/cache"; const { CacheService } = require("m3o/cache");
// Delete a value from the cache // Delete a value from the cache
async function DeleteAvalue() { async function deleteAvalue() {
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); let cacheService = new CacheService(process.env.MICRO_API_TOKEN);
let rsp = await cacheService.delete({ let rsp = await cacheService.delete({
key: "foo", key: "foo",
}); });
console.log(rsp); console.log(rsp);
} }
await DeleteAvalue(); deleteAvalue();

View File

@@ -1,12 +1,12 @@
import * as cache from "m3o/cache"; const { CacheService } = require("m3o/cache");
// Get an item from the cache by key // Get an item from the cache by key
async function GetAvalue() { async function getAvalue() {
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); let cacheService = new CacheService(process.env.MICRO_API_TOKEN);
let rsp = await cacheService.get({ let rsp = await cacheService.get({
key: "foo", key: "foo",
}); });
console.log(rsp); console.log(rsp);
} }
await GetAvalue(); getAvalue();

View File

@@ -1,8 +1,8 @@
import * as cache from "m3o/cache"; const { CacheService } = require("m3o/cache");
// Increment a value (if it's a number) // Increment a value (if it's a number)
async function IncrementAvalue() { async function incrementAvalue() {
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); let cacheService = new CacheService(process.env.MICRO_API_TOKEN);
let rsp = await cacheService.increment({ let rsp = await cacheService.increment({
key: "counter", key: "counter",
value: 2, value: 2,
@@ -10,4 +10,4 @@ async function IncrementAvalue() {
console.log(rsp); console.log(rsp);
} }
await IncrementAvalue(); incrementAvalue();

View File

@@ -1,8 +1,8 @@
import * as cache from "m3o/cache"; const { CacheService } = require("m3o/cache");
// Set an item in the cache. Overwrites any existing value already set. // Set an item in the cache. Overwrites any existing value already set.
async function SetAvalue() { async function setAvalue() {
let cacheService = new cache.CacheService(process.env.MICRO_API_TOKEN); let cacheService = new CacheService(process.env.MICRO_API_TOKEN);
let rsp = await cacheService.set({ let rsp = await cacheService.set({
key: "foo", key: "foo",
value: "bar", value: "bar",
@@ -10,4 +10,4 @@ async function SetAvalue() {
console.log(rsp); console.log(rsp);
} }
await SetAvalue(); setAvalue();

View File

@@ -1,12 +1,12 @@
import * as crypto from "m3o/crypto"; const { CryptoService } = require("m3o/crypto");
// Returns the history for the previous close // Returns the history for the previous close
async function GetPreviousClose() { async function getPreviousClose() {
let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN); let cryptoService = new CryptoService(process.env.MICRO_API_TOKEN);
let rsp = await cryptoService.history({ let rsp = await cryptoService.history({
symbol: "BTCUSD", symbol: "BTCUSD",
}); });
console.log(rsp); console.log(rsp);
} }
await GetPreviousClose(); getPreviousClose();

View File

@@ -1,12 +1,12 @@
import * as crypto from "m3o/crypto"; const { CryptoService } = require("m3o/crypto");
// Get news related to a currency // Get news related to a currency
async function GetCryptocurrencyNews() { async function getCryptocurrencyNews() {
let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN); let cryptoService = new CryptoService(process.env.MICRO_API_TOKEN);
let rsp = await cryptoService.news({ let rsp = await cryptoService.news({
symbol: "BTCUSD", symbol: "BTCUSD",
}); });
console.log(rsp); console.log(rsp);
} }
await GetCryptocurrencyNews(); getCryptocurrencyNews();

View File

@@ -1,12 +1,12 @@
import * as crypto from "m3o/crypto"; const { CryptoService } = require("m3o/crypto");
// Get the last price for a given crypto ticker // Get the last price for a given crypto ticker
async function GetCryptocurrencyPrice() { async function getCryptocurrencyPrice() {
let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN); let cryptoService = new CryptoService(process.env.MICRO_API_TOKEN);
let rsp = await cryptoService.price({ let rsp = await cryptoService.price({
symbol: "BTCUSD", symbol: "BTCUSD",
}); });
console.log(rsp); console.log(rsp);
} }
await GetCryptocurrencyPrice(); getCryptocurrencyPrice();

View File

@@ -1,12 +1,12 @@
import * as crypto from "m3o/crypto"; const { CryptoService } = require("m3o/crypto");
// Get the last quote for a given crypto ticker // Get the last quote for a given crypto ticker
async function GetAcryptocurrencyQuote() { async function getAcryptocurrencyQuote() {
let cryptoService = new crypto.CryptoService(process.env.MICRO_API_TOKEN); let cryptoService = new CryptoService(process.env.MICRO_API_TOKEN);
let rsp = await cryptoService.quote({ let rsp = await cryptoService.quote({
symbol: "BTCUSD", symbol: "BTCUSD",
}); });
console.log(rsp); console.log(rsp);
} }
await GetAcryptocurrencyQuote(); getAcryptocurrencyQuote();

View File

@@ -1,12 +1,10 @@
import * as currency from "m3o/currency"; const { CurrencyService } = require("m3o/currency");
// Codes returns the supported currency codes for the API // Codes returns the supported currency codes for the API
async function GetSupportedCodes() { async function getSupportedCodes() {
let currencyService = new currency.CurrencyService( let currencyService = new CurrencyService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await currencyService.codes({}); let rsp = await currencyService.codes({});
console.log(rsp); console.log(rsp);
} }
await GetSupportedCodes(); getSupportedCodes();

View File

@@ -1,10 +1,8 @@
import * as currency from "m3o/currency"; const { CurrencyService } = require("m3o/currency");
// Convert returns the currency conversion rate between two pairs e.g USD/GBP // Convert returns the currency conversion rate between two pairs e.g USD/GBP
async function Convert10usdToGbp() { async function convert10usdToGbp() {
let currencyService = new currency.CurrencyService( let currencyService = new CurrencyService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await currencyService.convert({ let rsp = await currencyService.convert({
amount: 10, amount: 10,
from: "USD", from: "USD",
@@ -13,4 +11,4 @@ async function Convert10usdToGbp() {
console.log(rsp); console.log(rsp);
} }
await Convert10usdToGbp(); convert10usdToGbp();

View File

@@ -1,10 +1,8 @@
import * as currency from "m3o/currency"; const { CurrencyService } = require("m3o/currency");
// Convert returns the currency conversion rate between two pairs e.g USD/GBP // Convert returns the currency conversion rate between two pairs e.g USD/GBP
async function ConvertUsdToGbp() { async function convertUsdToGbp() {
let currencyService = new currency.CurrencyService( let currencyService = new CurrencyService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await currencyService.convert({ let rsp = await currencyService.convert({
from: "USD", from: "USD",
to: "GBP", to: "GBP",
@@ -12,4 +10,4 @@ async function ConvertUsdToGbp() {
console.log(rsp); console.log(rsp);
} }
await ConvertUsdToGbp(); convertUsdToGbp();

View File

@@ -1,10 +1,8 @@
import * as currency from "m3o/currency"; const { CurrencyService } = require("m3o/currency");
// Returns the historic rates for a currency on a given date // Returns the historic rates for a currency on a given date
async function HistoricRatesForAcurrency() { async function historicRatesForAcurrency() {
let currencyService = new currency.CurrencyService( let currencyService = new CurrencyService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await currencyService.history({ let rsp = await currencyService.history({
code: "USD", code: "USD",
date: "2021-05-30", date: "2021-05-30",
@@ -12,4 +10,4 @@ async function HistoricRatesForAcurrency() {
console.log(rsp); console.log(rsp);
} }
await HistoricRatesForAcurrency(); historicRatesForAcurrency();

View File

@@ -1,14 +1,12 @@
import * as currency from "m3o/currency"; const { CurrencyService } = require("m3o/currency");
// Rates returns the currency rates for a given code e.g USD // Rates returns the currency rates for a given code e.g USD
async function GetRatesForUsd() { async function getRatesForUsd() {
let currencyService = new currency.CurrencyService( let currencyService = new CurrencyService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await currencyService.rates({ let rsp = await currencyService.rates({
code: "USD", code: "USD",
}); });
console.log(rsp); console.log(rsp);
} }
await GetRatesForUsd(); getRatesForUsd();

View File

@@ -1,12 +1,12 @@
import * as db from "m3o/db"; const { DbService } = require("m3o/db");
// Count records in a table // Count records in a table
async function CountEntriesInAtable() { async function countEntriesInAtable() {
let dbService = new db.DbService(process.env.MICRO_API_TOKEN); let dbService = new DbService(process.env.MICRO_API_TOKEN);
let rsp = await dbService.count({ let rsp = await dbService.count({
table: "users", table: "users",
}); });
console.log(rsp); console.log(rsp);
} }
await CountEntriesInAtable(); countEntriesInAtable();

View File

@@ -1,8 +1,8 @@
import * as db from "m3o/db"; const { DbService } = require("m3o/db");
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically. // Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
async function CreateArecord() { async function createArecord() {
let dbService = new db.DbService(process.env.MICRO_API_TOKEN); let dbService = new DbService(process.env.MICRO_API_TOKEN);
let rsp = await dbService.create({ let rsp = await dbService.create({
record: { record: {
age: 42, age: 42,
@@ -15,4 +15,4 @@ async function CreateArecord() {
console.log(rsp); console.log(rsp);
} }
await CreateArecord(); createArecord();

View File

@@ -1,8 +1,8 @@
import * as db from "m3o/db"; const { DbService } = require("m3o/db");
// Delete a record in the database by id. // Delete a record in the database by id.
async function DeleteArecord() { async function deleteArecord() {
let dbService = new db.DbService(process.env.MICRO_API_TOKEN); let dbService = new DbService(process.env.MICRO_API_TOKEN);
let rsp = await dbService.delete({ let rsp = await dbService.delete({
id: "1", id: "1",
table: "users", table: "users",
@@ -10,4 +10,4 @@ async function DeleteArecord() {
console.log(rsp); console.log(rsp);
} }
await DeleteArecord(); deleteArecord();

View File

@@ -1,8 +1,8 @@
import * as db from "m3o/db"; const { DbService } = require("m3o/db");
// Read data from a table. Lookup can be by ID or via querying any field in the record. // Read data from a table. Lookup can be by ID or via querying any field in the record.
async function ReadRecords() { async function readRecords() {
let dbService = new db.DbService(process.env.MICRO_API_TOKEN); let dbService = new DbService(process.env.MICRO_API_TOKEN);
let rsp = await dbService.read({ let rsp = await dbService.read({
query: "age == 43", query: "age == 43",
table: "users", table: "users",
@@ -10,4 +10,4 @@ async function ReadRecords() {
console.log(rsp); console.log(rsp);
} }
await ReadRecords(); readRecords();

View File

@@ -1,12 +1,12 @@
import * as db from "m3o/db"; const { DbService } = require("m3o/db");
// Truncate the records in a table // Truncate the records in a table
async function TruncateTable() { async function truncateTable() {
let dbService = new db.DbService(process.env.MICRO_API_TOKEN); let dbService = new DbService(process.env.MICRO_API_TOKEN);
let rsp = await dbService.truncate({ let rsp = await dbService.truncate({
table: "users", table: "users",
}); });
console.log(rsp); console.log(rsp);
} }
await TruncateTable(); truncateTable();

View File

@@ -1,8 +1,8 @@
import * as db from "m3o/db"; const { DbService } = require("m3o/db");
// Update a record in the database. Include an "id" in the record to update. // Update a record in the database. Include an "id" in the record to update.
async function UpdateArecord() { async function updateArecord() {
let dbService = new db.DbService(process.env.MICRO_API_TOKEN); let dbService = new DbService(process.env.MICRO_API_TOKEN);
let rsp = await dbService.update({ let rsp = await dbService.update({
record: { record: {
age: 43, age: 43,
@@ -13,4 +13,4 @@ async function UpdateArecord() {
console.log(rsp); console.log(rsp);
} }
await UpdateArecord(); updateArecord();

View File

@@ -1,8 +1,8 @@
import * as email from "m3o/email"; const { EmailService } = require("m3o/email");
// Send an email by passing in from, to, subject, and a text or html body // Send an email by passing in from, to, subject, and a text or html body
async function SendEmail() { async function sendEmail() {
let emailService = new email.EmailService(process.env.MICRO_API_TOKEN); let emailService = new EmailService(process.env.MICRO_API_TOKEN);
let rsp = await emailService.send({ let rsp = await emailService.send({
from: "Awesome Dot Com", from: "Awesome Dot Com",
subject: "Email verification", subject: "Email verification",
@@ -12,4 +12,4 @@ async function SendEmail() {
console.log(rsp); console.log(rsp);
} }
await SendEmail(); sendEmail();

View File

@@ -1,12 +1,12 @@
import * as emoji from "m3o/emoji"; const { EmojiService } = require("m3o/emoji");
// Find an emoji by its alias e.g :beer: // Find an emoji by its alias e.g :beer:
async function FindEmoji() { async function findEmoji() {
let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN); let emojiService = new EmojiService(process.env.MICRO_API_TOKEN);
let rsp = await emojiService.find({ let rsp = await emojiService.find({
alias: ":beer:", alias: ":beer:",
}); });
console.log(rsp); console.log(rsp);
} }
await FindEmoji(); findEmoji();

View File

@@ -1,12 +1,12 @@
import * as emoji from "m3o/emoji"; const { EmojiService } = require("m3o/emoji");
// Get the flag for a country. Requires country code e.g GB for great britain // Get the flag for a country. Requires country code e.g GB for great britain
async function GetFlagByCountryCode() { async function getFlagByCountryCode() {
let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN); let emojiService = new EmojiService(process.env.MICRO_API_TOKEN);
let rsp = await emojiService.flag({ let rsp = await emojiService.flag({
alias: "GB", alias: "GB",
}); });
console.log(rsp); console.log(rsp);
} }
await GetFlagByCountryCode(); getFlagByCountryCode();

View File

@@ -1,13 +1,13 @@
import * as emoji from "m3o/emoji"; const { EmojiService } = require("m3o/emoji");
// Print text and renders the emojis with aliases e.g // Print text and renders the emojis with aliases e.g
// let's grab a :beer: becomes let's grab a 🍺 // let's grab a :beer: becomes let's grab a 🍺
async function PrintTextIncludingEmoji() { async function printTextIncludingEmoji() {
let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN); let emojiService = new EmojiService(process.env.MICRO_API_TOKEN);
let rsp = await emojiService.print({ let rsp = await emojiService.print({
text: "let's grab a :beer:", text: "let's grab a :beer:",
}); });
console.log(rsp); console.log(rsp);
} }
await PrintTextIncludingEmoji(); printTextIncludingEmoji();

View File

@@ -1,8 +1,8 @@
import * as emoji from "m3o/emoji"; const { EmojiService } = require("m3o/emoji");
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>' // Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
async function SendAtextContainingAnEmojiToAnyoneViaSms() { async function sendAtextContainingAnEmojiToAnyoneViaSms() {
let emojiService = new emoji.EmojiService(process.env.MICRO_API_TOKEN); let emojiService = new EmojiService(process.env.MICRO_API_TOKEN);
let rsp = await emojiService.send({ let rsp = await emojiService.send({
from: "Alice", from: "Alice",
message: "let's grab a :beer:", message: "let's grab a :beer:",
@@ -11,4 +11,4 @@ async function SendAtextContainingAnEmojiToAnyoneViaSms() {
console.log(rsp); console.log(rsp);
} }
await SendAtextContainingAnEmojiToAnyoneViaSms(); sendAtextContainingAnEmojiToAnyoneViaSms();

View File

@@ -1,12 +1,10 @@
import * as evchargers from "m3o/evchargers"; const { EvchargersService } = require("m3o/evchargers");
// Retrieve reference data as used by this API and in conjunction with the Search endpoint // Retrieve reference data as used by this API and in conjunction with the Search endpoint
async function GetReferenceData() { async function getReferenceData() {
let evchargersService = new evchargers.EvchargersService( let evchargersService = new EvchargersService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await evchargersService.referenceData({}); let rsp = await evchargersService.referenceData({});
console.log(rsp); console.log(rsp);
} }
await GetReferenceData(); getReferenceData();

View File

@@ -1,10 +1,8 @@
import * as evchargers from "m3o/evchargers"; const { EvchargersService } = require("m3o/evchargers");
// Search by giving a coordinate and a max distance, or bounding box and optional filters // Search by giving a coordinate and a max distance, or bounding box and optional filters
async function SearchByBoundingBox() { async function searchByBoundingBox() {
let evchargersService = new evchargers.EvchargersService( let evchargersService = new EvchargersService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await evchargersService.search({ let rsp = await evchargersService.search({
box: { box: {
bottom_left: { bottom_left: {
@@ -21,4 +19,4 @@ async function SearchByBoundingBox() {
console.log(rsp); console.log(rsp);
} }
await SearchByBoundingBox(); searchByBoundingBox();

View File

@@ -1,10 +1,8 @@
import * as evchargers from "m3o/evchargers"; const { EvchargersService } = require("m3o/evchargers");
// Search by giving a coordinate and a max distance, or bounding box and optional filters // Search by giving a coordinate and a max distance, or bounding box and optional filters
async function SearchByLocation() { async function searchByLocation() {
let evchargersService = new evchargers.EvchargersService( let evchargersService = new EvchargersService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await evchargersService.search({ let rsp = await evchargersService.search({
distance: 2000, distance: 2000,
location: { location: {
@@ -16,4 +14,4 @@ async function SearchByLocation() {
console.log(rsp); console.log(rsp);
} }
await SearchByLocation(); searchByLocation();

View File

@@ -1,10 +1,8 @@
import * as evchargers from "m3o/evchargers"; const { EvchargersService } = require("m3o/evchargers");
// Search by giving a coordinate and a max distance, or bounding box and optional filters // Search by giving a coordinate and a max distance, or bounding box and optional filters
async function SearchWithFiltersFastChargersOnly() { async function searchWithFiltersFastChargersOnly() {
let evchargersService = new evchargers.EvchargersService( let evchargersService = new EvchargersService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await evchargersService.search({ let rsp = await evchargersService.search({
distance: 2000, distance: 2000,
levels: ["3"], levels: ["3"],
@@ -17,4 +15,4 @@ async function SearchWithFiltersFastChargersOnly() {
console.log(rsp); console.log(rsp);
} }
await SearchWithFiltersFastChargersOnly(); searchWithFiltersFastChargersOnly();

View File

@@ -1,8 +1,8 @@
import * as file from "m3o/file"; const { FileService } = require("m3o/file");
// Delete a file by project name/path // Delete a file by project name/path
async function DeleteFile() { async function deleteFile() {
let fileService = new file.FileService(process.env.MICRO_API_TOKEN); let fileService = new FileService(process.env.MICRO_API_TOKEN);
let rsp = await fileService.delete({ let rsp = await fileService.delete({
path: "/document/text-files/file.txt", path: "/document/text-files/file.txt",
project: "examples", project: "examples",
@@ -10,4 +10,4 @@ async function DeleteFile() {
console.log(rsp); console.log(rsp);
} }
await DeleteFile(); deleteFile();

View File

@@ -1,12 +1,12 @@
import * as file from "m3o/file"; const { FileService } = require("m3o/file");
// List files by their project and optionally a path. // List files by their project and optionally a path.
async function ListFiles() { async function listFiles() {
let fileService = new file.FileService(process.env.MICRO_API_TOKEN); let fileService = new FileService(process.env.MICRO_API_TOKEN);
let rsp = await fileService.list({ let rsp = await fileService.list({
project: "examples", project: "examples",
}); });
console.log(rsp); console.log(rsp);
} }
await ListFiles(); listFiles();

View File

@@ -1,8 +1,8 @@
import * as file from "m3o/file"; const { FileService } = require("m3o/file");
// Read a file by path // Read a file by path
async function ReadFile() { async function readFile() {
let fileService = new file.FileService(process.env.MICRO_API_TOKEN); let fileService = new FileService(process.env.MICRO_API_TOKEN);
let rsp = await fileService.read({ let rsp = await fileService.read({
path: "/document/text-files/file.txt", path: "/document/text-files/file.txt",
project: "examples", project: "examples",
@@ -10,4 +10,4 @@ async function ReadFile() {
console.log(rsp); console.log(rsp);
} }
await ReadFile(); readFile();

View File

@@ -1,8 +1,8 @@
import * as file from "m3o/file"; const { FileService } = require("m3o/file");
// Save a file // Save a file
async function SaveFile() { async function saveFile() {
let fileService = new file.FileService(process.env.MICRO_API_TOKEN); let fileService = new FileService(process.env.MICRO_API_TOKEN);
let rsp = await fileService.save({ let rsp = await fileService.save({
file: { file: {
content: "file content example", content: "file content example",
@@ -13,4 +13,4 @@ async function SaveFile() {
console.log(rsp); console.log(rsp);
} }
await SaveFile(); saveFile();

View File

@@ -1,12 +1,12 @@
import * as forex from "m3o/forex"; const { ForexService } = require("m3o/forex");
// Returns the data for the previous close // Returns the data for the previous close
async function GetPreviousClose() { async function getPreviousClose() {
let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN); let forexService = new ForexService(process.env.MICRO_API_TOKEN);
let rsp = await forexService.history({ let rsp = await forexService.history({
symbol: "GBPUSD", symbol: "GBPUSD",
}); });
console.log(rsp); console.log(rsp);
} }
await GetPreviousClose(); getPreviousClose();

View File

@@ -1,12 +1,12 @@
import * as forex from "m3o/forex"; const { ForexService } = require("m3o/forex");
// Get the latest price for a given forex ticker // Get the latest price for a given forex ticker
async function GetAnFxPrice() { async function getAnFxPrice() {
let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN); let forexService = new ForexService(process.env.MICRO_API_TOKEN);
let rsp = await forexService.price({ let rsp = await forexService.price({
symbol: "GBPUSD", symbol: "GBPUSD",
}); });
console.log(rsp); console.log(rsp);
} }
await GetAnFxPrice(); getAnFxPrice();

View File

@@ -1,12 +1,12 @@
import * as forex from "m3o/forex"; const { ForexService } = require("m3o/forex");
// Get the latest quote for the forex // Get the latest quote for the forex
async function GetAfxQuote() { async function getAfxQuote() {
let forexService = new forex.ForexService(process.env.MICRO_API_TOKEN); let forexService = new ForexService(process.env.MICRO_API_TOKEN);
let rsp = await forexService.quote({ let rsp = await forexService.quote({
symbol: "GBPUSD", symbol: "GBPUSD",
}); });
console.log(rsp); console.log(rsp);
} }
await GetAfxQuote(); getAfxQuote();

View File

@@ -1,8 +1,8 @@
import * as fx from "m3o/function"; const { FunctionService } = require("m3o/function");
// Call a function by name // Call a function by name
async function CallAfunction() { async function callAfunction() {
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN); let functionService = new FunctionService(process.env.MICRO_API_TOKEN);
let rsp = await functionService.call({ let rsp = await functionService.call({
name: "my-first-func", name: "my-first-func",
request: {}, request: {},
@@ -10,4 +10,4 @@ async function CallAfunction() {
console.log(rsp); console.log(rsp);
} }
await CallAfunction(); callAfunction();

View File

@@ -1,8 +1,8 @@
import * as fx from "m3o/function"; const { FunctionService } = require("m3o/function");
// Delete a function by name // Delete a function by name
async function DeleteAfunction() { async function deleteAfunction() {
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN); let functionService = new FunctionService(process.env.MICRO_API_TOKEN);
let rsp = await functionService.delete({ let rsp = await functionService.delete({
name: "my-first-func", name: "my-first-func",
project: "tests", project: "tests",
@@ -10,4 +10,4 @@ async function DeleteAfunction() {
console.log(rsp); console.log(rsp);
} }
await DeleteAfunction(); deleteAfunction();

View File

@@ -1,8 +1,8 @@
import * as fx from "m3o/function"; const { FunctionService } = require("m3o/function");
// Deploy a group of functions // Deploy a group of functions
async function DeployAfunction() { async function deployAfunction() {
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN); let functionService = new FunctionService(process.env.MICRO_API_TOKEN);
let rsp = await functionService.deploy({ let rsp = await functionService.deploy({
entrypoint: "helloworld", entrypoint: "helloworld",
name: "my-first-func", name: "my-first-func",
@@ -13,4 +13,4 @@ async function DeployAfunction() {
console.log(rsp); console.log(rsp);
} }
await DeployAfunction(); deployAfunction();

View File

@@ -1,8 +1,8 @@
import * as fx from "m3o/function"; const { FunctionService } = require("m3o/function");
// //
async function DescribeFunctionStatus() { async function describeFunctionStatus() {
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN); let functionService = new FunctionService(process.env.MICRO_API_TOKEN);
let rsp = await functionService.describe({ let rsp = await functionService.describe({
name: "my-first-func", name: "my-first-func",
project: "tests", project: "tests",
@@ -10,4 +10,4 @@ async function DescribeFunctionStatus() {
console.log(rsp); console.log(rsp);
} }
await DescribeFunctionStatus(); describeFunctionStatus();

View File

@@ -1,10 +1,10 @@
import * as fx from "m3o/function"; const { FunctionService } = require("m3o/function");
// List all the deployed functions // List all the deployed functions
async function ListFunctions() { async function listFunctions() {
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN); let functionService = new FunctionService(process.env.MICRO_API_TOKEN);
let rsp = await functionService.list({}); let rsp = await functionService.list({});
console.log(rsp); console.log(rsp);
} }
await ListFunctions(); listFunctions();

View File

@@ -1,10 +1,8 @@
import * as geocoding from "m3o/geocoding"; const { GeocodingService } = require("m3o/geocoding");
// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results // Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
async function GeocodeAnAddress() { async function geocodeAnAddress() {
let geocodingService = new geocoding.GeocodingService( let geocodingService = new GeocodingService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await geocodingService.lookup({ let rsp = await geocodingService.lookup({
address: "10 russell st", address: "10 russell st",
city: "london", city: "london",
@@ -14,4 +12,4 @@ async function GeocodeAnAddress() {
console.log(rsp); console.log(rsp);
} }
await GeocodeAnAddress(); geocodeAnAddress();

View File

@@ -1,10 +1,8 @@
import * as geocoding from "m3o/geocoding"; const { GeocodingService } = require("m3o/geocoding");
// Reverse lookup an address from gps coordinates // Reverse lookup an address from gps coordinates
async function ReverseGeocodeLocation() { async function reverseGeocodeLocation() {
let geocodingService = new geocoding.GeocodingService( let geocodingService = new GeocodingService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await geocodingService.reverse({ let rsp = await geocodingService.reverse({
latitude: 51.5123064, latitude: 51.5123064,
longitude: -0.1216235, longitude: -0.1216235,
@@ -12,4 +10,4 @@ async function ReverseGeocodeLocation() {
console.log(rsp); console.log(rsp);
} }
await ReverseGeocodeLocation(); reverseGeocodeLocation();

View File

@@ -1,14 +1,12 @@
import * as helloworld from "m3o/helloworld"; const { HelloworldService } = require("m3o/helloworld");
// Call returns a personalised "Hello $name" response // Call returns a personalised "Hello $name" response
async function CallTheHelloworldService() { async function callTheHelloworldService() {
let helloworldService = new helloworld.HelloworldService( let helloworldService = new HelloworldService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await helloworldService.call({ let rsp = await helloworldService.call({
name: "John", name: "John",
}); });
console.log(rsp); console.log(rsp);
} }
await CallTheHelloworldService(); callTheHelloworldService();

View File

@@ -1,14 +1,12 @@
import * as helloworld from "m3o/helloworld"; const { HelloworldService } = require("m3o/helloworld");
// Stream returns a stream of "Hello $name" responses // Stream returns a stream of "Hello $name" responses
async function StreamsAreCurrentlyTemporarilyNotSupportedInClients() { async function streamsAreCurrentlyTemporarilyNotSupportedInClients() {
let helloworldService = new helloworld.HelloworldService( let helloworldService = new HelloworldService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await helloworldService.stream({ let rsp = await helloworldService.stream({
name: "not supported", name: "not supported",
}); });
console.log(rsp); console.log(rsp);
} }
await StreamsAreCurrentlyTemporarilyNotSupportedInClients(); streamsAreCurrentlyTemporarilyNotSupportedInClients();

View File

@@ -1,12 +1,10 @@
import * as holidays from "m3o/holidays"; const { HolidaysService } = require("m3o/holidays");
// Get the list of countries that are supported by this API // Get the list of countries that are supported by this API
async function ListCountries() { async function listCountries() {
let holidaysService = new holidays.HolidaysService( let holidaysService = new HolidaysService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await holidaysService.countries({}); let rsp = await holidaysService.countries({});
console.log(rsp); console.log(rsp);
} }
await ListCountries(); listCountries();

View File

@@ -1,10 +1,8 @@
import * as holidays from "m3o/holidays"; const { HolidaysService } = require("m3o/holidays");
// List the holiday dates for a given country and year // List the holiday dates for a given country and year
async function GetHolidays() { async function getHolidays() {
let holidaysService = new holidays.HolidaysService( let holidaysService = new HolidaysService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await holidaysService.list({ let rsp = await holidaysService.list({
country_code: "GB", country_code: "GB",
year: 2022, year: 2022,
@@ -12,4 +10,4 @@ async function GetHolidays() {
console.log(rsp); console.log(rsp);
} }
await GetHolidays(); getHolidays();

View File

@@ -1,12 +1,12 @@
import * as id from "m3o/id"; const { IdService } = require("m3o/id");
// Generate a unique ID. Defaults to uuid. // Generate a unique ID. Defaults to uuid.
async function GenerateAbigflakeId() { async function generateAbigflakeId() {
let idService = new id.IdService(process.env.MICRO_API_TOKEN); let idService = new IdService(process.env.MICRO_API_TOKEN);
let rsp = await idService.generate({ let rsp = await idService.generate({
type: "bigflake", type: "bigflake",
}); });
console.log(rsp); console.log(rsp);
} }
await GenerateAbigflakeId(); generateAbigflakeId();

View File

@@ -1,12 +1,12 @@
import * as id from "m3o/id"; const { IdService } = require("m3o/id");
// Generate a unique ID. Defaults to uuid. // Generate a unique ID. Defaults to uuid.
async function GenerateAshortId() { async function generateAshortId() {
let idService = new id.IdService(process.env.MICRO_API_TOKEN); let idService = new IdService(process.env.MICRO_API_TOKEN);
let rsp = await idService.generate({ let rsp = await idService.generate({
type: "shortid", type: "shortid",
}); });
console.log(rsp); console.log(rsp);
} }
await GenerateAshortId(); generateAshortId();

View File

@@ -1,12 +1,12 @@
import * as id from "m3o/id"; const { IdService } = require("m3o/id");
// Generate a unique ID. Defaults to uuid. // Generate a unique ID. Defaults to uuid.
async function GenerateAsnowflakeId() { async function generateAsnowflakeId() {
let idService = new id.IdService(process.env.MICRO_API_TOKEN); let idService = new IdService(process.env.MICRO_API_TOKEN);
let rsp = await idService.generate({ let rsp = await idService.generate({
type: "snowflake", type: "snowflake",
}); });
console.log(rsp); console.log(rsp);
} }
await GenerateAsnowflakeId(); generateAsnowflakeId();

View File

@@ -1,12 +1,12 @@
import * as id from "m3o/id"; const { IdService } = require("m3o/id");
// Generate a unique ID. Defaults to uuid. // Generate a unique ID. Defaults to uuid.
async function GenerateAuniqueId() { async function generateAuniqueId() {
let idService = new id.IdService(process.env.MICRO_API_TOKEN); let idService = new IdService(process.env.MICRO_API_TOKEN);
let rsp = await idService.generate({ let rsp = await idService.generate({
type: "uuid", type: "uuid",
}); });
console.log(rsp); console.log(rsp);
} }
await GenerateAuniqueId(); generateAuniqueId();

View File

@@ -1,10 +1,10 @@
import * as id from "m3o/id"; const { IdService } = require("m3o/id");
// List the types of IDs available. No query params needed. // List the types of IDs available. No query params needed.
async function ListTheTypesOfIdsAvailable() { async function listTheTypesOfIdsAvailable() {
let idService = new id.IdService(process.env.MICRO_API_TOKEN); let idService = new IdService(process.env.MICRO_API_TOKEN);
let rsp = await idService.types({}); let rsp = await idService.types({});
console.log(rsp); console.log(rsp);
} }
await ListTheTypesOfIdsAvailable(); listTheTypesOfIdsAvailable();

View File

@@ -1,9 +1,9 @@
import * as image from "m3o/image"; const { ImageService } = require("m3o/image");
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), // Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
// or by uploading the conversion result. // or by uploading the conversion result.
async function ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() { async function convertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); let imageService = new ImageService(process.env.MICRO_API_TOKEN);
let rsp = await imageService.convert({ let rsp = await imageService.convert({
name: "cat.jpeg", name: "cat.jpeg",
outputURL: true, outputURL: true,
@@ -12,4 +12,4 @@ async function ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
console.log(rsp); console.log(rsp);
} }
await ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn(); convertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn();

View File

@@ -1,10 +1,10 @@
import * as image from "m3o/image"; const { ImageService } = require("m3o/image");
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. // Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
async function Base64toBase64image() { async function base64toBase64image() {
let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); let imageService = new ImageService(process.env.MICRO_API_TOKEN);
let rsp = await imageService.resize({ let rsp = await imageService.resize({
base64: base64:
"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
@@ -14,4 +14,4 @@ async function Base64toBase64image() {
console.log(rsp); console.log(rsp);
} }
await Base64toBase64image(); base64toBase64image();

View File

@@ -1,10 +1,10 @@
import * as image from "m3o/image"; const { ImageService } = require("m3o/image");
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. // Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
async function Base64toBase64imageWithCropping() { async function base64toBase64imageWithCropping() {
let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); let imageService = new ImageService(process.env.MICRO_API_TOKEN);
let rsp = await imageService.resize({ let rsp = await imageService.resize({
base64: base64:
"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
@@ -18,4 +18,4 @@ async function Base64toBase64imageWithCropping() {
console.log(rsp); console.log(rsp);
} }
await Base64toBase64imageWithCropping(); base64toBase64imageWithCropping();

View File

@@ -1,10 +1,10 @@
import * as image from "m3o/image"; const { ImageService } = require("m3o/image");
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. // Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
async function Base64toHostedImage() { async function base64toHostedImage() {
let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); let imageService = new ImageService(process.env.MICRO_API_TOKEN);
let rsp = await imageService.resize({ let rsp = await imageService.resize({
base64: base64:
"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
@@ -16,4 +16,4 @@ async function Base64toHostedImage() {
console.log(rsp); console.log(rsp);
} }
await Base64toHostedImage(); base64toHostedImage();

View File

@@ -1,9 +1,9 @@
import * as image from "m3o/image"; const { ImageService } = require("m3o/image");
// Upload an image by either sending a base64 encoded image to this endpoint or a URL. // Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint. // To resize an image before uploading, see the Resize endpoint.
async function UploadAbase64imageToMicrosCdn() { async function uploadAbase64imageToMicrosCdn() {
let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); let imageService = new ImageService(process.env.MICRO_API_TOKEN);
let rsp = await imageService.upload({ let rsp = await imageService.upload({
base64: base64:
"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==", "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
@@ -13,4 +13,4 @@ async function UploadAbase64imageToMicrosCdn() {
console.log(rsp); console.log(rsp);
} }
await UploadAbase64imageToMicrosCdn(); uploadAbase64imageToMicrosCdn();

View File

@@ -1,9 +1,9 @@
import * as image from "m3o/image"; const { ImageService } = require("m3o/image");
// Upload an image by either sending a base64 encoded image to this endpoint or a URL. // Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint. // To resize an image before uploading, see the Resize endpoint.
async function UploadAnImageFromAurlToMicrosCdn() { async function uploadAnImageFromAurlToMicrosCdn() {
let imageService = new image.ImageService(process.env.MICRO_API_TOKEN); let imageService = new ImageService(process.env.MICRO_API_TOKEN);
let rsp = await imageService.upload({ let rsp = await imageService.upload({
name: "cat.jpeg", name: "cat.jpeg",
url: "somewebsite.com/cat.png", url: "somewebsite.com/cat.png",
@@ -11,4 +11,4 @@ async function UploadAnImageFromAurlToMicrosCdn() {
console.log(rsp); console.log(rsp);
} }
await UploadAnImageFromAurlToMicrosCdn(); uploadAnImageFromAurlToMicrosCdn();

View File

@@ -1,12 +1,12 @@
import * as ip from "m3o/ip"; const { IpService } = require("m3o/ip");
// Lookup the geolocation information for an IP address // Lookup the geolocation information for an IP address
async function LookupIpInfo() { async function lookupIpInfo() {
let ipService = new ip.IpService(process.env.MICRO_API_TOKEN); let ipService = new IpService(process.env.MICRO_API_TOKEN);
let rsp = await ipService.lookup({ let rsp = await ipService.lookup({
ip: "93.148.214.31", ip: "93.148.214.31",
}); });
console.log(rsp); console.log(rsp);
} }
await LookupIpInfo(); lookupIpInfo();

View File

@@ -1,14 +1,12 @@
import * as location from "m3o/location"; const { LocationService } = require("m3o/location");
// Read an entity by its ID // Read an entity by its ID
async function GetLocationById() { async function getLocationById() {
let locationService = new location.LocationService( let locationService = new LocationService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await locationService.read({ let rsp = await locationService.read({
id: "1", id: "1",
}); });
console.log(rsp); console.log(rsp);
} }
await GetLocationById(); getLocationById();

View File

@@ -1,10 +1,8 @@
import * as location from "m3o/location"; const { LocationService } = require("m3o/location");
// Save an entity's current position // Save an entity's current position
async function SaveAnEntity() { async function saveAnEntity() {
let locationService = new location.LocationService( let locationService = new LocationService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await locationService.save({ let rsp = await locationService.save({
entity: { entity: {
id: "1", id: "1",
@@ -19,4 +17,4 @@ async function SaveAnEntity() {
console.log(rsp); console.log(rsp);
} }
await SaveAnEntity(); saveAnEntity();

View File

@@ -1,10 +1,8 @@
import * as location from "m3o/location"; const { LocationService } = require("m3o/location");
// Search for entities in a given radius // Search for entities in a given radius
async function SearchForLocations() { async function searchForLocations() {
let locationService = new location.LocationService( let locationService = new LocationService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await locationService.search({ let rsp = await locationService.search({
center: { center: {
latitude: 51.511061, latitude: 51.511061,
@@ -17,4 +15,4 @@ async function SearchForLocations() {
console.log(rsp); console.log(rsp);
} }
await SearchForLocations(); searchForLocations();

View File

@@ -1,8 +1,8 @@
import * as notes from "m3o/notes"; const { NotesService } = require("m3o/notes");
// Create a new note // Create a new note
async function CreateAnote() { async function createAnote() {
let notesService = new notes.NotesService(process.env.MICRO_API_TOKEN); let notesService = new NotesService(process.env.MICRO_API_TOKEN);
let rsp = await notesService.create({ let rsp = await notesService.create({
text: "This is my note", text: "This is my note",
title: "New Note", title: "New Note",
@@ -10,4 +10,4 @@ async function CreateAnote() {
console.log(rsp); console.log(rsp);
} }
await CreateAnote(); createAnote();

View File

@@ -1,12 +1,12 @@
import * as notes from "m3o/notes"; const { NotesService } = require("m3o/notes");
// Delete a note // Delete a note
async function DeleteAnote() { async function deleteAnote() {
let notesService = new notes.NotesService(process.env.MICRO_API_TOKEN); let notesService = new NotesService(process.env.MICRO_API_TOKEN);
let rsp = await notesService.delete({ let rsp = await notesService.delete({
id: "63c0cdf8-2121-11ec-a881-0242e36f037a", id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
}); });
console.log(rsp); console.log(rsp);
} }
await DeleteAnote(); deleteAnote();

View File

@@ -1,10 +1,10 @@
import * as notes from "m3o/notes"; const { NotesService } = require("m3o/notes");
// List all the notes // List all the notes
async function ListAllNotes() { async function listAllNotes() {
let notesService = new notes.NotesService(process.env.MICRO_API_TOKEN); let notesService = new NotesService(process.env.MICRO_API_TOKEN);
let rsp = await notesService.list({}); let rsp = await notesService.list({});
console.log(rsp); console.log(rsp);
} }
await ListAllNotes(); listAllNotes();

View File

@@ -1,12 +1,12 @@
import * as notes from "m3o/notes"; const { NotesService } = require("m3o/notes");
// Read a note // Read a note
async function ReadAnote() { async function readAnote() {
let notesService = new notes.NotesService(process.env.MICRO_API_TOKEN); let notesService = new NotesService(process.env.MICRO_API_TOKEN);
let rsp = await notesService.read({ let rsp = await notesService.read({
id: "63c0cdf8-2121-11ec-a881-0242e36f037a", id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
}); });
console.log(rsp); console.log(rsp);
} }
await ReadAnote(); readAnote();

View File

@@ -1,8 +1,8 @@
import * as notes from "m3o/notes"; const { NotesService } = require("m3o/notes");
// Update a note // Update a note
async function UpdateAnote() { async function updateAnote() {
let notesService = new notes.NotesService(process.env.MICRO_API_TOKEN); let notesService = new NotesService(process.env.MICRO_API_TOKEN);
let rsp = await notesService.update({ let rsp = await notesService.update({
note: { note: {
id: "63c0cdf8-2121-11ec-a881-0242e36f037a", id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
@@ -13,4 +13,4 @@ async function UpdateAnote() {
console.log(rsp); console.log(rsp);
} }
await UpdateAnote(); updateAnote();

View File

@@ -1,12 +1,12 @@
import * as otp from "m3o/otp"; const { OtpService } = require("m3o/otp");
// Generate an OTP (one time pass) code // Generate an OTP (one time pass) code
async function GenerateOtp() { async function generateOtp() {
let otpService = new otp.OtpService(process.env.MICRO_API_TOKEN); let otpService = new OtpService(process.env.MICRO_API_TOKEN);
let rsp = await otpService.generate({ let rsp = await otpService.generate({
id: "asim@example.com", id: "asim@example.com",
}); });
console.log(rsp); console.log(rsp);
} }
await GenerateOtp(); generateOtp();

View File

@@ -1,8 +1,8 @@
import * as otp from "m3o/otp"; const { OtpService } = require("m3o/otp");
// Validate the OTP code // Validate the OTP code
async function ValidateOtp() { async function validateOtp() {
let otpService = new otp.OtpService(process.env.MICRO_API_TOKEN); let otpService = new OtpService(process.env.MICRO_API_TOKEN);
let rsp = await otpService.validate({ let rsp = await otpService.validate({
code: "656211", code: "656211",
id: "asim@example.com", id: "asim@example.com",
@@ -10,4 +10,4 @@ async function ValidateOtp() {
console.log(rsp); console.log(rsp);
} }
await ValidateOtp(); validateOtp();

View File

@@ -1,14 +1,12 @@
import * as postcode from "m3o/postcode"; const { PostcodeService } = require("m3o/postcode");
// Lookup a postcode to retrieve the related region, county, etc // Lookup a postcode to retrieve the related region, county, etc
async function LookupPostcode() { async function lookupPostcode() {
let postcodeService = new postcode.PostcodeService( let postcodeService = new PostcodeService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await postcodeService.lookup({ let rsp = await postcodeService.lookup({
postcode: "SW1A 2AA", postcode: "SW1A 2AA",
}); });
console.log(rsp); console.log(rsp);
} }
await LookupPostcode(); lookupPostcode();

View File

@@ -1,12 +1,10 @@
import * as postcode from "m3o/postcode"; const { PostcodeService } = require("m3o/postcode");
// Return a random postcode and its related info // Return a random postcode and its related info
async function ReturnArandomPostcodeAndItsInformation() { async function returnArandomPostcodeAndItsInformation() {
let postcodeService = new postcode.PostcodeService( let postcodeService = new PostcodeService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await postcodeService.random({}); let rsp = await postcodeService.random({});
console.log(rsp); console.log(rsp);
} }
await ReturnArandomPostcodeAndItsInformation(); returnArandomPostcodeAndItsInformation();

View File

@@ -1,14 +1,12 @@
import * as postcode from "m3o/postcode"; const { PostcodeService } = require("m3o/postcode");
// Validate a postcode. // Validate a postcode.
async function ReturnArandomPostcodeAndItsInformation() { async function returnArandomPostcodeAndItsInformation() {
let postcodeService = new postcode.PostcodeService( let postcodeService = new PostcodeService(process.env.MICRO_API_TOKEN);
process.env.MICRO_API_TOKEN
);
let rsp = await postcodeService.validate({ let rsp = await postcodeService.validate({
postcode: "SW1A 2AA", postcode: "SW1A 2AA",
}); });
console.log(rsp); console.log(rsp);
} }
await ReturnArandomPostcodeAndItsInformation(); returnArandomPostcodeAndItsInformation();

View File

@@ -1,12 +1,12 @@
import * as prayer from "m3o/prayer"; const { PrayerService } = require("m3o/prayer");
// Get the prayer (salah) times for a location on a given date // Get the prayer (salah) times for a location on a given date
async function PrayerTimes() { async function prayerTimes() {
let prayerService = new prayer.PrayerService(process.env.MICRO_API_TOKEN); let prayerService = new PrayerService(process.env.MICRO_API_TOKEN);
let rsp = await prayerService.times({ let rsp = await prayerService.times({
location: "london", location: "london",
}); });
console.log(rsp); console.log(rsp);
} }
await PrayerTimes(); prayerTimes();

View File

@@ -1,8 +1,8 @@
import * as qr from "m3o/qr"; const { QrService } = require("m3o/qr");
// Generate a QR code with a specific text and size // Generate a QR code with a specific text and size
async function GenerateAqrCode() { async function generateAqrCode() {
let qrService = new qr.QrService(process.env.MICRO_API_TOKEN); let qrService = new QrService(process.env.MICRO_API_TOKEN);
let rsp = await qrService.generate({ let rsp = await qrService.generate({
size: 300, size: 300,
text: "https://m3o.com/qr", text: "https://m3o.com/qr",
@@ -10,4 +10,4 @@ async function GenerateAqrCode() {
console.log(rsp); console.log(rsp);
} }
await GenerateAqrCode(); generateAqrCode();

View File

@@ -1,12 +1,12 @@
import * as quran from "m3o/quran"; const { QuranService } = require("m3o/quran");
// List the Chapters (surahs) of the Quran // List the Chapters (surahs) of the Quran
async function ListChapters() { async function listChapters() {
let quranService = new quran.QuranService(process.env.MICRO_API_TOKEN); let quranService = new QuranService(process.env.MICRO_API_TOKEN);
let rsp = await quranService.chapters({ let rsp = await quranService.chapters({
language: "en", language: "en",
}); });
console.log(rsp); console.log(rsp);
} }
await ListChapters(); listChapters();

View File

@@ -1,12 +1,12 @@
import * as quran from "m3o/quran"; const { QuranService } = require("m3o/quran");
// Search the Quran for any form of query or questions // Search the Quran for any form of query or questions
async function SearchTheQuran() { async function searchTheQuran() {
let quranService = new quran.QuranService(process.env.MICRO_API_TOKEN); let quranService = new QuranService(process.env.MICRO_API_TOKEN);
let rsp = await quranService.search({ let rsp = await quranService.search({
query: "messenger", query: "messenger",
}); });
console.log(rsp); console.log(rsp);
} }
await SearchTheQuran(); searchTheQuran();

View File

@@ -1,12 +1,12 @@
import * as quran from "m3o/quran"; const { QuranService } = require("m3o/quran");
// Get a summary for a given chapter (surah) // Get a summary for a given chapter (surah)
async function GetChapterSummary() { async function getChapterSummary() {
let quranService = new quran.QuranService(process.env.MICRO_API_TOKEN); let quranService = new QuranService(process.env.MICRO_API_TOKEN);
let rsp = await quranService.summary({ let rsp = await quranService.summary({
chapter: 1, chapter: 1,
}); });
console.log(rsp); console.log(rsp);
} }
await GetChapterSummary(); getChapterSummary();

View File

@@ -1,14 +1,14 @@
import * as quran from "m3o/quran"; const { QuranService } = require("m3o/quran");
// Lookup the verses (ayahs) for a chapter including // Lookup the verses (ayahs) for a chapter including
// translation, interpretation and breakdown by individual // translation, interpretation and breakdown by individual
// words. // words.
async function GetVersesOfAchapter() { async function getVersesOfAchapter() {
let quranService = new quran.QuranService(process.env.MICRO_API_TOKEN); let quranService = new QuranService(process.env.MICRO_API_TOKEN);
let rsp = await quranService.verses({ let rsp = await quranService.verses({
chapter: 1, chapter: 1,
}); });
console.log(rsp); console.log(rsp);
} }
await GetVersesOfAchapter(); getVersesOfAchapter();

View File

@@ -1,8 +1,8 @@
import * as routing from "m3o/routing"; const { RoutingService } = require("m3o/routing");
// Turn by turn directions from a start point to an end point including maneuvers and bearings // Turn by turn directions from a start point to an end point including maneuvers and bearings
async function TurnByTurnDirections() { async function turnByTurnDirections() {
let routingService = new routing.RoutingService(process.env.MICRO_API_TOKEN); let routingService = new RoutingService(process.env.MICRO_API_TOKEN);
let rsp = await routingService.directions({ let rsp = await routingService.directions({
destination: { destination: {
latitude: 52.529407, latitude: 52.529407,
@@ -16,4 +16,4 @@ async function TurnByTurnDirections() {
console.log(rsp); console.log(rsp);
} }
await TurnByTurnDirections(); turnByTurnDirections();

View File

@@ -1,8 +1,8 @@
import * as routing from "m3o/routing"; const { RoutingService } = require("m3o/routing");
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes // Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
async function EtaFromPointAtoPointB() { async function etaFromPointAtoPointB() {
let routingService = new routing.RoutingService(process.env.MICRO_API_TOKEN); let routingService = new RoutingService(process.env.MICRO_API_TOKEN);
let rsp = await routingService.eta({ let rsp = await routingService.eta({
destination: { destination: {
latitude: 52.529407, latitude: 52.529407,
@@ -16,4 +16,4 @@ async function EtaFromPointAtoPointB() {
console.log(rsp); console.log(rsp);
} }
await EtaFromPointAtoPointB(); etaFromPointAtoPointB();

View File

@@ -1,8 +1,8 @@
import * as routing from "m3o/routing"; const { RoutingService } = require("m3o/routing");
// Retrieve a route as a simple list of gps points along with total distance and estimated duration // Retrieve a route as a simple list of gps points along with total distance and estimated duration
async function GpsPointsForAroute() { async function gpsPointsForAroute() {
let routingService = new routing.RoutingService(process.env.MICRO_API_TOKEN); let routingService = new RoutingService(process.env.MICRO_API_TOKEN);
let rsp = await routingService.route({ let rsp = await routingService.route({
destination: { destination: {
latitude: 52.529407, latitude: 52.529407,
@@ -16,4 +16,4 @@ async function GpsPointsForAroute() {
console.log(rsp); console.log(rsp);
} }
await GpsPointsForAroute(); gpsPointsForAroute();

View File

@@ -1,8 +1,8 @@
import * as rss from "m3o/rss"; const { RssService } = require("m3o/rss");
// Add a new RSS feed with a name, url, and category // Add a new RSS feed with a name, url, and category
async function AddAnewFeed() { async function addAnewFeed() {
let rssService = new rss.RssService(process.env.MICRO_API_TOKEN); let rssService = new RssService(process.env.MICRO_API_TOKEN);
let rsp = await rssService.add({ let rsp = await rssService.add({
category: "news", category: "news",
name: "bbc", name: "bbc",
@@ -11,4 +11,4 @@ async function AddAnewFeed() {
console.log(rsp); console.log(rsp);
} }
await AddAnewFeed(); addAnewFeed();

Some files were not shown because too many files have changed in this diff Show More