Setup a Simple Server-Side Application for Your Game Using Strapi.js — Part 1

“Note that this tutorial is done in Windows OS. For Linux you may need to make some changes and modifications ;)”

It’s a fact that having a server-side application, can help developers to add lots of functionalities to their games. They can have a score leaderboard, some game configs they want to change without client updates, occasional events, handling online asset bundles, validating purchases, or even implementing game logic on the server! And that’s just a few of the functionalities I’m talking about!

Today I’m going to introduce something that can help you meet your very basic needs for a game web application. Something that you can easily deploy on a server (Windows/Linux) and use it in a game, no matter what engine or tool you’re using (Unity, Unreal, Game Maker, …).

#unity #strapi #game-server #nodejs #web-applications

What is GEEK

Buddha Community

Setup a Simple Server-Side Application for Your Game Using Strapi.js — Part 1

Setup a Simple Server-Side Application for Your Game Using Strapi.js — Part 1

“Note that this tutorial is done in Windows OS. For Linux you may need to make some changes and modifications ;)”

It’s a fact that having a server-side application, can help developers to add lots of functionalities to their games. They can have a score leaderboard, some game configs they want to change without client updates, occasional events, handling online asset bundles, validating purchases, or even implementing game logic on the server! And that’s just a few of the functionalities I’m talking about!

Today I’m going to introduce something that can help you meet your very basic needs for a game web application. Something that you can easily deploy on a server (Windows/Linux) and use it in a game, no matter what engine or tool you’re using (Unity, Unreal, Game Maker, …).

#unity #strapi #game-server #nodejs #web-applications

A Wrapper for Sembast and SQFlite to Enable Easy

FHIR_DB

This is really just a wrapper around Sembast_SQFLite - so all of the heavy lifting was done by Alex Tekartik. I highly recommend that if you have any questions about working with this package that you take a look at Sembast. He's also just a super nice guy, and even answered a question for me when I was deciding which sembast version to use. As usual, ResoCoder also has a good tutorial.

I have an interest in low-resource settings and thus a specific reason to be able to store data offline. To encourage this use, there are a number of other packages I have created based around the data format FHIR. FHIR® is the registered trademark of HL7 and is used with the permission of HL7. Use of the FHIR trademark does not constitute endorsement of this product by HL7.

Using the Db

So, while not absolutely necessary, I highly recommend that you use some sort of interface class. This adds the benefit of more easily handling errors, plus if you change to a different database in the future, you don't have to change the rest of your app, just the interface.

I've used something like this in my projects:

class IFhirDb {
  IFhirDb();
  final ResourceDao resourceDao = ResourceDao();

  Future<Either<DbFailure, Resource>> save(Resource resource) async {
    Resource resultResource;
    try {
      resultResource = await resourceDao.save(resource);
    } catch (error) {
      return left(DbFailure.unableToSave(error: error.toString()));
    }
    return right(resultResource);
  }

  Future<Either<DbFailure, List<Resource>>> returnListOfSingleResourceType(
      String resourceType) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.getAllSortedById(resourceType: resourceType);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }

  Future<Either<DbFailure, List<Resource>>> searchFunction(
      String resourceType, String searchString, String reference) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.searchFor(resourceType, searchString, reference);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }
}

I like this because in case there's an i/o error or something, it won't crash your app. Then, you can call this interface in your app like the following:

final patient = Patient(
    resourceType: 'Patient',
    name: [HumanName(text: 'New Patient Name')],
    birthDate: Date(DateTime.now()),
);

final saveResult = await IFhirDb().save(patient);

This will save your newly created patient to the locally embedded database.

IMPORTANT: this database will expect that all previously created resources have an id. When you save a resource, it will check to see if that resource type has already been stored. (Each resource type is saved in it's own store in the database). It will then check if there is an ID. If there's no ID, it will create a new one for that resource (along with metadata on version number and creation time). It will save it, and return the resource. If it already has an ID, it will copy the the old version of the resource into a _history store. It will then update the metadata of the new resource and save that version into the appropriate store for that resource. If, for instance, we have a previously created patient:

{
    "resourceType": "Patient",
    "id": "fhirfli-294057507-6811107",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2020-10-16T19:41:28.054369Z"
    },
    "name": [
        {
            "given": ["New"],
            "family": "Patient"
        }
    ],
    "birthDate": "2020-10-16"
}

And we update the last name to 'Provider'. The above version of the patient will be kept in _history, while in the 'Patient' store in the db, we will have the updated version:

{
    "resourceType": "Patient",
    "id": "fhirfli-294057507-6811107",
    "meta": {
        "versionId": "2",
        "lastUpdated": "2020-10-16T19:45:07.316698Z"
    },
    "name": [
        {
            "given": ["New"],
            "family": "Provider"
        }
    ],
    "birthDate": "2020-10-16"
}

This way we can keep track of all previous version of all resources (which is obviously important in medicine).

For most of the interactions (saving, deleting, etc), they work the way you'd expect. The only difference is search. Because Sembast is NoSQL, we can search on any of the fields in a resource. If in our interface class, we have the following function:

  Future<Either<DbFailure, List<Resource>>> searchFunction(
      String resourceType, String searchString, String reference) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.searchFor(resourceType, searchString, reference);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }

You can search for all immunizations of a certain patient:

searchFunction(
        'Immunization', 'patient.reference', 'Patient/$patientId');

This function will search through all entries in the 'Immunization' store. It will look at all 'patient.reference' fields, and return any that match 'Patient/$patientId'.

The last thing I'll mention is that this is a password protected db, using AES-256 encryption (although it can also use Salsa20). Anytime you use the db, you have the option of using a password for encryption/decryption. Remember, if you setup the database using encryption, you will only be able to access it using that same password. When you're ready to change the password, you will need to call the update password function. If we again assume we created a change password method in our interface, it might look something like this:

class IFhirDb {
  IFhirDb();
  final ResourceDao resourceDao = ResourceDao();
  ...
    Future<Either<DbFailure, Unit>> updatePassword(String oldPassword, String newPassword) async {
    try {
      await resourceDao.updatePw(oldPassword, newPassword);
    } catch (error) {
      return left(DbFailure.unableToUpdatePassword(error: error.toString()));
    }
    return right(Unit);
  }

You don't have to use a password, and in that case, it will save the db file as plain text. If you want to add a password later, it will encrypt it at that time.

General Store

After using this for a while in an app, I've realized that it needs to be able to store data apart from just FHIR resources, at least on occasion. For this, I've added a second class for all versions of the database called GeneralDao. This is similar to the ResourceDao, but fewer options. So, in order to save something, it would look like this:

await GeneralDao().save('password', {'new':'map'});
await GeneralDao().save('password', {'new':'map'}, 'key');

The difference between these two options is that the first one will generate a key for the map being stored, while the second will store the map using the key provided. Both will return the key after successfully storing the map.

Other functions available include:

// deletes everything in the general store
await GeneralDao().deleteAllGeneral('password'); 

// delete specific entry
await GeneralDao().delete('password','key'); 

// returns map with that key
await GeneralDao().find('password', 'key'); 

FHIR® is a registered trademark of Health Level Seven International (HL7) and its use does not constitute an endorsement of products by HL7®

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add fhir_db

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  fhir_db: ^0.4.3

Alternatively, your editor might support or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:fhir_db/dstu2.dart';
import 'package:fhir_db/dstu2/fhir_db.dart';
import 'package:fhir_db/dstu2/general_dao.dart';
import 'package:fhir_db/dstu2/resource_dao.dart';
import 'package:fhir_db/encrypt/aes.dart';
import 'package:fhir_db/encrypt/salsa.dart';
import 'package:fhir_db/r4.dart';
import 'package:fhir_db/r4/fhir_db.dart';
import 'package:fhir_db/r4/general_dao.dart';
import 'package:fhir_db/r4/resource_dao.dart';
import 'package:fhir_db/r5.dart';
import 'package:fhir_db/r5/fhir_db.dart';
import 'package:fhir_db/r5/general_dao.dart';
import 'package:fhir_db/r5/resource_dao.dart';
import 'package:fhir_db/stu3.dart';
import 'package:fhir_db/stu3/fhir_db.dart';
import 'package:fhir_db/stu3/general_dao.dart';
import 'package:fhir_db/stu3/resource_dao.dart'; 

example/lib/main.dart

import 'package:fhir/r4.dart';
import 'package:fhir_db/r4.dart';
import 'package:flutter/material.dart';
import 'package:test/test.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final resourceDao = ResourceDao();

  // await resourceDao.updatePw('newPw', null);
  await resourceDao.deleteAllResources(null);

  group('Playing with passwords', () {
    test('Playing with Passwords', () async {
      final patient = Patient(id: Id('1'));

      final saved = await resourceDao.save(null, patient);

      await resourceDao.updatePw(null, 'newPw');
      final search1 = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search1[0]);

      await resourceDao.updatePw('newPw', 'newerPw');
      final search2 = await resourceDao.find('newerPw',
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search2[0]);

      await resourceDao.updatePw('newerPw', null);
      final search3 = await resourceDao.find(null,
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search3[0]);

      await resourceDao.deleteAllResources(null);
    });
  });

  final id = Id('12345');
  group('Saving Things:', () {
    test('Save Patient', () async {
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);
      final patient = Patient(id: id, name: [humanName]);
      final saved = await resourceDao.save(null, patient);

      expect(saved.id, id);

      expect((saved as Patient).name?[0], humanName);
    });

    test('Save Organization', () async {
      final organization = Organization(id: id, name: 'FhirFli');
      final saved = await resourceDao.save(null, organization);

      expect(saved.id, id);

      expect((saved as Organization).name, 'FhirFli');
    });

    test('Save Observation1', () async {
      final observation1 = Observation(
        id: Id('obs1'),
        code: CodeableConcept(text: 'Observation #1'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1');
    });

    test('Save Observation1 Again', () async {
      final observation1 = Observation(
          id: Id('obs1'),
          code: CodeableConcept(text: 'Observation #1 - Updated'));
      final saved = await resourceDao.save(null, observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1 - Updated');

      expect(saved.meta?.versionId, Id('2'));
    });

    test('Save Observation2', () async {
      final observation2 = Observation(
        id: Id('obs2'),
        code: CodeableConcept(text: 'Observation #2'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation2);

      expect(saved.id, Id('obs2'));

      expect((saved as Observation).code.text, 'Observation #2');
    });

    test('Save Observation3', () async {
      final observation3 = Observation(
        id: Id('obs3'),
        code: CodeableConcept(text: 'Observation #3'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation3);

      expect(saved.id, Id('obs3'));

      expect((saved as Observation).code.text, 'Observation #3');
    });
  });

  group('Finding Things:', () {
    test('Find 1st Patient', () async {
      final search = await resourceDao.find(null,
          resourceType: R4ResourceType.Patient, id: id);
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);

      expect(search.length, 1);

      expect((search[0] as Patient).name?[0], humanName);
    });

    test('Find 3rd Observation', () async {
      final search = await resourceDao.find(null,
          resourceType: R4ResourceType.Observation, id: Id('obs3'));

      expect(search.length, 1);

      expect(search[0].id, Id('obs3'));

      expect((search[0] as Observation).code.text, 'Observation #3');
    });

    test('Find All Observations', () async {
      final search = await resourceDao.getResourceType(
        null,
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 3);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), true);

      expect(idList.contains('obs3'), true);
    });

    test('Find All (non-historical) Resources', () async {
      final search = await resourceDao.getAll(null);

      expect(search.length, 5);
      final patList = search.toList();
      final orgList = search.toList();
      final obsList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);
      obsList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Observation);

      expect(patList.length, 1);

      expect(orgList.length, 1);

      expect(obsList.length, 3);
    });
  });

  group('Deleting Things:', () {
    test('Delete 2nd Observation', () async {
      await resourceDao.delete(
          null, null, R4ResourceType.Observation, Id('obs2'), null, null);

      final search = await resourceDao.getResourceType(
        null,
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 2);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), false);

      expect(idList.contains('obs3'), true);
    });

    test('Delete All Observations', () async {
      await resourceDao.deleteSingleType(null,
          resourceType: R4ResourceType.Observation);

      final search = await resourceDao.getAll(null);

      expect(search.length, 2);

      final patList = search.toList();
      final orgList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);

      expect(patList.length, 1);

      expect(patList.length, 1);
    });

    test('Delete All Resources', () async {
      await resourceDao.deleteAllResources(null);

      final search = await resourceDao.getAll(null);

      expect(search.length, 0);
    });
  });

  group('Password - Saving Things:', () {
    test('Save Patient', () async {
      await resourceDao.updatePw(null, 'newPw');
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);
      final patient = Patient(id: id, name: [humanName]);
      final saved = await resourceDao.save('newPw', patient);

      expect(saved.id, id);

      expect((saved as Patient).name?[0], humanName);
    });

    test('Save Organization', () async {
      final organization = Organization(id: id, name: 'FhirFli');
      final saved = await resourceDao.save('newPw', organization);

      expect(saved.id, id);

      expect((saved as Organization).name, 'FhirFli');
    });

    test('Save Observation1', () async {
      final observation1 = Observation(
        id: Id('obs1'),
        code: CodeableConcept(text: 'Observation #1'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1');
    });

    test('Save Observation1 Again', () async {
      final observation1 = Observation(
          id: Id('obs1'),
          code: CodeableConcept(text: 'Observation #1 - Updated'));
      final saved = await resourceDao.save('newPw', observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1 - Updated');

      expect(saved.meta?.versionId, Id('2'));
    });

    test('Save Observation2', () async {
      final observation2 = Observation(
        id: Id('obs2'),
        code: CodeableConcept(text: 'Observation #2'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation2);

      expect(saved.id, Id('obs2'));

      expect((saved as Observation).code.text, 'Observation #2');
    });

    test('Save Observation3', () async {
      final observation3 = Observation(
        id: Id('obs3'),
        code: CodeableConcept(text: 'Observation #3'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation3);

      expect(saved.id, Id('obs3'));

      expect((saved as Observation).code.text, 'Observation #3');
    });
  });

  group('Password - Finding Things:', () {
    test('Find 1st Patient', () async {
      final search = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Patient, id: id);
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);

      expect(search.length, 1);

      expect((search[0] as Patient).name?[0], humanName);
    });

    test('Find 3rd Observation', () async {
      final search = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Observation, id: Id('obs3'));

      expect(search.length, 1);

      expect(search[0].id, Id('obs3'));

      expect((search[0] as Observation).code.text, 'Observation #3');
    });

    test('Find All Observations', () async {
      final search = await resourceDao.getResourceType(
        'newPw',
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 3);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), true);

      expect(idList.contains('obs3'), true);
    });

    test('Find All (non-historical) Resources', () async {
      final search = await resourceDao.getAll('newPw');

      expect(search.length, 5);
      final patList = search.toList();
      final orgList = search.toList();
      final obsList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);
      obsList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Observation);

      expect(patList.length, 1);

      expect(orgList.length, 1);

      expect(obsList.length, 3);
    });
  });

  group('Password - Deleting Things:', () {
    test('Delete 2nd Observation', () async {
      await resourceDao.delete(
          'newPw', null, R4ResourceType.Observation, Id('obs2'), null, null);

      final search = await resourceDao.getResourceType(
        'newPw',
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 2);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), false);

      expect(idList.contains('obs3'), true);
    });

    test('Delete All Observations', () async {
      await resourceDao.deleteSingleType('newPw',
          resourceType: R4ResourceType.Observation);

      final search = await resourceDao.getAll('newPw');

      expect(search.length, 2);

      final patList = search.toList();
      final orgList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);

      expect(patList.length, 1);

      expect(patList.length, 1);
    });

    test('Delete All Resources', () async {
      await resourceDao.deleteAllResources('newPw');

      final search = await resourceDao.getAll('newPw');

      expect(search.length, 0);

      await resourceDao.updatePw('newPw', null);
    });
  });
} 

Download Details:

Author: MayJuun

Source Code: https://github.com/MayJuun/fhir/tree/main/fhir_db

#sqflite  #dart  #flutter 

Arvel  Miller

Arvel Miller

1599762180

Setup a Simple Server-Side Application for Your Game Using Strapi.js

In the previous part, we successfully installed and ran a Strapi application. Now it is time to build the API. But first let’s take a close look at what a game server like this can provide us:

  • It can authenticate users.
  • We can implement game logics.
  • Users can see leaderboads.
  • We can change some of the game elements through the server.
  • and lots of other functionalities.

Controllers, Services and Routes

For building an API in Strapi, you need to understand 3 main concepts.

**Services: **Services serve as global methods which you can use everywhere in your application. Their main job is to reduce the use of some repeatable functions by being available globally.

**Controllers: **Controllers are the main part of your API. The main functions go here.

**Routes: **Routes are bounded to controller methods. They are actually Urls which are pointing to a specific method, so each time you call that Url the method gets executed.

Know that you’re familiar with these 3 concepts, we are ready to create a remote config system for our game.

Remote Config

Creating Model

Let’s say we have an RPG game with different heroes, hero types, buildings, maps, items and etc. Each hero has its own specifications such as damage power (if it is melee), range (if it’s of range type), health, mana and so many other parameters. These things need to be balanced and tweaked by game designers frequently. So it is not a good idea to put them inside the client. The best solution is to get all of those data from your server at the very beginning of the game and keep them for later use.

For creating such a functionality, the very first step is to create a model of data. It should be one single model to cover everything that need a config in the game, such as heroes, hero types, items and etc. So we need these fields:

  • **Name **(it defines to what specific part of the game, this object belongs)
  • **Type **(it tells us the type of this object)
  • **Data **(the main data that we want to tweak or adjust later)

Now that we have a model in mind, we open the Strapi’s admin panel:

Image for post

Strapi admin panel

here you can see that Strapi has already made a collection (or content-type) called Users. We need something like that for our Remote Config. A collection that stores our config data.

open the Content-Types Builder:

Image for post

under the Collection Types in the grey column, you can see the blue text saying Create new collection type. Click on it:

Image for post

a window pops open. In the Display name write Remote Config and press Continue. Now you can see this window:

Image for post

here you should create those 3 fields that we talked about. Name,_Type _and Data. For name you can choose _Text _or UID. I recommend you to select _UID _because it guarantees that the content of that field is unique in entire collection. So I select the UID:

Image for post

inside the Name field write name (with small letter because it’s better :) )

and click on +Add another field, For our _Type _field you can select Text:

Image for post

Image for post

#strapi #games #javascript #game-server #nodejs

NBB: Ad-hoc CLJS Scripting on Node.js

Nbb

Not babashka. Node.js babashka!?

Ad-hoc CLJS scripting on Node.js.

Status

Experimental. Please report issues here.

Goals and features

Nbb's main goal is to make it easy to get started with ad hoc CLJS scripting on Node.js.

Additional goals and features are:

  • Fast startup without relying on a custom version of Node.js.
  • Small artifact (current size is around 1.2MB).
  • First class macros.
  • Support building small TUI apps using Reagent.
  • Complement babashka with libraries from the Node.js ecosystem.

Requirements

Nbb requires Node.js v12 or newer.

How does this tool work?

CLJS code is evaluated through SCI, the same interpreter that powers babashka. Because SCI works with advanced compilation, the bundle size, especially when combined with other dependencies, is smaller than what you get with self-hosted CLJS. That makes startup faster. The trade-off is that execution is less performant and that only a subset of CLJS is available (e.g. no deftype, yet).

Usage

Install nbb from NPM:

$ npm install nbb -g

Omit -g for a local install.

Try out an expression:

$ nbb -e '(+ 1 2 3)'
6

And then install some other NPM libraries to use in the script. E.g.:

$ npm install csv-parse shelljs zx

Create a script which uses the NPM libraries:

(ns script
  (:require ["csv-parse/lib/sync$default" :as csv-parse]
            ["fs" :as fs]
            ["path" :as path]
            ["shelljs$default" :as sh]
            ["term-size$default" :as term-size]
            ["zx$default" :as zx]
            ["zx$fs" :as zxfs]
            [nbb.core :refer [*file*]]))

(prn (path/resolve "."))

(prn (term-size))

(println (count (str (fs/readFileSync *file*))))

(prn (sh/ls "."))

(prn (csv-parse "foo,bar"))

(prn (zxfs/existsSync *file*))

(zx/$ #js ["ls"])

Call the script:

$ nbb script.cljs
"/private/tmp/test-script"
#js {:columns 216, :rows 47}
510
#js ["node_modules" "package-lock.json" "package.json" "script.cljs"]
#js [#js ["foo" "bar"]]
true
$ ls
node_modules
package-lock.json
package.json
script.cljs

Macros

Nbb has first class support for macros: you can define them right inside your .cljs file, like you are used to from JVM Clojure. Consider the plet macro to make working with promises more palatable:

(defmacro plet
  [bindings & body]
  (let [binding-pairs (reverse (partition 2 bindings))
        body (cons 'do body)]
    (reduce (fn [body [sym expr]]
              (let [expr (list '.resolve 'js/Promise expr)]
                (list '.then expr (list 'clojure.core/fn (vector sym)
                                        body))))
            body
            binding-pairs)))

Using this macro we can look async code more like sync code. Consider this puppeteer example:

(-> (.launch puppeteer)
      (.then (fn [browser]
               (-> (.newPage browser)
                   (.then (fn [page]
                            (-> (.goto page "https://clojure.org")
                                (.then #(.screenshot page #js{:path "screenshot.png"}))
                                (.catch #(js/console.log %))
                                (.then #(.close browser)))))))))

Using plet this becomes:

(plet [browser (.launch puppeteer)
       page (.newPage browser)
       _ (.goto page "https://clojure.org")
       _ (-> (.screenshot page #js{:path "screenshot.png"})
             (.catch #(js/console.log %)))]
      (.close browser))

See the puppeteer example for the full code.

Since v0.0.36, nbb includes promesa which is a library to deal with promises. The above plet macro is similar to promesa.core/let.

Startup time

$ time nbb -e '(+ 1 2 3)'
6
nbb -e '(+ 1 2 3)'   0.17s  user 0.02s system 109% cpu 0.168 total

The baseline startup time for a script is about 170ms seconds on my laptop. When invoked via npx this adds another 300ms or so, so for faster startup, either use a globally installed nbb or use $(npm bin)/nbb script.cljs to bypass npx.

Dependencies

NPM dependencies

Nbb does not depend on any NPM dependencies. All NPM libraries loaded by a script are resolved relative to that script. When using the Reagent module, React is resolved in the same way as any other NPM library.

Classpath

To load .cljs files from local paths or dependencies, you can use the --classpath argument. The current dir is added to the classpath automatically. So if there is a file foo/bar.cljs relative to your current dir, then you can load it via (:require [foo.bar :as fb]). Note that nbb uses the same naming conventions for namespaces and directories as other Clojure tools: foo-bar in the namespace name becomes foo_bar in the directory name.

To load dependencies from the Clojure ecosystem, you can use the Clojure CLI or babashka to download them and produce a classpath:

$ classpath="$(clojure -A:nbb -Spath -Sdeps '{:aliases {:nbb {:replace-deps {com.github.seancorfield/honeysql {:git/tag "v2.0.0-rc5" :git/sha "01c3a55"}}}}}')"

and then feed it to the --classpath argument:

$ nbb --classpath "$classpath" -e "(require '[honey.sql :as sql]) (sql/format {:select :foo :from :bar :where [:= :baz 2]})"
["SELECT foo FROM bar WHERE baz = ?" 2]

Currently nbb only reads from directories, not jar files, so you are encouraged to use git libs. Support for .jar files will be added later.

Current file

The name of the file that is currently being executed is available via nbb.core/*file* or on the metadata of vars:

(ns foo
  (:require [nbb.core :refer [*file*]]))

(prn *file*) ;; "/private/tmp/foo.cljs"

(defn f [])
(prn (:file (meta #'f))) ;; "/private/tmp/foo.cljs"

Reagent

Nbb includes reagent.core which will be lazily loaded when required. You can use this together with ink to create a TUI application:

$ npm install ink

ink-demo.cljs:

(ns ink-demo
  (:require ["ink" :refer [render Text]]
            [reagent.core :as r]))

(defonce state (r/atom 0))

(doseq [n (range 1 11)]
  (js/setTimeout #(swap! state inc) (* n 500)))

(defn hello []
  [:> Text {:color "green"} "Hello, world! " @state])

(render (r/as-element [hello]))

Promesa

Working with callbacks and promises can become tedious. Since nbb v0.0.36 the promesa.core namespace is included with the let and do! macros. An example:

(ns prom
  (:require [promesa.core :as p]))

(defn sleep [ms]
  (js/Promise.
   (fn [resolve _]
     (js/setTimeout resolve ms))))

(defn do-stuff
  []
  (p/do!
   (println "Doing stuff which takes a while")
   (sleep 1000)
   1))

(p/let [a (do-stuff)
        b (inc a)
        c (do-stuff)
        d (+ b c)]
  (prn d))
$ nbb prom.cljs
Doing stuff which takes a while
Doing stuff which takes a while
3

Also see API docs.

Js-interop

Since nbb v0.0.75 applied-science/js-interop is available:

(ns example
  (:require [applied-science.js-interop :as j]))

(def o (j/lit {:a 1 :b 2 :c {:d 1}}))

(prn (j/select-keys o [:a :b])) ;; #js {:a 1, :b 2}
(prn (j/get-in o [:c :d])) ;; 1

Most of this library is supported in nbb, except the following:

  • destructuring using :syms
  • property access using .-x notation. In nbb, you must use keywords.

See the example of what is currently supported.

Examples

See the examples directory for small examples.

Also check out these projects built with nbb:

API

See API documentation.

Migrating to shadow-cljs

See this gist on how to convert an nbb script or project to shadow-cljs.

Build

Prequisites:

  • babashka >= 0.4.0
  • Clojure CLI >= 1.10.3.933
  • Node.js 16.5.0 (lower version may work, but this is the one I used to build)

To build:

  • Clone and cd into this repo
  • bb release

Run bb tasks for more project-related tasks.

Download Details:
Author: borkdude
Download Link: Download The Source Code
Official Website: https://github.com/borkdude/nbb 
License: EPL-1.0

#node #javascript

Best Review

1629825646

Design Beast Review & OTO Link

Design Beast Review & OTOs + $20k Bonuses

CHECK BONUSES & GRAB IT AT: https://bit.ly/3yhtcqi

Welcome to my Design Beast Review A Very warm welcome to my DesignBeast Review Here You Will Find Honest Opinion About The Design Beast Whether It is A Right Fit For You or not also I Have Covered All Working processes of DesignBeast, Live Video Demo, features Pros & Cons & All Design Beast OTO details.

Govind Rana Here Stay Till the End Of This Review I Have included $20k Bonuses At the end Of DesignBeast Review

DesignBeast Review – World finest graphic designing & animation software that will come into existence in some days. If you are searching for DesignBeast Review then this is the right platform to get in-depth information and the truth for Design Beast Review. An AI-based designing software that enables the 3D designing technology to you.

I am pretty much excited to share my point of view about the design beast. and this is because I want to meet you to the high technology graphics software.

This software is going to launch on 26 Aug. 2021 by the very famous vendor Paul Ponna and this time he is launching is 2 years of efforts on this amazing app. So do believe me without any doubt, here I only share the actual facts for Designbeast Review.

At this time the limited information is available on the web so I have included the creator of DesignBeast, Paul Ponna’s previous launches, what is DesignBeast, features & benefits, examples, who will best fit for this app, pros & cons, included with a huge bonuses.

Discount will be rolling out from 26th August

(fingers crossed till its launch because it is the launch beyond expectations)

Design Beast Review – Overview

  • Creator: Paul Ponna
  • Product Name: DesignBeast
  • Launch Date – 2021-Aug-24
  • Launch Timing – 11:00 EDT
  • Pricing – $67
  • Official Website – Visit
  • Money-Back Guarantee- Information Not Available
  • Category – Graphic Designing
  • Training – Yes, Available
  • Bonuses – Techevoke Special Bonuses Available

About Paul Ponna the vendor & Creator of DesignBeast

Paul Ponna is an entrepreneur and a digital geek in the internet marketing niche. His previous launches were hit the market products and were evergreen. No comparison of his products because he knows what is a need in today’s market and how online marketers will get benefited from online technologies.

So let’s have a look at Paul Ponna’s previous hits in the saas industry.

  1. DoodleMaker – This is the doodle video maker and the popular software on JVZoo that is the biggest launch in the history of internet marketing software. With a doodle maker, you can create studio-quality doodle videos with this application.
  2. VideoCreator – A readymade video editing app that is more authentic than existing video editing software. No more templates creation is required and no extra efforts to make and you can make exciting effects with videocreator.
  3. There is more software that has been launched by Paul Ponna…
  • DoodleMaker
  • Avatar Builder
  • VideoCreator
  • DesignBeast (available on 26th Aug)

Paul Ponna is a tech entrepreneur and he was started his journey from his 18 and with a website and hosting spending only $20. And he is a millionaire and frequently launches products that are really amazing and useful.

So not further delays let come to the designbeast review and let’s talk about what will be this software and how can you get benefited from this.

What is Design Beast?

Design beast is a software that comes with 6 world-class designing technology, and with those 6 modules, you can fulfill your graphics needs in just 1 price tag.

DesignBeast is a software that is responsible for multipurpose designs and better technology including these below-mentioned modules.

  1. Design Automation App #1– All in One Design and Mockup Engine
  2. Design Automation App #1– 3D Live Motion Photos
  3. Design Automation App #1– Magic Object Remover
  4. Design Automation App #1– 1-Click Background Removal
  5. Design Automation App #1– Slick Image Editor
  6. Design Automation App #1– AI Logo Creator

This is app bundle is fully loaded with advanced graphics features that are essential for making high-quality posts, infographics, motion pictures, 3D banners, and more.

Here are all modules explanations of DesignBeast

So this is clear this app has various technologies that are responsible for advanced editing and professional graphical designs. So here is the module’s explanation.

  1. All in One Design and mockup Engine

This is a designs library, not an ordinary image or premade design library. All elements are customizable and you can create any of your imagination with this design and mockup engine.

7000+ ready-to-use customizable designs and mockups are available in this module. Just head over to the DesignBeast software and you will get the professional DFY designs and mockups for your graphics need.

There are for all social apps, means available in various sizes.

2. 3D Live Motion Photos

Now you can convert a still, boring photo to a live, 3D effect photo with the A.I. technology of DesignBeast. With this effect, you can engage with your audience in a more effective manner.

And you all know that a moving object with a visual effect is 10x more engaging than an ordinary graphical image. with this technology, you can grab the attention of your customers and get more clicks on your sales platform.

3. Magic Object Removal Tool

Most of the time we need to remove some object or any person from any of the selected images and this module will give you access to select the required object or person and the remove that thing is just one click.

The feature Paul Ponna offers in his software is rarely available on any other software. With only one click the magic happens and the object will be removed.

4. 1-Click Background Removal

Because the software has technology that is based on AI and Machine Learning. So it auto-detects the edges and objects in your photos and automatically erases the background from any photo.

You don’t need to make extra effects just select the 1 click background removal option and click on the image background and it will vanish within seconds.

5. Slick Image Editor

This has the multi-feature of basic editing for any photo. Just like edit, crop, short, effects, blur, and more. You don’t need to go for different apps to perform different tasks every time.

You can convert any still normal photo to a high-class visual and ready-to-use, ready-to-print photo with this module.

6. Artificial Intelligence Logo Creator

An AI logo creator, not just a free tool that is available in the online market but it is quite effective and useful for you to generate any kind of logo. You can now bulk-create 50 logo variations for any brand in 3 easy steps.

All designs are fully customizable, also a single object is customizable with this app.

How DesignBeast will fire in the saas market?

In this section of DesignBeast Review, I am sharing its popularity, hype, and the vendor name-fame with you, so that you can evaluate its worth.

Just because you need a better, time-saving, authentic, graphic designing and animation software that will fulfill your professional graphics need for online marketing.

Because paul Ponna is a tech entrepreneur and he knows what is write to tab the market and what should be the next useful tool for every marketer.

DesignBeast is now going to be a popular one from the software list of its vendor. No matter what competitors of DesignBeast will say about this software. But as a consumer and a digital marketer, I am pretty much excited for its official launch.

DesignBeast Features & Benefits

If you want to create designs for Social media, websites, e-commerce sites, local businesses, promos, and advertising then focus on the features & benefits of DesignBeast Review, so that you can evaluate its actual strength.

 A.I. & Machine Learning Technology

This is the platform that suggests automatically the designs, objects, effects & more things that are based on your needs and the design frame you choose.

Automate design tasks with machine learning and artificial intelligence to leapfrog your competition and maximize revenues.

 6 Apps in the Price of One

There is no comparison of this app in the online market because the bundle of 6 apps and those apps are highly authentic useful in today’s competitive marketing world.

You can replace multiple graphics apps from one that is DesignBeast and you need to replace it if you want to save your money and time.

 Multilingual

This app is available in multi-languages, and with this feature, it doesn’t matter from where you are in this world.

It enables you to sell your service towards the globe and also give you the access to create graphical content in your local language.

 Commercial and resell rights available

Commercial licensing brings you to another stage of selling your services to clients. Now you can freely sell all generated content to your clients in the market. Also charge extra fees according to your skills and set your service on commercial platforms.

 Copywrite free assets and resources

Assets that are really expensive and everyone even I needs to purchase from the online market and those services are very expensive for all of us. But now all are available at one place that is design beast, you will get premium royalty-free images, icons, backgrounds & animations.

 Save Time and money

You can build world-class designs in minutes and all designs are professional, in starting you need to learn some lessons and practice to perform with DesignBeast membersarea.

 Dynamic Visual Effects

The effects offered by this software is so amazing and fully customizable so that I have given the term dynamic. All things are editable and ready to use.

Is there are any skills required to work with DesignBeast?

Designbeast is a DFY editable templates advanced graphic design software that will suggest to you the designs from its A.I. and machine learning technology. So I am sure you don’t need any advanced skills to use DesignBeast.

But to be honest, you need to work on these soft skills.

  1. Knowledge of using basic online apps.
  2. The mindset to Selecting the best
  3. Knowledge of colors
  4. Knowledge of graphics
  5. Understanding of designs
  6. Branding

And there are most soft skills required.

Design Beast Review – Who will be fit for this software?

So now in this series, it’s time to share the industry people who are best fit for this software that is Designbeast. And after lots of research and analysis, I decided to include these professionals in the DesignBeast audience. I am happy to share my point views in this DesignBeast Review.

  • Graphic Designers
  • Digital Marketers
  • Bloggers.
  • Vloggers
  • Youtubers
  • Media Agency
  • Advertising agency
  • Local Businesses
  • Ecommerce Players

DesignBeast Review – Pros & Cons

I have shared the sure short pros and cons for this revolutionary software. But there are some cons also available. After reviewing the product, as a marketer, I also realized this has lots of pros and some cons available in the market.

Pros

  • 6 modules in 1 app
  • 3d photo creation technology with AI and machine learning
  • Background and object removal technology.
  • Designs library over 7000
  • Kindly support team.
  • Trustable vendor
  • 30 Days money back gaurantee.
  • And more…

Cons

  • Some modules are more useful than 1 or 2 other modules.
  • You cannot download the software to your computer or on a desktop.
  • No more cons I have found for this software.

Design Beast OTOs/Upgrades

Here are the details of its upgrade, so that you can utilize all its advanced features. In this DesignBeast Review, I have mentioned the name and price of OTOs, and the rest of the details will be available soon.

Front End: DesignBeast Commercial

Price – $47 Onetime

  • Six Designs App For Price of One
  • Mockup Designer App
  • AI Logo Maker App
  • 1-Click Background Removal App
  • Live Motion Photos App
  • Multi-Purpose Image Editor App
  • Magic Object Removal App
  • 7000+ Ready-to-Use Templates
  • Millions of Royalty-Free Images
  • Copyright-Free Vectors & Icons
  • Hundreds of Fonts
  • Multi-Lingual Support
  • Step-by-Step Video Training
  • Commercial License
  • Sell The Designs For Profit
  • Facebook Group Access
  • Skype Mentorship Group Access
  • 8 Week Training Webinars

OTO#1: DesignBeast Elite

Price – $49 Onetime

Get access to additional features worth thousands. 10X your results, sales and profits and get ahead of the competition and other DesignBeast customers. 

  • Unlock 2,000 additional ready-to-use templates
  • Get 80 new templates added to your account each month for 1 year. (no monthly or yearly fees.)
  • Thousands of Premium Text Effects and Animations
  • Millions of Premium Royalty Free Design Assets, Icons and vectors.
  • Millions of Copyright-Free Image
  • Priority Future Software Updates

OTO#2: DesignBeast Agency

Price – $67

Sell videos for $300 to $500 each with the done-for-you agency package included. This upgrade makes it easy for everyone to find clients and sell their designs for top dollar. 

  • 5 sub accounts
  • Done-For-You Agency Marketing Bundle
  • Done-For-You Legal Client Contracts
  • Done-For-You Agency Website
  • Done-For-You Agency Sales Video

OTO#3: DesignBeast 4 in 1 Ultra.

Price – $39 OneTime

Customers get access to FOUR additional apps as part of this upgrade. 

  • Pixel Perfect
  • Instantly turn any image, even a low quality image, into ultra HD, high quality photo that can be blown up to any size – even billboard size – without any pixelation or distortion.
  • Animated Ads Builder 

Create animated ads in all languages, shapes and sizes using hundreds of ready to use design templates. Use animated ads to promote your products, create ads for clients or sell animated designs on freelancer websites like fiverr, upwork and freelancer to maximize profits. 

  • Video Resizer

With this powerful technology you can resize any video into multiple video sizes perfectly sized for all social platforms. Turn a single video into multiple dimensions and sizes within minutes and share the video onto different platforms to drive more traffic and sales!

  • Video Survey Pro

With this powerful app you can instantly collect:

* Video Testimonials

* Live video feedback from clients about your work

* Add video surveys on your websites to collect valuable information

* Have your team record video feedback about any project 

Streamline your workflows without any confusion or relying on old and outdated methods like email and text.  

OTO#4: DesignBeast Unlimited

Price $67 OneTime

With the DesignBeast basic license, you can create unlimited designs forever with one limit of 600 credits per month on each of the six apps included. 

The limits reset each month so you can continue creating amazing designs, graphics and animations forever without any monthly fees. 

This limit is put in place to prevent abuse and ensure all our customers are getting the best value for years to come at an unbeatable price.

As part of this special unlimited upgrade, you can remove all the monthly limits and restrictions for all the cutting-edge apps and technologies included. 

Design Beast Review Conclusion

From my take, this will be a good and useful tool for you if you belong to these above-mentioned professional categories. No matter you have advanced skills or not because everything will be DFY and ready to use. And the best thing is that you can customize and edit each and every pre-made effect, design, and more thing. According to my opinion, graphics designing software is ned for every marketer and business person, but everyone cannot go for photoshop, AI, and Coral, so for making it easy and useful there will be a choice in your hand that is DesignBeast.

CHECK BONUSES & GRAB IT AT: https://bit.ly/3yhtcqi

SOURCE: https://bit.ly/3Dch4KV