diff --git a/.gitignore b/.gitignore index fbd390a..ccc0bb2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,27 @@ -# ---> Go -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins +# Encore +/.encore +encore.gen.go +encore.gen.cue +.secrets.local.cue + +# Go *.exe *.exe~ *.dll *.so *.dylib - -# Test binary, built with `go test -c` *.test - -# Output of the go coverage tool, specifically when used with LiteIDE *.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file go.work go.work.sum -# env file +# Environment files .env +.env.development.local +.env.test.local +.env.production.local +.env.local -# ---> Node # Logs logs *.log @@ -35,7 +31,7 @@ yarn-error.log* lerna-debug.log* .pnpm-debug.log* -# Diagnostic reports (https://nodejs.org/api/report.html) +# Diagnostic reports report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # Runtime data @@ -44,122 +40,52 @@ pids *.seed *.pid.lock -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul +# Coverage and build output coverage *.lcov - -# nyc test coverage .nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) +dist +out build/Release # Dependency directories node_modules/ jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) +bower_components/ web_modules/ -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory +# Tool caches +lib-cov +.grunt .npm - -# Optional eslint cache .eslintcache - -# Optional stylelint cache .stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) .cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files .cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory +.parcel-cache +.next +.nuxt .temp -.cache - -# vitepress build output +.vuepress/dist **/.vitepress/dist - -# vitepress cache directory **/.vitepress/cache - -# Docusaurus cache and generated files .docusaurus - -# Serverless directories .serverless/ - -# FuseBox cache .fusebox/ - -# DynamoDB Local files .dynamodb/ - -# TernJS port file .tern-port - -# Stores VSCode versions used for testing VSCode extensions .vscode-test -# yarn v2 +# TypeScript +*.tsbuildinfo + +# Packaging +*.tgz + +# Yarn +.yarn-integrity .yarn/cache .yarn/unplugged .yarn/build-state.yml .yarn/install-state.gz .pnp.* - diff --git a/README.md b/README.md index 3236897..1e88e3f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,50 @@ # encore-test -test del framework encore \ No newline at end of file +Test del framework Encore con backend Go e frontend Quasar. + +## Prerequisiti + +- Encore: `brew install encoredev/tap/encore` +- Go +- Node.js e pnpm per il frontend + +## Avvio locale + +Backend: + +```bash +encore run +``` + +Frontend: + +```bash +cd frontend +pnpm install +pnpm dev +``` + +## Test + +Backend: + +```bash +go test ./... +``` + +Frontend: + +```bash +cd frontend +pnpm typecheck +``` + +## Note Encore + +Con `encore run` attivo, il dashboard locale e' disponibile su: + +```text +http://localhost:9400/ +``` + +Le API locali sono esposte dall'ambiente Encore locale. Consulta il Service Catalog nel dashboard per endpoint e schema aggiornati. diff --git a/encore.app b/encore.app new file mode 100644 index 0000000..263e1e1 --- /dev/null +++ b/encore.app @@ -0,0 +1,5 @@ +{ + // The app is not currently linked to the encore.dev platform. + // Use "encore app link" to link it. + "id": "", +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..79c2688 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module encore.app + +go 1.26 + +require encore.dev v1.57.5 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..b3fbfde --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +encore.dev v1.57.5 h1:gpcE2XF4Qvh0IzD+seLf9DPV9q8Mzr7bMaNJfpF2xuc= +encore.dev v1.57.5/go.mod h1:lK8vSJG6uhYeUwT87/FEpcLdiN98QUcotd3gxRX0xDw= diff --git a/hello/hello.go b/hello/hello.go new file mode 100644 index 0000000..8cbb5ff --- /dev/null +++ b/hello/hello.go @@ -0,0 +1,62 @@ +// Service hello implements a simple hello world REST API. +package hello + +import ( + "context" +) + +// Welcome to Encore! +// This is a simple "Hello World" project to get you started. +// +// To run it, execute "encore run" in your favorite shell. + +// ================================================================== + +// This is a public REST API that responds with a personalized greeting. +// Learn more about defining APIs with Encore: +// https://encore.dev/docs/primitives/services-and-apis +// +// To call it, run in your terminal: +// +// curl http://localhost:4000/hello/World +// +//encore:api public path=/hello/:name +func World(ctx context.Context, name string) (*Response, error) { + msg := "Hello, " + name + "!" + return &Response{Message: msg}, nil +} + +type Response struct { + Message string +} + +// ================================================================== + +// Encore comes with a built-in local development dashboard for +// exploring your API, viewing documentation, debugging with +// distributed tracing, and more: +// +// http://localhost:9400 +// + +// ================================================================== + +// Next steps +// +// 1. Deploy your application to the cloud +// +// git add -A . +// git commit -m 'Commit message' +// git push encore +// +// 2. To continue exploring Encore, check out some of these topics: +// +// Defining Services: https://encore.dev/docs/go/primitives/services +// Defining APIs: https://encore.dev/docs/go/primitives/defining-apis +// Using SQL databases: https://encore.dev/docs/go/primitives/databases +// Using Pub/Sub: https://encore.dev/docs/go/primitives/pubsub +// Authenticating users: https://encore.dev/docs/go/develop/auth +// Building a REST API: https://encore.dev/docs/go/tutorials/rest-api +// Building an Event-Driven app: https://encore.dev/docs/go/tutorials/uptime +// Building a Slack bot: https://encore.dev/docs/go/tutorials/slack-bot +// Example apps repo: https://github.com/encoredev/examples diff --git a/hello/hello_test.go b/hello/hello_test.go new file mode 100644 index 0000000..5fb840d --- /dev/null +++ b/hello/hello_test.go @@ -0,0 +1,22 @@ +package hello + +import ( + "context" + "strings" + "testing" +) + +// Run tests using `encore test`, which compiles the Encore app and then runs `go test`. +// It supports all the same flags that the `go test` command does. +// You automatically get tracing for tests in the local dev dash: http://localhost:9400 +// Learn more: https://encore.dev/docs/go/develop/testing +func TestWorld(t *testing.T) { + const in = "Jane Doe" + resp, err := World(context.Background(), in) + if err != nil { + t.Fatal(err) + } + if got := resp.Message; !strings.Contains(got, in) { + t.Errorf("World(%q) = %q, expected to contain %q", in, got, in) + } +} diff --git a/hello/index.go b/hello/index.go new file mode 100644 index 0000000..e0887be --- /dev/null +++ b/hello/index.go @@ -0,0 +1,69 @@ +package hello + +import ( + "net/http" + "strings" + + "encore.dev" +) + +// Landing page with usage instructions. +// +//encore:api public raw path=/!path +func Index(w http.ResponseWriter, req *http.Request) { + baseUrl := encore.Meta().APIBaseURL.String() + + w.Header().Set("Content-Type", "text/html") + w.Write([]byte(strings.ReplaceAll(landingPage, "{{baseUrl}}", baseUrl))) +} + +const landingPage = ` + +
+ + +A simple REST API to get you started with Encore. This is the simplest possible Encore app, with a single endpoint that returns a greeting.
+ +Explore and test endpoints in the Local Dashboard when running locally. When deployed to Encore Cloud, use the Service Catalog to call endpoints and view traces to see how requests flow between services.
+ +hello.World
+ Returns a personalized greeting.
+curl {{baseUrl}}/hello/World
+
+ Check out these topics to keep building:
++ Building a REST API · + Defining Services · + Using SQL Databases · + Using Pub/Sub +
+ +`