Code Monkey home page Code Monkey logo

tutorial-workspace's Introduction

tutorial-workspace

tutorial-workspace is a basic workspace based on template-workplace and contains the following applications:

  • a simple TODO application - A simple todo application. Included from ssapp-minimal-app
  • a simple "Hello World! DSU" - a small tutorial aiming to show how you can use DSU to save and load data.

Notes:

  • A workspace is a project with many other libraries and configuration loaded.
  • We will use ${workSpaceRoot} for the workspace folder
  • An included application means that the original code is in a separate repo but got included here (either by hard copy or brought in by git's clone commands)

Prerequisites

You need the following software installed on your machine in order to continue the this guide

  1. Install or update Node (including NPM) to version 14.15 .
  2. Install or update Git

Installation

The only commands you need to run in the tutorial-workspace workspace are:

# Step 1: Clone tutorial-workspace from GitHub
git clone https://github.com/PrivateSky/tutorial-workspace.git

# Step 2: Go inside the [tutorial-workspace] folder
cd tutorial-workspace

# Step 3: Brings all dependencies needed by a developer to have an working setup
$ npm run dev-install

# Step 4: Launch the Node js  
$ npm run server

# Step 5: Note: Run this in a separate console! Scans all applications and wallet it finds in the configuration and tries to run the build script for each one
$ npm run build-all

After all this steps are done, you can access the tutorial application by going to http://localhost:8080/tutorial/loader/

Hello World! DSU Tutorial

This tutorial sub project helps you understand how you can work directly with DSUs.

The code for this tutorial is in [helloworld-dsu] folder. It consist of only one file main.js

To FIRST run it simply run the steps found in the [Installation] section above then:

# Step 1: Go inside [helloworld-dsu]
cd helloworld-dsu

# Step 2: Run the app
node main.js

You should get something like:

....
Data written succesfully! :)
KeySSI identifier:  BBudGH6ySHG6GUHN8ogNrTWbZHtTCUHnMvP5Un8LrUFrdb2yDx3pbh85gMdLgEAoex6rX86B9dY5Fscjx77uMcfmh
Data load succesfully! :) Hello world!
....

Hello World! Wallet & SSAPP Tutorial

This tutorial sub project helps you understand how you can create a simple SSAPP and a Wallet from scratch.

The code for this tutorial will end up in [helloworld-ssapp] folder.

To FIRST run it simply run the steps found in the [Installation] section above then follow these steps:

Let's start to create our first SSApp based on a template

# 0. Verify to be in the root folder of our workspace

# 1. Clone the template repo
git clone https://github.com/PrivateSky/ssapp-template.git helloworld-ssapp

# 2. Go inside it, remove .git folder and bring dependencies and exit back the folder
cd helloworld-ssapp && rm -rf .git && npm install && cd ..

# 3. Bind newly helloworld-ssapp to new wallet 
npm run bind-wallet helloworld-wallet helloworld-ssapp 

# 4. Prepare a loader for our newly wallet
npm run add-loader apihub-root/helloworld-wallet/loader https://github.com/PrivateSky/trust-loader 

# 5. Configure the loader 
cp -r trust-loader-config/tutorial trust-loader-config/helloworld-wallet

# 6. Rebuild the rest of the workspace
npm run build-all

Let's test our Wallet and SSApp

Open http://localhost:8080/helloworld-wallet/loader/ in a new Incognito Chrome browser (Ctr+Shift+N)

Develop more our newly SSApp

To continue with the development of the newly created SSApp and Wallet please refer to the PrivateSky, OpenDSU and Webcardinal documentation websites.

tutorial-workspace's People

Contributors

alexgheorghiu avatar asaccool avatar atravelingn3rd avatar denypatrascu avatar irimiacosmin avatar skutner avatar vassia38 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tutorial-workspace's Issues

Cloud Master - Private Sky

Buna ziua,

Ati spus ca putem sa va deranjam daca avem intrebari.

Am crezut ca am reusit in weekend sa fac un breakthrough. Am zis sa iau chiar cel mai basic approach si sa fac un calendar app cu events. Am reusit sa fac sa mearga calendarul dar dupa ce m-am uitat pe documentatia la PrivateSky(PS) si am vazut ca aveti o coada de mesaje VirtualMQ si sper ca am inteles - porneste odata cu procesele main din PS. Apoi, bazat pe documentatia la VirtualMQ si am vazut ca aveti niste rute REST-like, similar cu endpoints, precum /mq/create-channel/:anchorId.

Ce nu am inteles este: la ce port sau host (banuiesc ca localhost) ma conectez sa am access la acest VirtualMQ? Si ce reprezinta acel anchorId? Am cautat prin cod exemple, am vazut cateva js-uri ce pareau teste si se conectau la 127.0.0.1:9500, am incercat si eu hostul asta din postman, dar nu a mers, in sensul ca nu gasea un server la adresa respectiva. Realizez ca sunt mai incet de felul meu, dar aveti cumva un exemplu sau sa ma indrumati putin spre ceva, cum ma pot conecta la VirtualMQ si sa scriu/citesc din el. Vreau sa il folosesc ca sa pot face etapa de calendar care face share intre utilizatori. Practic cand cineva face o modificare in calendar sa scrie in VirtualMQ la un topic si cand altcineva porneste aplicatia sa citeasca din VirtualMQ si sa citeasca din topicul respectiv si sa randeze calendarul. Oare pot face asta? E vreo logica in attemptul asta?

Daca nu โ€“ cum ati face sincronizarea de evenimente? Aveti vreo sugestie/exemplu?

Am incercat sa trimit pe mail la [email protected] - dar nu exista adresa de mail.

Ssapp - import storage strategy

Am incercat aseara sa imi faca o instanta de basicDB, dar din ce vad pe documentatie trebuie sa ii dau argument un Storage strategy. M-am uitat prin codul de privatesky, unde se mai folosesc basicDB-uri si am vazut ca ceva de genul asta trebuie:

    let MemoryStorageStrategy = require("../../../db/storageStrategies/MemoryStorageStrategy");
    let storageStrategy = new MemoryStorageStrategy();
    let mydb = db.getBasicDB(storageStrategy);

Dar din ce vad - acest MemoryStorageStrategy - e din openDSU. Asa ca am incercat si eu in aplicatia mea sa dau let MemoryStorageStrategy = require("MemoryStorageStrategy");, dar imi da eroare. Asa ca am luat fisierul de MemoryStorageStrategy.js din openDSU si l-am pus in bundles la ssapp-ul meu si am facut refference din index.html asa:

    <script src="scripts/bundles/pskruntime.js"></script>
 ---->   <script src="scripts/bundles/MemoryStorageStrategy.js"></script> <----


    <!-- local imports -->

Tot primeasc o eroare de genul:

p-df4c668a.entry.js:1 Error while loading controller "ExampleController" Error: Failed to load module MemoryStorageStrategy
    at tryRequireSequence (iframeBoot.js:26001)
    at global.require (iframeBoot.js:26019)
    at new ExampleController (ExampleController.js:25)
    at m.loadController (VM12572 p-9b0f394c.entry.js:1)
    at async m.componentWillLoad (VM12572 p-9b0f394c.entry.js:1)

Ma puteti ajuta cu un hint pentru a importa un strategy de storage din ssapp-ul meu - cat sa pot sa am un obiect de basic db? Intuiesc ca un shared db ar fi fost mai ok pentru tema, dar din ce vad overheadul de a crea unul e un pic mai mare si ma voi multumi cu un basic db pentru moment - sa stochez calendar events.

Open DSU - Ssapp import

AM incercat sa incarc open dsu din controllerul aplicatiei mele, in acest mod:

const { Controller } = WebCardinal.controllers;
require("../privatesky/psknode/bundles/openDSU");

export default class MyController extends Controller {
...
}

am modificat si fiserul de build octopus la sectiunea dependinte astfel incat sa am privatesky:

{
  "workDir": ".",
	"dependencies": [
		{
			"name": "privatesky",
			"src": "http://github.com/privatesky/privatesky.git"
		}
	],

dar cand intru in aplicatia mea din din local http://localhost:8080/tutorial/loader/ primesc urmatoarea eroare care este - din ce inteleg eu - pentru ca nu poate incarca open dsu

Error while loading controller "MyController" TypeError: (intermediate value) is not a constructor
    at m.loadController (VM792 p-9b0f394c.entry.js:1)
    at async m.componentWillLoad (VM792 p-9b0f394c.entry.js:1)

M-am uitat pe exemplul dumneavoastra din helloworld-dsu, si am vazut ca acel require pare sa fie absolut, am incercat sa fac si eu un require absolut la opendsu din controllerul meu

require("../../../../privatesky/psknode/bundles/openDSU");

si, la fel, aceeasi eroare ca mai sus. Am vazut ca in octopus aveti "workingDir": "." si am pus si asa:

require("./privatesky/psknode/bundles/openDSU");

La fel, acceasi eroare. Eu aveam nevoie de opendsu pentru ca am vazut in documentatia de db de aici: https://opendsu.com/?dev-doc/rfc060.html , punctul 1. cu load database ca aceasta ar fi structura. Voiam sa folosesc api-ul de db din open dsu pentru storage.

Am mai sapat prin codul proiectului private sky si am gasit intr-un serviciu din aplicatia de todo o referinta la un DSUStorage, mai exact:

---> import DSUStorage from "/webcardinal/base/libs/DSUStorage.js"; <---

class TodoManagerService {

    constructor() {

M-am uitat putin pe codul sursa al lui DSUStorage si am vazut ca ofera implementari pentru apiurile de storage descrise si in curs. Am incercat sa salvez o valoare, pare ca a fost successful (am folosit DSUStorage.saveItem(...), dar la retrieve am incercat si cu DSUStorage.getObject() cat si cu DSUStorage.getItem()). DSUStorage.getObject imi returneaza undefined, m-am uitat si pe codul metodei si pare ca comportamentul acesta sa fie hardcodat in ea, iar a doua DSUStorage.getItem imi da internal server error din consola de chrome/opera/firefox.

Am mai sapat putin prin codul clasei utilitare DSUStorage si am vazut ca are o metoda de enableDirectAccess care ia ca argument un lambda, am incercat sa o apelez dar cand o apelez imi da aceeasi eroare de import de open dsu ca cele descrise mai sus, pentru ca metoda are in implementarea ei referinta la open dsu:

class DSUStorage {
    constructor(height, width) {
      this.directAccessEnabled = false;
    }

  enableDirectAccess(callback){
    let self = this;

    function addFunctionsFromMainDSU(){
      if(!self.directAccessEnabled){
       -----> let sc = require("opendsu").loadAPI("sc"); <-----
        let availableFunctions = [

Ma puteti ajuta cu un hint la importul open dsu in un SSApp, m-am uitat pe documentatia proiectului, cat si prin cod, si va rog sa imi scuzati neatentia, dar nu am reusit sa inteleg cum se face.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.