Giter VIP home page Giter VIP logo

go-webapp-sample's People

Contributors

bobcode99 avatar dependabot[bot] avatar pzathief avatar stackkrocket avatar ybkuroki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

go-webapp-sample's Issues

[Question] GET https://***/api/auth/loginStatus 401 (Unauthorized)

Summary

GET https://***/api/auth/loginStatus 401 (Unauthorized)

Cause

Deploy this to server with nginx proxy_pass

To reproduce

  1. run go-webapp-sample in ubuntu server;
  2. use nginx for port forwarding:
    image
  3. start vuejs-webapp-sample locally, try to login, then I got
    image
  4. logs in server:
    image

Expected behavior

successfully login

How to deal with this issue

not solved yet.

Notes

[NEW] Implement unit test

Purpose

To test Web APIs.

Expected behavior

It can test with the test command for golang.

How to deal with this issue

TBD

Notes

[NEW] About load configuration files

1、Use environment.
When there are multiple systems running, it is not very convenient

2、Start with parameters
In the development process, if unit testing is needed, especially using Golan, it seems inconvenient to do testing

Whether a third option can be added, using a relative path to load the configuration file .

[NEW] Create the unit test cases

Purpose

The purpose of this ticket is to be improved quality of this sample, and to be able to find the bugs related it quickly when updates the version of some libraries or some source codes by covering the major test cases.

Targets of this ticket

  • Controllers
    • Add the irregular cases.
  • Services
    • Add the major test cases.
  • DTO (Data Transfer Objects)
    • Add the test cases about validation checks.
  • Unit test utility
    • Add the test cases about request builder.

[NEW] Change logger specification

Purpose

To make it easy to change logging settings.

Change List

  • Change info log to debug log.
  • Change to set logging settings in the configuration file

[NEW] Add a properties file for defining the system messages

Purpose

The purpose of this ticket is to be able to manage the messages is returned by the system in the properties file.

Expected behavior

The expected behavior is the followings:

  • Load the properties file when this application have started up.
  • This application returns the messages is defined when occurred errors.
  • The path of properties file is the root path of this project.

[NEW] Support swagger

Purpose

We can't only check Web APIs of this application in README but also we would like to be able to check in Swagger UI.

Expected behavior

  • We can check Web APIs documentation which Swagger have automatically generated when we access to localhost:8080/swagger/index.html in our browser.
  • It only enables Swagger at develop environment.

How to deal with this issue

Use swaggo/echo-swagger library

Notes

None

[NEW] Implement HTTP Session Authentication

Purpose

To allow only authorized users to see book datas.

Expected behavior

  • Some users can login or logout by using username and password.

How to deal with this issue

Implement the following method.

  • Implement session management using echo-session library.
  • Implement authentication function.
    • Login Rest API
      • Authenticate using username and password.
      • Check authority of login user.
      • Create session id and set cookie session id.
    • Logout Rest API
      • Remove session and cookie.
    • Validate session id in the each request.
      • Implement using echo's middleware.

References

[NEW] Support static files

Purpose

The purpose of this ticket is to provide with the screen of this application without starting a web server of vuejs-webapp-sample project.

Expected behavior

The expected behavior is the followings:

  • Load static files such as html, css and javascript files when this application have started up.
  • The path of static files which is loaded is provided with application.yml.
  • The default static files is build files of vuejs-webapp-sample project.

Master data not generated when running with postgres

Summary

The application is connecting with my postgres server but not creating the master data

Cause

Why such a problem happened?

To reproduce

Changed the application.docker.yml file and added the following config
database:
dialect: postgres
host: localhost
port: 5432
dbname: testdb
username: admin
password: psltest
migration: true

Then I built the application go build main.go
Execute the app with ./main.exe -env=docker
The output is
PS C:\Users\Raja.Ramanujam\OneDrive - Neudesic\Documents\kube-monitoring\golangapp\go-webapp-sample> .\main.exe -env=docker
2022-11-08T18:27:39.688+0530 INFO logger/logger.go:62 Success to read zap logger configuration: zaplogger.docker.yml
2022-11-08T18:27:39.689+0530 INFO go-webapp-sample/main.go:41 Loaded this configuration : application.docker.yml
2022-11-08T18:27:39.689+0530 INFO repository/repository.go:50 Try database connection
2022-11-08T18:27:42.186+0530 INFO repository/repository.go:56 Success database connection, localhost:5432


/ // / ___
/ // / _ / _
/
/_
////___/ v4.9.0
High performance, minimalist Go web framework
https://echo.labstack.com
_____________________________O/
O
⇨ http server started on [::]:8080

Expected behavior

The master data is not generated as how it use to do when using the application.develop.yml file
PS C:\Users\Raja.Ramanujam\OneDrive - Neudesic\Documents\kube-monitoring\golangapp\go-webapp-sample> .\main.exe
2022-11-08T18:16:40.591+0530 INFO logger/logger.go:62 Success to read zap logger configuration: zaplogger.develop.yml
2022-11-08T18:16:40.592+0530 INFO go-webapp-sample/main.go:41 Loaded this configuration : application.develop.yml
2022-11-08T18:16:40.593+0530 INFO repository/repository.go:50 Try database connection
2022-11-08T18:16:40.611+0530 INFO repository/repository.go:56 Success database connection, book.db:
2022-11-08T18:16:40.629+0530 DEBUG logger/gormlogger.go:58 [gorm] INSERT INTO authority_master (name) VALUES ("Admin") RETURNING id
2022-11-08T18:16:40.700+0530 DEBUG logger/gormlogger.go:58 [gorm] INSERT INTO account_master (name,password,authority_id) VALUES ("test","$2a$10$TiX8wtNwK6QgnRQnfSkxvuBstQcteN0NcCdW7fDT3XyNpjJnVhqme",2) RETURNING id
2022-11-08T18:16:40.766+0530 DEBUG logger/gormlogger.go:58 [gorm] INSERT INTO account_master (name,password,authority_id) VALUES ("test2","$2a$10$Py4EzSdPWU6w0uECT8KXRud5wWWGLWDaHHv7wzwCayqV0tSOOhN5e",2) RETURNING id
2022-11-08T18:16:40.772+0530 DEBUG logger/gormlogger.go:58 [gorm] INSERT INTO category_master (name) VALUES ("Technical Book") RETURNING id
2022-11-08T18:16:40.780+0530 DEBUG logger/gormlogger.go:58 [gorm] INSERT INTO category_master (name) VALUES ("Magazine") RETURNING id
2022-11-08T18:16:40.787+0530 DEBUG logger/gormlogger.go:58 [gorm] INSERT INTO category_master (name) VALUES ("Novel") RETURNING id
2022-11-08T18:16:40.795+0530 DEBUG logger/gormlogger.go:58 [gorm] INSERT INTO format_master (name) VALUES ("Paper Book") RETURNING id
2022-11-08T18:16:40.869+0530 INFO middleware/middleware.go:132 Served the static contents.

How to deal with this issue

How do you fix it?

Notes

[NEW] Switch different environment

Purpose

This web application can be deployed in different environments such as development or production by allowing to switch the configuration settings.

Expected behavior

This application can switch different environment by changing runtime parameter.

How to deal with this issue

  • The configuration settings implement by using configor library.
  • Uses flag to get runtime parameter.

References

Error when executing main.go

Summary

Getting the following error when try to get the source code
sqlite3-binding.c: In function 'sqlite3SelectNew':
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
128049 | return pNew;
| ^~~~
sqlite3-binding.c:128009:10: note: declared here
128009 | Select standin;
| ^~~~~~~

github.com/ybkuroki/go-webapp-sample

Cause

Why such a problem happened?

To reproduce

Perform the follwing steps to reproduce the problem.

  1. run go install github.com/ybkuroki/go-webapp-sample@latest

[NEW] Why did you choose the zap logger over the built-in echo logger interface?

Purpose

It seems to me that in services accessing a logger from a container is quite inconvenient, so why did you choose to explicitly pass a container instance to every service?
There might be the following option to do that:

  1. Use a native echo Logger
  2. Instead of a container instance you could assign a logger to echo.Context and then accessing the logger from it

[NEW] Update golang version from 1.16 to 1.17

Purpose

Update golang version from 1.16 to 1.17.

How to deal with this issue

  1. Uninstall golang 1.16.
  2. Install golang 1.17.
  3. Update the golang version of go.mod.
  4. Check the behavior of this application.

Wrong spelling

Summary

Write the actual behavior and the purpose to modify.
IN the READ.md file under the Project map section, the following is spelt wrongly.

Cause

Why such a problem happened?

To reproduce

Perform the follwing steps to reproduce the problem.

Expected behavior

Expected the follwing behavior.

How to deal with this issue

How do you fix it?

Notes

[NEW] Use dep for dependencies management

Purpose

To easy dependencies management.

How to deal with this issue

Perform the following steps:

  1. Install dep.
    $ go get -u github.com/golang/dep/cmd/dep
    $ cd GOPATH/src/github.com/ybkuroki/go-webapp-sample
  2. Setup this Go project.
    $ dep init
  3. Run this application.
    $ go run main.go

Notes

To update dependencies

Perform the following steps:

  1. Update source code.
  2. Update dependencies.
    $ dep ensure

[NEW] Add session to context

Purpose

The purpose of this ticket is to be able to use session data at anywhere by adding session to context.

Expected behavior

The behavior isn't changed by fixing this issue.

[BUG] -- Issue in running the app after a clone

Summary

I forked the repo to practice devops(CICD with Jenkins) and from my personal GitHub, I cloned the repo, and I was following the steps mentioned in the readme. However, I have issues with the running of application as it says database connection failure. I couldn't find any information on setting up db in the readme. Also, please note that I already have go installed in my machine along with VS code. I didn't bother to install MinGW(gcc).

Cause

If we need to configure db, that details are not updated, due to which may be this issue.

To reproduce

Perform the follwing steps to reproduce the problem.

  1. In a new machine, follow the steps mentioned in readme and try "go run main.go" (in my case I haven't done this bit "Download and install MinGW(gcc).")

Expected behavior

If we follow steps mentioned in readme, we should be able to run the app without any issue

Screenshot from Terminal

goapp

Remaining issuses

The remaining issues are as follows.

Entity Name Before After
Category categories category_master
Format formats format_master
  • Consider output of logging.
  • Consider error handling.

I will rise as separate issues if it necessary.

Consider about the features and improvements

Purpose

The purpose of this issue is to consider about we will want to add what features and improvement in the future.

Current remain issues

There is the following remain issues in this repository.
I would like to resolve those issues by discussing with some contributors.

  • [Improvement] #173
  • [Improvement] #169
  • [Improvement] #40

What we will want to do it

This is some improvements which I considered in the past:

  • Implement RBAC (Role Base Access Control)
    • Change from the hardcoding based access control to the RBAC which used the database.
  • Implement the authentication using JWT (JSON Web Token)

[BUG]

Summary

Write the actual behavior and the purpose to modify.

go test -v .
gives out below error:

? github.com/ybkuroki/go-webapp-sample [no test files]

To reproduce

Perform the follwing steps to reproduce the problem.

go test -v .

[NEW] Refactoring Web APIs

Purpose

To refactor Web APIs.

ASIS / TOBE

Book Management

Service Name ASIS URL ASIS Method TOBE URL TOBE Method
Get Service /api/book?id=[BOOK_ID] GET /api/books/:id GET
List Service /api/book/list?page=[PAGE_NUMBER]&size=[PAGE_SIZE] GET /api/books?page=[PAGE_NUMBER]&size=[PAGE_SIZE] GET
Regist Service /api/book/new POST /api/books POST
Edit Service /api/book/edit POST /api/books PUT
Delete Service /api/book/delete POST /api/books DELETE
Search Title Service /api/book/search?query=[KEYWORD]&page=[PAGE_NUMBER]&size=[PAGE_SIZE] GET /api/books?query=[KEYWORD]&page=[PAGE_NUMBER]&size=[PAGE_SIZE] GET

Account Management

Service Name ASIS URL ASIS Method TOBE URL TOBE Method
Login Service /api/account/login POST /api/auth/login POST
Logout Service /api/account/logout POST /api/auth/logout POST
Login Status Check Service /api/account/loginStatus GET /api/auth/loginStatus GET
Login Username Service /api/account/loginAccount GET /api/auth/loginAccount GET

Master Management

Service Name ASIS URL ASIS Method TOBE URL TOBE Method
Category List Service /api/master/category GET /api/categories GET
Format List Service /api/master/format GET /api/formats GET

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.