forked from tsai/budibase
11 changed files with 91 additions and 75 deletions
@ -1,31 +1,31 @@ |
|||||
import { isString } from "lodash/fp" |
// import { isString } from "lodash/fp"
|
||||
|
|
||||
import { |
// import {
|
||||
BB_STATE_BINDINGPATH, |
// BB_STATE_BINDINGPATH,
|
||||
BB_STATE_FALLBACK, |
// BB_STATE_FALLBACK,
|
||||
BB_STATE_BINDINGSOURCE, |
// BB_STATE_BINDINGSOURCE,
|
||||
isBound, |
// isBound,
|
||||
parseBinding, |
// parseBinding,
|
||||
} from "@budibase/client/src/state/parseBinding" |
// } from "@budibase/client/src/state/parseBinding"
|
||||
|
|
||||
export const isBinding = isBound |
// export const isBinding = isBound
|
||||
|
|
||||
export const setBinding = ({ path, fallback, source }, binding = {}) => { |
// export const setBinding = ({ path, fallback, source }, binding = {}) => {
|
||||
if (isNonEmptyString(path)) binding[BB_STATE_BINDINGPATH] = path |
// if (isNonEmptyString(path)) binding[BB_STATE_BINDINGPATH] = path
|
||||
if (isNonEmptyString(fallback)) binding[BB_STATE_FALLBACK] = fallback |
// if (isNonEmptyString(fallback)) binding[BB_STATE_FALLBACK] = fallback
|
||||
binding[BB_STATE_BINDINGSOURCE] = source || "store" |
// binding[BB_STATE_BINDINGSOURCE] = source || "store"
|
||||
return binding |
// return binding
|
||||
} |
// }
|
||||
|
|
||||
export const getBinding = val => { |
// export const getBinding = val => {
|
||||
const binding = parseBinding(val) |
// const binding = parseBinding(val)
|
||||
return binding |
// return binding
|
||||
? binding |
// ? binding
|
||||
: { |
// : {
|
||||
path: "", |
// path: "",
|
||||
source: "store", |
// source: "store",
|
||||
fallback: "", |
// fallback: "",
|
||||
} |
// }
|
||||
} |
// }
|
||||
|
|
||||
const isNonEmptyString = s => isString(s) && s.length > 0 |
// const isNonEmptyString = s => isString(s) && s.length > 0
|
||||
|
|||||
@ -0,0 +1,26 @@ |
|||||
|
const userController = require("../../user") |
||||
|
|
||||
|
module.exports = async function createUser(user) { |
||||
|
console.log("SAVING this user", user) |
||||
|
|
||||
|
const ctx = { |
||||
|
params: { |
||||
|
instanceId: "inst_60dd510_700f7dc06735403e81d5af91072d7241", |
||||
|
}, |
||||
|
request: { |
||||
|
body: user |
||||
|
}, |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
const response = await userController.create(ctx) |
||||
|
return { |
||||
|
user: response |
||||
|
} |
||||
|
} catch (err) { |
||||
|
console.error(err); |
||||
|
return { |
||||
|
user: null |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue