Giter Club home page Giter Club logo

todolist-on-herbs's Introduction

Node.js CI

What's Herbs?

Herbs is an open source library for backend applications. It is focused on achieving faster deliveries and with happier developers, without neglecting the long-term need to constantly evolve your application as requirements change.

See more on the website: https://herbsjs.org/

Getting Started with TO DO list on Herbs

Within this repository, you will find a front-end application, made in react consuming a back-end application, using Herbs, the API is made in graphQL

Todolist on Herbs

This is a example on how to build a backend application using Herbs.

Live example Herbs Shelf

Using

$ npm install
$ npm run knex:migrate
$ npm start

You should receive this message => πŸš€ Server UP and Running in port: 4000

VSCode launchers (launch.json) are also available.

Postgresql setup

  1. Change knexfile.js and src\infra\config\dev.json connection info.

  2. Run migration:

$ npx knex migrate:latest --env development

Herbs Shelf

View all the use cases and its steps in just one place.

Herbs Shelf: http://localhost:4000/herbsshelf

Documentation dynamically generated by herbsshelf.

GraphQL

GraphQL Playground: http://localhost:4000/graphql

GraphQL dynamically generated by herbs2gql.

Rest

Express routes dynamically generated by herbs2rest.

Herbs REPL

View all the use cases your termnal.

$ node ./src/infra/repl

REPL dynamically generated by Herbs REPL.

Settings

Environment:

.env.{environment} files.

Rename one of the files to just .env.

Default is dev. Also check for HERBS_EXCEPTION env variable.

Config:

Edit /backend/infra/config/{environment}.json files if necessary.

Diagram

classDiagram
    class Item {
        Number id
        String description
        Boolean isDone
        Number position
    }
    class ToDoList{
        Number id
        String name
        Item[] items
        isEmpty()
        lastPosition()
    }

    ToDoList "1" --> "*" Item

How to contribute

If you would like to help contribute to this repository, please see CONTRIBUTING

License

todolist-on-herbs's People

Contributors

alavortx avatar dalssoft avatar dependabot[bot] avatar endersoncosta avatar gabrielmellooliveira avatar italojs avatar jhomarolo avatar jhomarolo-vortx avatar juliadibo avatar m7vicente avatar m7vicente-vortx avatar maikmb avatar maikvortx avatar nathalia45 avatar rodrigodosanjosoliveira avatar vitorgamer58 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

todolist-on-herbs's Issues

Add getAll lists in backend

We already have a feature that can get lists by their own ids, would it be a nice ideia to create a query to get all lists?

Delete list in SPA

Implement the functionality of deleting a list in the SPA using the DeleteList usecase

Implement a SPA front-end

Create a simple SPA to start consume the API and have a nice UI.
Should it be a completely separate project or a directory on the root folder works (back-end/front-end)?

Adjust the main read me file

Write a new main read me explaining the complete project

  • how to use
  • front end stack + link to read me
  • back end stack + link to read me

Layout and Design

I believe that the project can include a simple layout with a good design, but that shows the real potential of the project.

What about herbs CLI ?

Herbs CLI

Inspired by VueJS, Angular, dotnet and others, I would like to suggest the creation of a CLI to help the new herbs adopters

Usually developer use CLIs to easily start an project and principally the jr developers use it to maintain the project in the same architecture proposed by the framework.

The main idea of this CLI is to facilitate the creation of new projects and modules in your project that use herbs. In the future I believe this CLI can be an tool to check your herbs quality code, help you to modeling your clean archtecture, analisy logs and more, but for now it will start being something like a semi-inteligent code generator.

Herbs start

Propose 1

My initial propose is to build an entry project by the CLI like an template

Herbs new app -β€”graphql -β€”knex-pg (We can use --rest --mongo --knex-sql-server and other)

This will create an app with graphql that use a knex-repository, the generated files will be something like this:

β”‚Β Β  β”œβ”€β”€ herbs.json
β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β  β”œβ”€β”€ knexfile.js
β”‚Β Β  β”œβ”€β”€ package.json
β”‚Β Β  └── src
β”‚Β Β      β”œβ”€β”€ domain
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ entities
β”‚Β Β      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ entity.js
β”‚Β Β      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ entity.test.js
β”‚Β Β      β”‚Β Β  └── usecases
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ createEntity.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ createEntity.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ deleteEntity.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ deleteEntity.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ getEntity.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ getEntity.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ updateEntity.js
β”‚Β Β      β”‚Β Β      └── updateEntity.test.js
β”‚Β Β      └── infra
β”‚Β Β          β”œβ”€β”€ api
β”‚Β Β          β”‚Β Β  β”œβ”€β”€ graphql
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ custom
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ defaultResolver.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ defaultResolver.test.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mutations.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ queries.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  └── types.js
β”‚Β Β          β”‚Β Β  └── server.js
β”‚Β Β          β”œβ”€β”€ config
β”‚Β Β          β”‚Β Β  β”œβ”€β”€ config.js
β”‚Β Β          β”œβ”€β”€ db
β”‚Β Β          β”‚Β Β  └── migrations
β”‚Β Β          β”‚Β Β      β”œβ”€β”€ 20210101000000_entity.js
β”‚Β Β          β”œβ”€β”€ repl
β”‚Β Β          β”‚Β Β  └── index.js
β”‚Β Β          └── repositories
β”‚Β Β              β”œβ”€β”€ memDB
β”‚Β Β              β”‚Β Β  β”œβ”€β”€ inMemDB.js
β”‚Β Β              β”‚Β Β  β”œβ”€β”€ EntityRepository.js
β”‚Β Β              β”‚Β Β  β”œβ”€β”€ EntityRepository.test.js
β”‚Β Β              └── pg
β”‚Β Β                  β”œβ”€β”€ connection.js
β”‚Β Β                  β”œβ”€β”€ EntityRepository.js

note we have an herbs.json, this json will be an control file to help the cli when it add new modules in the project.

Propose 2

my second propose is to build an modular project, so the first thing you need is to create your entities int the root project path:

β”œβ”€β”€ user.js
β”œβ”€β”€ item.js

so when we start our project we can generate all project using the entities
Herbs new app -β€”graphql β€”-knex

This will create an app with graphql that use knex into repository, the generated files will be something like this:

β”‚Β Β  β”œβ”€β”€ herbs.json
β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β  β”œβ”€β”€ knexfile.js
β”‚Β Β  β”œβ”€β”€ package.json
β”‚Β Β  └── src
β”‚Β Β      β”œβ”€β”€ domain
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ entities
β”‚Β Β      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ user.js
β”‚Β Β      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ user.test.js
β”‚Β Β      β”‚Β Β  └── usecases
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ createUser.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ createUser.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ deleteUser.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ deleteUser.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ getUser.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ getUser.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ updateUser.js
β”‚Β Β      β”‚Β Β      └── updateUser.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ createItem.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ createItem.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ deleteItem.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ deleteItem.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ getItem.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ getItem.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ updateItem.js
β”‚Β Β      β”‚Β Β      └── updateItem.test.js
β”‚Β Β      └── infra
β”‚Β Β          β”œβ”€β”€ api
β”‚Β Β          β”‚Β Β  β”œβ”€β”€ graphql
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ custom
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ UserResolver.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ UserResolver.test.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ItemResolver.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ItemResolver.test.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mutations.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ queries.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  └── types.js
β”‚Β Β          β”‚Β Β  └── server.js
β”‚Β Β          β”œβ”€β”€ config
β”‚Β Β          β”‚Β Β  β”œβ”€β”€ config.js
β”‚Β Β          β”œβ”€β”€ db
β”‚Β Β          β”‚Β Β  └── migrations
β”‚Β Β          β”‚Β Β      β”œβ”€β”€ 20210101000000_User.js
β”‚Β Β          β”‚Β Β      β”œβ”€β”€ 20210101000000_item.js
β”‚Β Β          β”œβ”€β”€ repl
β”‚Β Β          β”‚Β Β  └── index.js
β”‚Β Β          └── repositories
β”‚Β Β              β”œβ”€β”€ memDB
β”‚Β Β              β”‚Β Β  β”œβ”€β”€ inMemDB.js
β”‚Β Β              β”‚Β Β  β”œβ”€β”€ UserRepository.js
β”‚Β Β              β”‚Β Β  β”œβ”€β”€ UserRepository.test.js
β”‚Β Β              └── pg
β”‚Β Β                  β”œβ”€β”€ connection.js
β”‚Β Β                  β”œβ”€β”€ UserRepository.js
β”‚Β Β                  β”œβ”€β”€ UserRepository.test.js
β”‚Β Β              β”‚Β Β  β”œβ”€β”€ ItemRepository.js
β”‚Β Β              β”‚Β Β  β”œβ”€β”€ ItemRepository.test.js

note we have an herbs.json, this json will be an control file to help the cli when it add new modules in the project.

Propose 3

Makes the propose-1 so grow the CLI to propose-2

Herbs Modules

After create your app, you can write an new entity in the project and generate a new crud for this entity, example:
herbs new entity ShoppingCart(or you can specify the entity path with --path)
So we will in the entities path `src/entities/item.js, read the file and generate a CRUD usecase (create, delete, list, update), generate the repository and add this entity into graphql layer.

β”‚Β Β  β”œβ”€β”€ herbs.json
β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β  β”œβ”€β”€ knexfile.js
β”‚Β Β  β”œβ”€β”€ package.json
β”‚Β Β  └── src
β”‚Β Β      β”œβ”€β”€ domain
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ entities
β”‚Β Β      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ user.js
β”‚Β Β      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ user.test.js
β”‚Β Β      β”‚Β Β  └── usecases
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ createUser.js
                [...]
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ createItem.js
β”‚Β Β      β”‚Β Β      [...]
                β”œβ”€β”€ createShoppingCart.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ deleteShoppingCart.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ deleteShoppingCart.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ getShoppingCart.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ getShoppingCart.test.js
β”‚Β Β      β”‚Β Β      β”œβ”€β”€ updateShoppingCart.js
β”‚Β Β      β”‚Β Β      └── updateShoppingCart.test.js
β”‚Β Β      └── infra
β”‚Β Β          β”œβ”€β”€ api
β”‚Β Β          β”‚Β Β  β”œβ”€β”€ graphql
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ custom
                    [...]
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ShoppingCart.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ ShoppingCart.test.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ index.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mutations.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  β”œβ”€β”€ queries.js
β”‚Β Β          β”‚Β Β  β”‚Β Β  └── types.js
β”‚Β Β          β”‚Β Β  └── server.js
β”‚Β Β          β”œβ”€β”€ config
β”‚Β Β          β”‚Β Β  β”œβ”€β”€ config.js
β”‚Β Β          β”œβ”€β”€ db
β”‚Β Β          β”‚Β Β  └── migrations
                    [...]
β”‚Β Β          β”‚Β Β      β”œβ”€β”€ 20210101000000_ShoppingCart.js
β”‚Β Β          β”œβ”€β”€ repl
β”‚Β Β          β”‚Β Β  └── index.js
β”‚Β Β          └── repositories
β”‚Β Β                  memDB
β”‚Β Β               Β Β  β”œβ”€β”€ inMemDB.js
                    [...]
β”‚Β Β           Β Β      β”œβ”€β”€ 20210101000000_ShoppingCart.js
β”‚Β Β                  pg
β”‚Β Β                  β”œβ”€β”€ connection.js
β”‚Β Β                  β”œβ”€β”€ UserRepository.js
β”‚Β Β                  β”œβ”€β”€ UserRepository.test.js
β”‚Β Β               Β Β  β”œβ”€β”€ ItemRepository.js
β”‚Β Β               Β Β  β”œβ”€β”€ ShoppingCartRepository.test.js
β”‚Β Β               Β Β  β”œβ”€β”€ ShoppingCartRepository.test.js

other example is to create new presentation layer
herbjs new module --rest

so we add the herbs2rest into package.json and generate the rest layer

I believe we can have the commands:

beta stage
herbs new app < --graphql --rest --knex --mongo >

release 1.0
herbs add layer < --graphql --rest --knex --mongo >
herbs add entity <name or --path>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.