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

vue-backend-block

v1.0.3

Published

Use in single-component vue components, blocks for your backend

Downloads

2

Readme

vue-backend-block

webpack loader and plugin for Vue Single-File Components use Custom Blocks as backend part

What is vue-backend-block?

vue-backend-block is a loader and plugin that allows you to embed part of your backend logically connected to the single-file component in a separate block. Learn more about custom blocks.

Installing vue-backend-block:


npm i vue-backend-block

Webpack plugin configuration

  • import plugin:
const vue_backend_block = require("vue-backend-block/plugin.js");
  • configure plugin:
plugins: [
    new vue_backend_block ({
        backend_template:   path.join(__dirname, "web_server_template.js"),
        backend_output:     path.join(__dirname, "services", "web_server.js"),
    }),
]

| options name | type | default | example | description| | --------------- |---------------|----------------------|--------------------------|------------------| | backend_template| string | - | './web_server_template.js' | Backend pattern path | | backend_output| string| - | './web_server.js'|Assembled backend from custom block .vue |


Webpack loader configuration

rules: [
    {
        resourceQuery: /blockType=backend/,
        loader: 'vue-backend-block'
    },
],

where blockType=backend - backend name of your custom block


What does the template contain ([backend_template] option)

  • Sample template:
const WEB_PORT = 314;

const Koa = require('koa');
var Router = require('koa-router');

const app = new Koa();
var router = new Router();

app
    .use(router.routes())
    .use(router.allowedMethods());

const body = require('koa-json-body')({ limit: '10kb' });

app.listen(WEB_PORT);

app.context.db = require('../lib/db.js');
/*{{endpoints}}*/

All parts from Custom Blocks will be inserted instead of: /*{{endpoints}}*/


Sample content of the single-file component vuejs

<template>

</template>

<script>
    export default {
        name: 'example',
        data() {
            return {
            }
        },
        methods:{
        }
    }
</script>

<style>
</style>

<backend>
    router
        .post('/reg/', body, async (ctx, next) => {
            try {
                let r = ctx.request.body;

                console.log(ctx.request.body.name);
                await ctx.db.getConnection();
                ctx.body = await ctx.db.db_query(`CALL users_reg('${r.name}', '${r.last_name}', '${r.mail}', '${r.pass}')`);
            } catch (err) {
                throw err;
            } finally {
                await ctx.db.end();
            }
        });
</backend>

Syntax Highlight in Custom Blocks for PhpStorm Editor

By default, syntax highlighting in Custom Blocks in PhpShtorm does not work. In order for everything to work, you need to do the following:

File -> Settings -> In the search box, type: injections

image

Add new Specify ID and local name

image

After these settings you should have something similar.

image