npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-devis

v1.3.9

Published

Scaffold out a devis project

Downloads

47

Readme

Devis generator

Check this playlist to see generator demos: https://www.youtube.com/playlist?list=PLXuIV4C_5YhI8dX2kFx8h414byI1_yAxM

#demos:

                           _-----_     ╭──────────────────────────╮
                          |       |    │     Welcome to devis     │
                          |--(o)--|    │  microservice framework  │
                         `---------´   │        generator!        │
                          ( _´U`_ )    ╰──────────────────────────╯
                          /___A___\   /
                           |  ~  |     
                         __'.___.'__   
                       ´   `  |° ´ Y `

Getting Started

What is Yeoman?

Yeoman helps you to kickstart new projects, prescribing best practices and tools to help you stay productive.

To do so, Yeoman provide a generator ecosystem. A generator is basically a plugin that can be run with the yo command to scaffold complete projects or useful parts.

Usage

Requirements:

Remember that Devis is based on devispattern that is an addon written in c ++.

It's necessary, before using Devis to install:

  • CMake(*.msi version for windows: You must check the addition of the path for all users, And restart your computer after installation)
  • A proper C/C++ compiler toolchain of the given platform
    • Windows:
    • Unix/linux-gnu:
      • Clang or GCC
      • Ninja or Make (Ninja will be picked if both present)
      • Xcode with command line tools if you are under mac os Installation
npm install -g yo generator-devis

Or, if you upload the project

Install both yeoman and the generator:

npm install -g yo generator-generator

Setup a generator project:

yo generator

Link the generator in the global node modules:

npm link

Navigate to a folder you would love to scaffold a new project and run:

yo devis

What is Generator-devis?

we will define each part of the generator as a tree

       |.app        |-->.script        |---->.script.js

  • generate local depencies on different microservices and run server you can customise the code if you want for example use different microservice remotely not localy.

       |---->You can add other scripts there        |-->.root.js

  • it is here where will be added the different microservices locally or as a client |-->.route
  • it is in this folder, where will the different routes associated to each model,where will be implemented and evaluated the different functions that you will use in the index file. By default every route file contains the functions put, get, post and delete to express routing framework.

|-->.client.json

  • If you intended to consume distance microservices you should add here the necessary information For each Microservice and the script that i described previously will handle these microservices by adding them to the root file. |.microservices
  • You will add there your different microservices |-->.Micro1 |---->.main.js
  • It's the core of your Microservice where you will define the different properties, but for clarity, you will only define the properties here, the callback functions will be reported elsewhere in the libs folder. |---->.libs
  • Example:

If your Microservice is model called and contains properties: GET and Post then your main.js will be like that:

let model = require("devis");
let model_f = require("./libs/functions");

model.add({
        role: "model",
        action: "GET"
    },
    model_f.GET);

model.add({
    role: "model",
    action: "POST"
}, model_f.POST);
module.exports = model;

And the functions file will be something like that:

function POST(args, done) {
   //do something
        done(null,finalresult);
    }
function GET(args, done) {
   //do something
        done(null,finalresult);
    }
module.exports={
	    POST:POST,
	    GET:GET
	}

       |---->.confs        |------>.core.js

  • If you want your Microservice to be used remotly too you should do like the two available microservices by adding the dependencies in the file depencies if you have. |.index

  • it is here or you'll exploit your different microservices.

  • This video will explain how to generate the scaffold: https://www.youtube.com/watch?v=Alw7Azklcvc&list=PLXuIV4C_5YhI8dX2kFx8h414byI1_yAxM&index=1

Using the project

Once installed, you can start creating microservices by using devis framework. You can rely on both microservices that already exist in the project: model and authentification.

After, you should add your microservices to the file root.js, located in the folder app. Fortunately there already a script that will perform this task in your place , you just have to run the command :

npm install
devis generate

If you just wanna test both existing microservices, you should install [ wakanda ] ( https://wakanda.github.io ), add one or more tables , a use, change login and password on app/wakanda_config.js and launch

npm install
devis generate
devis start

The script will generate automatically the file root.js: use both microservices and launch the server. By running the index file you will consume the server and log in wakanda.

Use devis command line

If you are using Mac OS or GNU/LINUX:

The devis command are in app folder.

As root user, run this command inside your project folder:

sudo mv app/devisCommand/GNU_UNIX/devis /usr/bin

On windows:

Setting the path and variables in Windows :

  • From the Desktop, right-click the very bottom left corner of the screen to get the Power User Task Menu.

  • From the Power User Task Menu, click System.

  • Click the Advanced System Settings link in the left column.

  • In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab.

  • In the Environment Variables window (pictured below), highlight the Path variable in the "System variables" section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon as shown below.

  • new and select the app/devisCommand/windows folder and restart your computer.

Log file

If you want to know handles that a Microservice offers, like model , you just have to write the following command:

devis get microservices/model/main

If this microservice are distant, for example

var devis=require("devis");

devis.add({
  action: 'game',
  cmd:'play'
}, function(args, done) {

  done(null,{ result: 'play' });
});
devis.add({
  action: 'game',
  cmd:'pause'
}, function(args, done) {

  done(null,{ result: 'pause' });
});
devis.listen({
  host:'127.0.0.1',
  port:3030
})

You should run

devis get connect port : '3030' , host : "127.0.0.1"

Don't forget space between each argument!

A file will be created under the name devis-log.txt or you will find all the information regarding this Microservice.

###Generate microservice scaffold If you want to generate a scaffold of Microservice you should run the following command:

devis create microservice_name
  • This video will explain how to use the default wakanda restfull api: https://www.youtube.com/watch?v=qghZtKiTyKw&list=PLXuIV4C_5YhI8dX2kFx8h414byI1_yAxM&index=2

##Use MongoDB and Angular If you want use mongodb and angular in your application you have just to write some simple commands: For example, you wanna create an application who will manage user posts.

So you need 2 schemas users and posts

we suppose that the database name is "myapp" First you should implement the data.json :app/database/data.json:

{
    "user": {
        "firstname": {
            "type": "String",
            "unique": "true",
            "required": "true"
        },
        "lastname": {
            "type": "String",
            "unique": true,
            "required": true
        },
        "updated_at": {
            "type": "Date",
            "default": "Date.now"
        }
    },
    "post":{
      "name":"String",
      "text":"String",
      "user_id":"String",
      "updated_at": {
          "type": "Date",
          "default": "Date.now"
      }
    }
}

After you have to run this commands:

devis db mongo
devis db add user
devis db add poste
devis db generate myapp

devis db mongo will add mongo folder to database and devis add user will generate the user data file on mongo folder and add user route file to the route folder and generate user folder on public with index.html and finaly add user angular controller to controllers folder under public folder.

After that,index.js will be implemented by using mongodb micorservice and user,poste schema. Inside views folder you will see 2 folders user and post with "html" files to implement for edit, add and index for each schema. Implement route methods inside app/route/user.js and app/route/post.js and angular methods inside public/controllers/user.js and public/controllers/post.js, after implementing the necessary microservices for User and post. And that's it! you have a complete and powerfull application with minimum effort in minimum time!

  • You can see the lirary example in generator-devis example for more information

  • This video will explain how to use mongoDb in your application: https://www.youtube.com/watch?v=p6uOOyJV35o&index=3&list=PLXuIV4C_5YhI8dX2kFx8h414byI1_yAxM