Initial commit
This commit is contained in:
138
.gitignore
vendored
138
.gitignore
vendored
@@ -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.*
|
||||
|
||||
|
||||
49
README.md
49
README.md
@@ -1,3 +1,50 @@
|
||||
# encore-test
|
||||
|
||||
test del framework encore
|
||||
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.
|
||||
|
||||
5
encore.app
Normal file
5
encore.app
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
// The app is not currently linked to the encore.dev platform.
|
||||
// Use "encore app link" to link it.
|
||||
"id": "",
|
||||
}
|
||||
5
go.mod
Normal file
5
go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module encore.app
|
||||
|
||||
go 1.26
|
||||
|
||||
require encore.dev v1.57.5 // indirect
|
||||
2
go.sum
Normal file
2
go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
encore.dev v1.57.5 h1:gpcE2XF4Qvh0IzD+seLf9DPV9q8Mzr7bMaNJfpF2xuc=
|
||||
encore.dev v1.57.5/go.mod h1:lK8vSJG6uhYeUwT87/FEpcLdiN98QUcotd3gxRX0xDw=
|
||||
62
hello/hello.go
Normal file
62
hello/hello.go
Normal file
@@ -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
|
||||
22
hello/hello_test.go
Normal file
22
hello/hello_test.go
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
69
hello/index.go
Normal file
69
hello/index.go
Normal file
@@ -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 = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Hello World</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #0a0a0a; color: #e5e5e5; padding: 2rem; max-width: 720px; margin: 0 auto; line-height: 1.6; }
|
||||
h1 { font-size: 1.75rem; margin-bottom: 0.5rem; color: #fff; }
|
||||
h2 { font-size: 1.1rem; margin-top: 2rem; margin-bottom: 0.75rem; color: #fff; }
|
||||
p { margin-bottom: 1rem; color: #a3a3a3; }
|
||||
code { background: #1a1a1a; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.9em; color: #e5e5e5; }
|
||||
pre { background: #1a1a1a; border: 1px solid #262626; border-radius: 8px; padding: 1rem; overflow-x: auto; margin-bottom: 1rem; }
|
||||
pre code { background: none; padding: 0; }
|
||||
.endpoint { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
|
||||
.method { font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.5rem; border-radius: 4px; font-family: monospace; }
|
||||
.get { background: #15803d; color: #fff; }
|
||||
.path { font-family: monospace; color: #e5e5e5; }
|
||||
.desc { color: #737373; font-size: 0.9rem; margin-bottom: 1.25rem; }
|
||||
a { color: #60a5fa; }
|
||||
.badge { display: inline-block; background: #15803d; color: #fff; font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px; margin-left: 0.5rem; font-weight: 600; vertical-align: middle; position: relative; top: -0.15em; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World <span class="badge">Encore.go</span></h1>
|
||||
<p>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.</p>
|
||||
|
||||
<p>Explore and test endpoints in the <a href="http://localhost:9400/">Local Dashboard</a> when running locally. When deployed to <a href="https://app.encore.cloud">Encore Cloud</a>, use the Service Catalog to call endpoints and view traces to see how requests flow between services.</p>
|
||||
|
||||
<h2>Try it</h2>
|
||||
|
||||
<div class="endpoint">
|
||||
<span class="method get">GET</span>
|
||||
<span class="path">/hello/:name</span>
|
||||
<code>hello.World</code>
|
||||
</div>
|
||||
<p class="desc">Returns a personalized greeting.</p>
|
||||
<pre><code>curl {{baseUrl}}/hello/World</code></pre>
|
||||
|
||||
<h2>Next steps</h2>
|
||||
<p>Check out these topics to keep building:</p>
|
||||
<p>
|
||||
<a href="https://encore.dev/docs/go/tutorials/rest-api">Building a REST API</a> ·
|
||||
<a href="https://encore.dev/docs/go/primitives/services">Defining Services</a> ·
|
||||
<a href="https://encore.dev/docs/go/primitives/databases">Using SQL Databases</a> ·
|
||||
<a href="https://encore.dev/docs/go/primitives/pubsub">Using Pub/Sub</a>
|
||||
</p>
|
||||
</body>
|
||||
</html>`
|
||||
Reference in New Issue
Block a user