Neglected Pulse Machine

    This package has been deprecated

    Author message:

    Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

    swarm-host-cli

    3.1.0 • Public • Published

    Swarm-Host-CLI

    CI Codacy Badge npm version

    CLI for Swarm-Host

    Install:

    npm i -g swarm-host-cli

    Usage:

    Create a new project (works in the empty dir):

    swarm-host init

    Create a new Route:

    swarm-host g route units

    File routes/units.ts will be created. Its content:

    // routes/units.ts
    import {Route} from 'swarm-host';
    
    export default Route.createRoute('get', 'units', (req, res, next, lair) => {
      res.json({});
    });

    Create a new Route with options:

    swarm-host g route units/new --url=api/v1/units --method=post

    File routes/units/new.ts will be created. Its content:

    // routes/units/new.ts
    import {Route} from 'swarm-host';
    
    export default Route.createRoute('post', 'api/v1/units', (req, res, next, lair) => {
      res.json({});
    });

    Create a new Route with dynamic parts:

    swarm-host g route units/unit/objectives/objective --url=units/:unit_id/objectives/:objective_id

    File routes/units/unit/objectives/objective.ts will be created. Its content:

    //routes/units/unit/objectives/objective.ts
    import {Route} from 'swarm-host';
    
    export default Route.createRoute('get', '/units/:unit_id/objectives/:objective_id', ({params: {unit_id, objective_id}}, res, next, lair) => {
      res.json({});
    });

    Create a new Factory:

    swarm-host g factory my/unit

    File factories/my/unit.ts will be created. Its content:

    // factories/my/unit.ts
    import {Factory} from 'swarm-host';
    
    export default Factory.create({
      name: 'unit',
      attrs: {
      }
    });

    Create a new Factory with attributes:

    swarm-host g factory my/unit name:string squad:has-one:squad:units objectives:has-many:objective

    File factories/my/unit.ts will be created. Its content:

    // factories/my/unit.ts
    import {Factory} from 'swarm-host';
    
    export default Factory.create({
      name: 'unit',
      attrs: {
        name: Factory.field({
          value() {
            return '';
          },
          preferredType: 'string'
        }),
        age: Factory.field({
          value() {
            return 0;
          },
          preferredType: 'number'
        }),
        objectives: Factory.hasMany('objective', null),
        squad: Factory.hasOne('squad', 'units'),
      }
    });

    Destroy existing Factory

    swarm-host d factory units

    File factories/units.ts will be deleted.

    Destroy existing Route

    swarm-host d route units

    File routes/units.ts will be deleted.

    Install

    npm i swarm-host-cli

    DownloadsWeekly Downloads

    12

    Version

    3.1.0

    License

    MIT

    Unpacked Size

    32.8 kB

    Total Files

    51

    Last publish

    Collaborators

    • onechiporenko