This commit is contained in:
Jason Kulatunga 2022-08-22 18:11:00 -07:00
parent cc9948cd04
commit d46f12928e
18 changed files with 61 additions and 43 deletions

View File

@ -3,5 +3,5 @@
npm run dist npm run dist
go mod vendor go mod vendor
go run backend/cmd/webcli/webcli.go start --config ./config.yaml go run backend/cmd/fasten/fasten.go start --config ./config.yaml
``` ```

View File

@ -3,7 +3,7 @@
Find & replace the following Find & replace the following
- `packagrio/goweb-template` - replace this with your github project name (owner/reponame) - `fastenhealth/fastenhealth-onprem` - replace this with your github project name (owner/reponame)
- `webcli` - find and replace this with your binary name - `fastenhealth` - find and replace this with your binary name
- make sure you rename the folder as well. - make sure you rename the folder as well.

View File

@ -4,10 +4,28 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/analogj/go-util/utils" "github.com/analogj/go-util/utils"
"github.com/packagrio/goweb-template/backend/pkg/config" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config"
"github.com/packagrio/goweb-template/backend/pkg/errors" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/errors"
"github.com/packagrio/goweb-template/backend/pkg/version" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/version"
"github.com/packagrio/goweb-template/backend/pkg/web" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/web"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"io"
"log"
"os"
"time"
)
\
import (
"encoding/json"
"fmt"
"github.com/analogj/go-util/utils"
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config"
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/errors"
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/version"
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/web"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"io" "io"
@ -48,7 +66,7 @@ func main() {
}, },
Before: func(c *cli.Context) error { Before: func(c *cli.Context) error {
packagrUrl := "github.com/packagrio/goweb-template" packagrUrl := "github.com/fastenhealth/fastenhealth-onprem"
versionInfo := fmt.Sprintf("%s.%s-%s", goos, goarch, version.VERSION) versionInfo := fmt.Sprintf("%s.%s-%s", goos, goarch, version.VERSION)
@ -69,7 +87,7 @@ func main() {
Commands: []*cli.Command{ Commands: []*cli.Command{
{ {
Name: "start", Name: "start",
Usage: "Start the webcli server", Usage: "Start the fasten server",
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
//fmt.Fprintln(c.App.Writer, c.Command.Usage) //fmt.Fprintln(c.App.Writer, c.Command.Usage)
if c.IsSet("config") { if c.IsSet("config") {

View File

@ -3,7 +3,7 @@ package config
import ( import (
"fmt" "fmt"
"github.com/analogj/go-util/utils" "github.com/analogj/go-util/utils"
"github.com/packagrio/goweb-template/backend/pkg/errors" "github.com/fastenhealth/fastenhealth-onprem/backend/pkg/errors"
"github.com/spf13/viper" "github.com/spf13/viper"
"log" "log"
"os" "os"
@ -24,7 +24,7 @@ func (c *configuration) Init() error {
c.SetDefault("web.listen.port", "8080") c.SetDefault("web.listen.port", "8080")
c.SetDefault("web.listen.host", "0.0.0.0") c.SetDefault("web.listen.host", "0.0.0.0")
c.SetDefault("web.listen.basepath", "") c.SetDefault("web.listen.basepath", "")
c.SetDefault("web.src.frontend.path", "/opt/webcli/web") c.SetDefault("web.src.frontend.path", "/opt/fasten/web")
c.SetDefault("log.level", "INFO") c.SetDefault("log.level", "INFO")
c.SetDefault("log.file", "") c.SetDefault("log.file", "")
@ -37,7 +37,7 @@ func (c *configuration) Init() error {
c.AddConfigPath("$HOME/") c.AddConfigPath("$HOME/")
//configure env variable parsing. //configure env variable parsing.
c.SetEnvPrefix("PACKAGR") c.SetEnvPrefix("FASTEN")
c.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_")) c.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
c.AutomaticEnv() c.AutomaticEnv()
//CLI options will be added via the `Set()` function //CLI options will be added via the `Set()` function

View File

@ -1,9 +1,9 @@
package handler package handler
import ( import (
//"github.com/packagrio/goweb-template/backend/pkg/database" //"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
//"github.com/packagrio/goweb-template/backend/pkg/config" //"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config"
//"github.com/sirupsen/logrus" //"github.com/sirupsen/logrus"
"net/http" "net/http"
) )

View File

@ -1,8 +1,8 @@
package middleware package middleware
import ( import (
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/packagrio/goweb-template/backend/pkg/config"
) )
func ConfigMiddleware(appConfig config.Interface) gin.HandlerFunc { func ConfigMiddleware(appConfig config.Interface) gin.HandlerFunc {

View File

@ -2,10 +2,10 @@ package web
import ( import (
"fmt" "fmt"
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config"
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/web/handler"
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/web/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/packagrio/goweb-template/backend/pkg/config"
"github.com/packagrio/goweb-template/backend/pkg/web/handler"
"github.com/packagrio/goweb-template/backend/pkg/web/middleware"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"net/http" "net/http"
"strings" "strings"

View File

@ -2,7 +2,7 @@
# Version # Version
# #
# version specifies the version of this configuration file schema, not # version specifies the version of this configuration file schema, not
# the webcli binary. There is only 1 version available at the moment # the fasten binary. There is only 1 version available at the moment
version: 1 version: 1
web: web:
@ -10,15 +10,15 @@ web:
port: 8080 port: 8080
host: 0.0.0.0 host: 0.0.0.0
# if you're using a reverse proxy like apache/nginx, you can override this value to serve webcli on a subpath. # if you're using a reverse proxy like apache/nginx, you can override this value to serve fasten on a subpath.
# eg. http://example.com/webcli/* vs http://example.com:8080 # eg. http://example.com/fasten/* vs http://example.com:8080
# basepath: `/webcli` # basepath: `/fasten`
# leave empty unless behind a path prefixed proxy # leave empty unless behind a path prefixed proxy
basepath: '' basepath: ''
src: src:
# the location on the filesystem where webapp javascript + css is located # the location on the filesystem where webapp javascript + css is located
frontend: frontend:
path: /opt/webcli/web path: /opt/fasten/web
# path: ./dist # path: ./dist
log: log:

View File

@ -1,4 +1,4 @@
# Webcli # fastenhealth
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.4. This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.4.

View File

@ -3,7 +3,7 @@
"version": 1, "version": 1,
"newProjectRoot": "projects", "newProjectRoot": "projects",
"projects": { "projects": {
"webcli": { "fastenhealth": {
"projectType": "application", "projectType": "application",
"schematics": { "schematics": {
"@schematics/angular:component": { "@schematics/angular:component": {
@ -17,7 +17,7 @@
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"outputPath": "dist/webcli", "outputPath": "dist/fastenhealth",
"index": "src/index.html", "index": "src/index.html",
"main": "src/main.ts", "main": "src/main.ts",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",
@ -66,18 +66,18 @@
"serve": { "serve": {
"builder": "@angular-devkit/build-angular:dev-server", "builder": "@angular-devkit/build-angular:dev-server",
"options": { "options": {
"browserTarget": "webcli:build" "browserTarget": "fastenhealth:build"
}, },
"configurations": { "configurations": {
"production": { "production": {
"browserTarget": "webcli:build:production" "browserTarget": "fastenhealth:build:production"
} }
} }
}, },
"extract-i18n": { "extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n", "builder": "@angular-devkit/build-angular:extract-i18n",
"options": { "options": {
"browserTarget": "webcli:build" "browserTarget": "fastenhealth:build"
} }
}, },
"test": { "test": {
@ -114,15 +114,15 @@
"builder": "@angular-devkit/build-angular:protractor", "builder": "@angular-devkit/build-angular:protractor",
"options": { "options": {
"protractorConfig": "e2e/protractor.conf.js", "protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "webcli:serve" "devServerTarget": "fastenhealth:serve"
}, },
"configurations": { "configurations": {
"production": { "production": {
"devServerTarget": "webcli:serve:production" "devServerTarget": "fastenhealth:serve:production"
} }
} }
} }
} }
}}, }},
"defaultProject": "webcli" "defaultProject": "fastenhealth"
} }

View File

@ -10,7 +10,7 @@ describe('workspace-project App', () => {
it('should display welcome message', () => { it('should display welcome message', () => {
page.navigateTo(); page.navigateTo();
expect(page.getTitleText()).toEqual('webcli app is running!'); expect(page.getTitleText()).toEqual('fastenhealth app is running!');
}); });
afterEach(async () => { afterEach(async () => {

View File

@ -16,7 +16,7 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser clearContext: false // leave Jasmine Spec Runner output visible in browser
}, },
coverageIstanbulReporter: { coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/webcli'), dir: require('path').join(__dirname, './coverage/fasten'),
reports: ['html', 'lcovonly', 'text-summary'], reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true fixWebpackSourcePaths: true
}, },

View File

@ -1,11 +1,11 @@
{ {
"name": "webcli", "name": "fastenhealth",
"version": "0.0.0", "version": "0.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "webcli", "name": "fastenhealth",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"@angular/animations": "~9.1.4", "@angular/animations": "~9.1.4",

View File

@ -1,5 +1,5 @@
{ {
"name": "webcli", "name": "fasten",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",

View File

@ -20,16 +20,16 @@ describe('AppComponent', () => {
expect(app).toBeTruthy(); expect(app).toBeTruthy();
}); });
it(`should have as title 'webcli'`, () => { it(`should have as title 'fastenhealth'`, () => {
const fixture = TestBed.createComponent(AppComponent); const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance; const app = fixture.componentInstance;
expect(app.title).toEqual('webcli'); expect(app.title).toEqual('fastenhealth');
}); });
it('should render title', () => { it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent); const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges(); fixture.detectChanges();
const compiled = fixture.nativeElement; const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('webcli app is running!'); expect(compiled.querySelector('.content span').textContent).toContain('fastenhealth app is running!');
}); });
}); });

View File

@ -6,5 +6,5 @@ import { Component } from '@angular/core';
styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss']
}) })
export class AppComponent { export class AppComponent {
title = 'webcli'; title = 'fastenhealth';
} }

View File

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Webcli</title> <title>fastenhealth</title>
<base href="/"> <base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/packagrio/goweb-template module github.com/fastenhealth/fastenhealth-onprem
go 1.18 go 1.18