Skip to content

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

License

Notifications You must be signed in to change notification settings

booscaaa/cleanv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: boscardinvinicius@gmail.com

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: boscardinvinicius@gmail.com

Connect with me at LinkedIn

Thank you!

License

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages