Cleanv - Golang SDK for Vue Projects. It is able to structure a clean code/arch pattern

Cleanv - Golang SDK for Vue Projects

Reference Release Software License Test status Coverage


Why?

This project is part of my personal portfolio, so, I'll be happy if you could provide me any feedback about the project, code, structure or anything that you can report that could make me a better developer!

Email-me: [email protected]

Connect with me at LinkedIn.


Functionalities

  • Creating a standard development framework
  • Creating separate files within existing code structures
  • Automatically update

Starting

Installation


Download the library and configure it in the path/environment variables of your operating system


Linux:

mv ~/Downloads/cleanv /usr/local/cleanv/
nano ~/.bashrc

# paste the line below at the end of the file
PATH=$PATH:/usr/local/cleanv

# give general permissions on the folder
sudo chmod 777 /usr/local/cleanv

# reload bash info
source ~/.bashrc

# add autocomplete in bash
cleanv completion bash > /tmp/completion
source /tmp/completion

Windows:



The initial struct of vue app code like this:

Struct1



With commands

cleanv template


This command will generate the complete structure for developing a new program on the web.

Positioned in the root of the project with vue.js run the command:

cleanv template -s payment001 -m payment -r findPayment

Prompt1


cleanv repository


This command will generate the structure of a new api call within a ready-made structure. Importing and injecting dependencies if necessary.

Positioned in the root of the project with vue.js run the command:

cleanv repository -s payment001 -m payment -n findTickets

Prompt1



Caution!!! Using the -d flag will delete the corresponding files.

cleanv repository -s screen_name -m module_name -n findSomething1 -d

cleanv update


This command updates the sdk binary automatically;

cleanv update



Examples of code struct generation

cleanv template -s payment001 -m payment -r findPayment
- module
  - payment
    - payment001
      - di
        - di.js
        - axios.js
      - controller
        - paymentController001.js
      - data
        - repository
          - findPaymentRepository.js
      - domain
        - model
          - payment001.js
        - usecase
          - findPaymentUseCase.js
      - view
        - payment001.vue
//Repository
const findPaymentRepository = (axios) => async () => {
  try {
    const response = await axios.get('/rest/TODO')
    return response //TODO
  } catch (error) {
    throw error
  }
}

export default findPaymentRepository
//Usecase
const findPaymentUseCase = (repository) => async () => {
  try {
    //TODO
    return await repository()
  } catch (error) {
    throw error
  }
}

export default findPaymentUseCase
//Model
class Payment001 {
    constructor() {}
}

export default Payment001
//Dependencie Injection
import axiosInstance from './axios'

import findPaymentRepository from '../data/repository/findPaymentRepository'
import findPaymentUseCase from '../domain/usecase/findPaymentUseCase'

import Payment001Controller from '../controller/payment001Controller'

const instance = axiosInstance

const findPaymentRepositoryImpl = findPaymentRepository(instance)
const findPaymentUseCaseImpl = findPaymentUseCase(findPaymentRepositoryImpl)

const payment001Controller = (context) =>
  new Payment001Controller(
    context,
	  findPaymentUseCaseImpl,
  )

export { payment001Controller }
//Axios instance for Dependencie Injection
import axios from 'axios'

const axiosInstace = axios.create({
  baseURL: process.env.VUE_APP_API_BASE_URL,
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    Access: 'application/json',
  },
})

export default axiosInstace
//Controller
class Payment001Controller {

  constructor(
    context,
    findPaymentUseCase,
  ) {
    this.context = context
    this.findPaymentUseCase = findPaymentUseCase
  }

  async mounted() {
    try {
      //TODO
    } catch (error) {
      //HANDLER ERROR
    }
  }
}

export default Payment001Controller
//Vue Screen
<template>
  <div>
    <!-- your code here -->
  </div>
</template>

<script>
import { payment001Controller } from "../di/di";
export default {
  data: (context) => ({
    controller: payment001Controller(context),
  }),
  mounted() {
    this.controller.mounted();
  },
};
</script>

Adding new repository

cleanv repository -s payment001 -m payment -n findTickets
- module
  - payment
    - payment001
      - di
        - di.js
        - axios.js
      - controller
        - paymentController001.js
      - data
        - repository
          - findPaymentRepository.js
          - findTicketsRepository.js
      - domain
        - model
          - payment001.js
        - usecase
          - findPaymentUseCase.js
          - findTicketsUseCase.js
      - view
        - payment001.vue
//Repository
const findTicketsRepository = (axios) => async () => {
  try {
    const response = await axios.get('/rest/TODO')
    return response //TODO
  } catch (error) {
    throw error
  }
}

export default findTicketsRepository
//Usecase
const findTicketsUseCase = (repository) => async () => {
  try {
    //TODO
    return await repository()
  } catch (error) {
    throw error
  }
}

export default findTicketsUseCase
//Dependencie Injection
import axiosInstance from './axios'

import findTicketsRepository from '../data/repository/findTicketsRepository'
import findTicketsUseCase from '../domain/usecase/findTicketsUseCase'

import findPaymentRepository from '../data/repository/findPaymentRepository'
import findPaymentUseCase from '../domain/usecase/findPaymentUseCase'

import Payment001Controller from '../controller/payment001Controller'

const instance = axiosInstance

const findTicketsRepositoryImpl = findTicketsRepository(instance)
const findTicketsUseCaseImpl = findTicketsUseCase(findTicketsRepositoryImpl)


const findPaymentRepositoryImpl = findPaymentRepository(instance)
const findPaymentUseCaseImpl = findPaymentUseCase(findPaymentRepositoryImpl)


const payment001Controller = (context) =>
  new Payment001Controller(
    context,
		findTicketsUseCaseImpl,
    findPaymentUseCaseImpl,
  )

export { payment001Controller }
//Controller
class Payment001Controller {

  constructor(
    context,
    findTicketsUseCase
    findPaymentUseCase,
  ) {
    this.context = context
    this.findTicketsUseCase = findTicketsUseCase
    this.findPaymentUseCase = findPaymentUseCase
  }

  async mounted() {
    try {
      //TODO
    } catch (error) {
      //HANDLER ERROR
    }
  }
}

export default Payment001Controller

Contributing

You can send how many PR's do you want, I'll be glad to analyze and accept them! And if you have any question about the project...

Email-me: [email protected]

Connect with me at LinkedIn

Thank you!

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Owner
Vinícius Boscardin
Challenges lover! 8 years of experience with software development. My current stack is Golang, Vue.js, Flutter, Docker, PostgreSQL, CI/CD, TDD, AWS, GCP, Digit
Vinícius Boscardin
Similar Resources

Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Mar 19, 2022

Fedora-new-install - Utility scripts for a clean fedora installation

fedora-new-install Utility scripts for a clean fedora installation new-install.g

Nov 8, 2022

Sample CDK projects developed by AWS Professional Services (ProServe)

AWS CDK Examples - ProServe This repository contains a set of CDK example projects which have been developed by AWS Professional Services (ProServe).

Dec 27, 2022

A Package Searching and Installation tool for Go Projects

A Package Searching and Installation tool for Go Projects

psearch A Package Searching and Installation tool for Go Projects. Installation

Dec 22, 2021

Repo for working on Cloud-based projects in Go

GoCloud Repo for working on Cloud-based projects in Go AWS checkout SDK: https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/s3 cd into /ho

Jan 10, 2022

A Golang SDK for Medium's OAuth2 API

Medium SDK for Go This repository contains the open source SDK for integrating Medium's OAuth2 API into your Go app. Install go get github.com/Medium/

Nov 28, 2022

Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)

simples3 : Simple no frills AWS S3 Library using REST with V4 Signing Overview SimpleS3 is a golang library for uploading and deleting objects on S3 b

Nov 4, 2022

Twilight is an unofficial Golang SDK for Twilio APIs

Twilight is an unofficial Golang SDK for Twilio APIs

Twilight is an unofficial Golang SDK for Twilio APIs. Twilight was born as a result of my inability to spell Twilio correctly. I searched for a Twillio Golang client library and couldn’t find any, I decided to build one. Halfway through building this, I realized I had spelled Twilio as Twillio when searching for a client library on Github.

Jul 2, 2021

weixin/wechat/微信公众平台/微信企业号/微信商户平台/微信支付 go/golang sdk

weixin/wechat/微信公众平台/微信企业号/微信商户平台/微信支付 go/golang sdk

wechat SDK for golang https://github.com/chanxuehong/wechat 招人啦 golang 后端的坑, 趣头条集团下面的创新团队, 现在步入正常轨道了, 前景很好. 要求: golang中高级 自驱、有责任心 沟通没有问题 待遇: open, 看能力

Dec 30, 2022
A Simple Anonym FileSharing Service which is able to be render in the Browser and in an Terminal-Client

FileSharingService A Simple Anonym FileSharing Service which is able to be render in the Browser and in an Terminal-Client How to use Take a look in t

Dec 25, 2022
A go sdk for baidu netdisk open platform 百度网盘开放平台 Go SDK

Pan Go Sdk 该代码库为百度网盘开放平台Go语言的SDK

Nov 22, 2022
Nextengine-sdk-go: the NextEngine SDK for the Go programming language

NextEngine SDK for Go nextengine-sdk-go is the NextEngine SDK for the Go programming language. Getting Started Install go get github.com/takaaki-s/nex

Dec 7, 2021
Commercetools-go-sdk is fork of original commercetools-go-sdk

commercetools-go-sdk The Commercetools Go SDK is automatically generated based on the official API specifications of Commercetools. It should therefor

Dec 13, 2021
Sdk-go - Go version of the Synapse SDK

synapsesdk-go Synapse Protocol's Go SDK. Currently in super duper alpha, do not

Jan 7, 2022
Redash-go-sdk - An SDK for the programmatic management of Redash, in Go
Redash-go-sdk - An SDK for the programmatic management of Redash, in Go

Redash Go SDK An SDK for the programmatic management of Redash. The main compone

Dec 13, 2022
A demonstration of the transactional outbox messaging pattern (+ Log Trailing) with Amazon DynamoDB (+ Streams) written in Go.
A demonstration of the transactional outbox messaging pattern (+ Log Trailing) with Amazon DynamoDB (+ Streams) written in Go.

Transactional Outbox Pattern in Amazon DynamoDB A demonstration of the transactional outbox messaging pattern (+ Log Trailing) with Amazon DynamoDB (+

Apr 12, 2022
Expand host pattern to host list.

expandhost Expand host pattern to host list. E.g.: Expand foo[01-03,06,10-12].[beijing,wuhan].bar.com, the result will be as follows: []string{ "f

Dec 24, 2021
This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event.

observer This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event. Usage go get githu

Nov 16, 2022
Aws-cdk-go-examples - Example projects using the AWS CDK by Golang

aws-cdk-go-examples Example projects using the AWS CDK by Golang Useful commands

Nov 24, 2022