Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import ImmudbClient from 'immudb-node'
import Parameters from 'immudb-node/dist/types/parameters'
const IMMUDB_HOST = '127.0.0.1'
const IMMUDB_PORT = 3322
const IMMUDB_USER = 'immudb'
const IMMUDB_PWD = 'immudb'
const cl = new ImmudbClient({
host: IMMUDB_HOST,
port: IMMUDB_PORT,
rootPath: 'rootfile'
});
const rand = '1';
const testDB = 'opsdb';
(async () => {
try {
// login using the specified username and password
const loginReq: Parameters.Login = { user: IMMUDB_USER, password: IMMUDB_PWD }
const loginRes = await cl.login(loginReq)
console.log('success: login', loginRes)
// create database
import ImmudbClient from 'immudb-node'
import Parameters from 'immudb-node/dist/types/parameters'
const IMMUDB_HOST = '127.0.0.1'
const IMMUDB_PORT = 3322
const IMMUDB_USER = 'immudb'
const IMMUDB_PWD = 'immudb'
const cl = new ImmudbClient({
host: IMMUDB_HOST,
port: IMMUDB_PORT,
});
const randNum = Math.floor(Math.random() * Math.floor(100000));
const randStr = `rand${randNum}`;
(async () => {
try {
// login using the specified username and password
const loginReq: Parameters.Login = { user: IMMUDB_USER, password: IMMUDB_PWD }
const loginRes = await cl.login(loginReq)
console.log('success: login', loginRes)
// create database
const createDatabaseReq: Parameters.CreateDatabase = { databasename: randStr }
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import ImmudbClient from 'immudb-node'
import Parameters from 'immudb-node/dist/types/parameters'
const IMMUDB_HOST = '127.0.0.1'
const IMMUDB_PORT = '3322'
const IMMUDB_USER = 'immudb'
const IMMUDB_PWD = 'immudb'
const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
(async () => {
try {
const loginReq: Parameters.Login = { user: IMMUDB_USER, password: IMMUDB_PWD }
const loginRes = await cl.login(loginReq)
console.log('success: login:', loginRes)
const useDatabaseReq: Parameters.UseDatabase = { databasename: 'defaultdb' }
const useDatabaseRes = await cl.useDatabase(useDatabaseReq)
console.log('success: useDatabase:', useDatabaseRes)
const updateAuthConfigReq: Parameters.UpdateAuthConfig = { kind: 1 }
const updateAuthConfigRes = await cl.updateAuthConfig(updateAuthConfigReq)
console.log('success: updateAuthConfig', updateAuthConfigRes)
const updateMTLSConfigReq: Parameters.UpdateMTLSConfig = { enabled: false }
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import ImmudbClient from 'immudb-node'
import Parameters from 'immudb-node/dist/types/parameters'
import util from 'util'
const IMMUDB_HOST = '127.0.0.1'
const IMMUDB_PORT = 3322
const IMMUDB_USER = 'immudb'
const IMMUDB_PWD = 'immudb'
const cl = new ImmudbClient({
host: IMMUDB_HOST,
port: IMMUDB_PORT,
});
const randNum = Math.floor(Math.random() * Math.floor(10));
const randStr = `rand${randNum}`;
(async () => {
try {
const loginReq: Parameters.Login = { user: IMMUDB_USER, password: IMMUDB_PWD }
const loginRes = await cl.login(loginReq)
console.log('success: login', loginRes);
const createDatabaseReq: Parameters.CreateDatabase = { databasename: randStr }
const createDatabaseRes = await cl.createDatabase(createDatabaseReq)
console.log('success: createDatabase', createDatabaseRes);
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import ImmudbClient from 'immudb-node'
import Parameters from 'immudb-node/dist/types/parameters'
import { USER_ACTION, USER_PERMISSION } from 'immudb-node/dist/types/user'
import util from 'util'
const IMMUDB_HOST = '127.0.0.1'
const IMMUDB_PORT = 3322
const IMMUDB_USER = 'immudb'
const IMMUDB_PWD = 'immudb'
const cl = new ImmudbClient({
host: IMMUDB_HOST,
port: IMMUDB_PORT,
})
const randNum = Math.floor(Math.random() * Math.floor(10));
const randStr = `rand${randNum}`;
(async () => {
try {
const loginReq: Parameters.Login = { user: IMMUDB_USER, password: IMMUDB_PWD }
const loginRes = await cl.login(loginReq)
console.log('success: login', loginRes)
const createUserReq: Parameters.CreateUser = {
user: randStr,
password: 'Example12#',
async function main(err, cl) {
if (err) {
return console.log(err)
}
try {
let req = { username: IMMUDB_USER, password: IMMUDB_PWD }
let res = await cl.login(req)
console.log('success: login', res)
req = {
username: rand,
password: 'Example12#',
permission: types.permission.readWrite,
database: 'defaultdb',
}
res = await cl.createUser(req)
console.log('success: createUser');
res = await cl.listUsers()
console.log('success: listUser', util.inspect(res, false, 6, true))
req = {
action: types.action.grant,
username: rand,
database: rand,
permission: types.permission.readOnly,
}
res = await cl.changePermission(req)
console.log('success: changePermission');
username: rand,
password: 'Example12#',
permission: types.permission.readWrite,
database: 'defaultdb',
}
res = await cl.createUser(req)
console.log('success: createUser');
res = await cl.listUsers()
console.log('success: listUser', util.inspect(res, false, 6, true))
req = {
action: types.action.grant,
username: rand,
database: rand,
permission: types.permission.readOnly,
}
res = await cl.changePermission(req)
console.log('success: changePermission');
req = {
username: rand,
old: 'Example12#',
new: 'Example1234%',
}
res = await cl.changePassword(req)
console.log('success: changePassword');
req = {
username: rand,
active: true,
}
console.log('success: login', loginRes)
const createUserReq: Parameters.CreateUser = {
user: randStr,
password: 'Example12#',
permission: USER_PERMISSION.READ_ONLY,
database: 'defaultdb',
}
const createUserRes = await cl.createUser(createUserReq)
console.log('success: createUser', createUserRes);
const listUsersRes = await cl.listUsers()
console.log('success: listUser', util.inspect(listUsersRes, false, 6, true))
const changePermissionReq: Parameters.ChangePermission = {
action: USER_ACTION.GRANT,
username: randStr,
database: randStr,
permission: USER_PERMISSION.READ_WRITE,
}
const changePermissionRes = await cl.changePermission(changePermissionReq)
console.log('success: changePermission', changePermissionRes);
const changePasswordReq: Parameters.ChangePassword = {
user: randStr,
oldpassword: 'Example12#',
newpassword: 'Example1234%',
}
const changePasswordRes = await cl.changePassword(changePasswordReq)
console.log('success: changePassword', changePasswordRes);
const setActiveUserReq: Parameters.SetActiveUser = {
(async () => {
try {
const loginReq: Parameters.Login = { user: IMMUDB_USER, password: IMMUDB_PWD }
const loginRes = await cl.login(loginReq)
console.log('success: login', loginRes)
const createUserReq: Parameters.CreateUser = {
user: randStr,
password: 'Example12#',
permission: USER_PERMISSION.READ_ONLY,
database: 'defaultdb',
}
const createUserRes = await cl.createUser(createUserReq)
console.log('success: createUser', createUserRes);
const listUsersRes = await cl.listUsers()
console.log('success: listUser', util.inspect(listUsersRes, false, 6, true))
const changePermissionReq: Parameters.ChangePermission = {
action: USER_ACTION.GRANT,
username: randStr,
database: randStr,
permission: USER_PERMISSION.READ_WRITE,
}
const changePermissionRes = await cl.changePermission(changePermissionReq)
console.log('success: changePermission', changePermissionRes);
user: randStr,
password: 'Example12#',
permission: USER_PERMISSION.READ_ONLY,
database: 'defaultdb',
}
const createUserRes = await cl.createUser(createUserReq)
console.log('success: createUser', createUserRes);
const listUsersRes = await cl.listUsers()
console.log('success: listUser', util.inspect(listUsersRes, false, 6, true))
const changePermissionReq: Parameters.ChangePermission = {
action: USER_ACTION.GRANT,
username: randStr,
database: randStr,
permission: USER_PERMISSION.READ_WRITE,
}
const changePermissionRes = await cl.changePermission(changePermissionReq)
console.log('success: changePermission', changePermissionRes);
const changePasswordReq: Parameters.ChangePassword = {
user: randStr,
oldpassword: 'Example12#',
newpassword: 'Example1234%',
}
const changePasswordRes = await cl.changePassword(changePasswordReq)
console.log('success: changePassword', changePasswordRes);
const setActiveUserReq: Parameters.SetActiveUser = {
username: randStr,
active: true,
}