New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@hapify/generator

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapify/generator

Generator for Hapify templates

npmnpm
Version
0.8.0
Version published
Weekly downloads
24
100%
Maintainers
2
Weekly downloads
 
Created
Source

Hapify Generator

Description

This package allows you to generate code using Hapify models and Hapify or JavaScript code templates.

Build Status codecov

Usage

import { Generator } from '@hapify/generator';

const templates = [
    {
    	path: '/path/to/{snake}',
    	engine: 'hpf',
    	input: 'one',
        content: 'Camel case is <<Model camel>>.',
    }
];
const models = [
    {
        id: 'bdc6c58e-ec49-9193-6b29-6c75518bc3ad',
        name: 'Place bookmark',
        notes: 'A user can only list its own bookmarks',
        fields: [
            {
                name: '_id',
                notes: null,
                type: 'string',
                subtype: null,
                value: null,
                primary: true,
                unique: false,
                label: false,
                nullable: false,
                multiple: false,
                embedded: false,
                searchable: false,
                sortable: false,
                hidden: false,
                internal: true,
                restricted: false,
                ownership: false
            }
        ],
        accesses: {
            create: 'auth',
            read: 'owner',
            update: 'admin',
            remove: 'owner',
            search: 'owner',
            count: 'owner'
        }
    }
];

// Get path & content
Generator.run(templates, models)
    .then(results => {
        // [{ path: '/path/to/place_bookmark', content: 'Camel case is placeBookmark' }]
    });

// Get path only
const path = Generator.path('/path/to/{camel}', models[0]); // '/path/to/placeBookmark'

More

For more information about this module, please refer to the online documentation.

Keywords

hapify

FAQs

Package last updated on 29 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts