Skip to content

Commit

Permalink
Add related examples to more docs pages (#1386)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuskohlberg authored Sep 12, 2024
1 parent b73958a commit 7feefda
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/develop/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func AuthHandler(ctx context.Context, token string) (auth.UID, *Data, error) {
}
```

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/clerk"
desc="Example application showing an auth handler implementation with Clerk."
/>

### Without custom user data

When you don't require custom user data and it's sufficient to use `auth.UID`,
Expand Down
5 changes: 5 additions & 0 deletions docs/primitives/api-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func MyOtherAPI(ctx context.Context) error {
}
```

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/trello-clone"
desc="Simple microservices example application with service-to-service API calls."
/>

This means your development workflow is as simple as building a monolith, even if you use multiple services.
You also get all the benefits of function calls, like compile-time checking of all the parameters and auto-completion in your editor, while still allowing the division of code into logical components, services, and systems.

Expand Down
5 changes: 5 additions & 0 deletions docs/primitives/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func Ping(ctx context.Context, params *PingParams) (*PingResponse, error) {
}
```

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/hello-world"
desc="Hello World REST API example application."
/>

## Access controls

When you define an API, you have three options for how it can be accessed:
Expand Down
5 changes: 5 additions & 0 deletions docs/primitives/cron-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ When you need to run periodic and recurring tasks, Encore's Backend Framework pr
When a Cron Job is defined, Encore will call the API of your choice on the schedule you have defined.
This means there is no need to maintain any infrastructure, as Encore handles the scheduling, monitoring and execution of Cron Jobs.

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/uptime"
desc="Uptime Monitoring app that uses a Cron Job to periodically check the uptime of a website."
/>

## Defining a Cron Job

To define a Cron Job, all you need to do is to import the `encore.dev/cron` [package](https://pkg.go.dev/encore.dev/cron),
Expand Down
5 changes: 5 additions & 0 deletions docs/primitives/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ With this code in place Encore will automatically create the database using Dock

For cloud environments, Encore automatically injects the appropriate configuration to authenticate and connect to the database, so once the application starts up the database is ready to be used.

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/sql-database"
desc="Simple PostgreSQL example application."
/>

## Defining the database schema

Database schemas are defined by creating *migration files* in a directory named `migrations`
Expand Down
5 changes: 5 additions & 0 deletions docs/primitives/pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ var Signups = pubsub.NewTopic[*SignupEvent]("signups", pubsub.TopicConfig{
})
```

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/uptime"
desc="Event-driven example application using Pub/Sub."
/>

### At-least-once delivery

The above example configures the topic to ensure that, for each subscription, events will be delivered _at least once_.
Expand Down
5 changes: 5 additions & 0 deletions docs/primitives/raw-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ Experienced Go developers will have already noted this is just a regular Go HTTP
(See the <a href="https://pkg.go.dev/net/http#Handler" target="_blank" rel="nofollow">net/http documentation</a> for how Go HTTP handlers work.)

Learn more about receiving webhooks and using WebSockets in the [receiving regular HTTP requests guide](/docs/how-to/http-requests).

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/slack-bot"
desc="Slack Bot example application that uses Raw endpoints to accept webhooks."
/>
5 changes: 5 additions & 0 deletions docs/primitives/secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Of course, we can’t do that &ndash; it's horrifyingly insecure!

Encore's built-in secrets manager makes it simple to store secrets in a secure way and lets you use them in your program like regular variables.

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/slack-bot"
desc="Slack Bot example application using secrets to store a Slack key."
/>

## Using secrets in your application

To use a secret in your application, first define it directly in your code by creating an unexported struct named `secrets`, where all fields are of type `string`. For example:
Expand Down
5 changes: 5 additions & 0 deletions docs/primitives/service-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func (s *Service) MyAPI(ctx context.Context) error {
}
```

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/uptime"
desc="Event-driven example application using service structs."
/>

## Calling APIs defined on service structs

When using a service struct like above, Encore will create a file named `encore.gen.go`
Expand Down
5 changes: 5 additions & 0 deletions docs/primitives/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ On disk it might look like this:
This means building a microservices architecture is as simple as creating multiple Go packages within your application.
See the [app structure documentation](/docs/develop/app-structure) for more details.

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/trello-clone"
desc="Simple microservices example application."
/>

## Service Initialization

Under the hood Encore automatically generates a `main` function that initializes all your infrastructure resources when the application starts up. This means you don't write a `main` function for your Encore application.
Expand Down
2 changes: 1 addition & 1 deletion docs/ts/concepts/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ To run it, you simply use `encore run` and the Open Source CLI will automaticall

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/ts/hello-world"
desc="Hello World REST API Starter."
desc="Hello World REST API example application."
/>

## Getting started video
Expand Down
6 changes: 6 additions & 0 deletions docs/ts/develop/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ incoming requests to your application, and whenever a request contains
an `Authorization` header it will first call the authentication handler to
resolve information about the user.


<GitHubLink
href="https://github.com/encoredev/examples/tree/main/ts/clerk"
desc="Example application showing an auth handler implementation using Clerk."
/>

### Rejecting authentication

If the auth handler returns an `AuthData` object, Encore will consider the request
Expand Down
5 changes: 5 additions & 0 deletions docs/ts/primitives/api-calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ export const myOtherAPI = api({}, async (): Promise<void> => {

This means your development workflow is as simple as building a monolith, even if you use multiple services.
You get all the benefits of function calls, like compile-time checking of all the parameters and auto-completion in your editor, while still allowing the division of code into logical components, services, and systems.

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/ts/simple-event-driven"
desc="Simple microservices example application with service-to-service API calls."
/>
2 changes: 1 addition & 1 deletion docs/ts/primitives/pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Encore's Backend Framework lets you use Pub/Sub in a cloud-agnostic declarative

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/ts/simple-event-driven"
desc="Simple starter (three services) with an event-driven architecture."
desc="Simple example app with an event-driven architecture using Pub/Sub."
/>

## Creating a Topic
Expand Down
2 changes: 1 addition & 1 deletion docs/ts/primitives/raw-endpoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ Hello, raw world!

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/ts/slack-bot"
desc="Slack Bot app that uses Raw endpoints to accept webhooks"
desc="Slack Bot example application that uses Raw endpoints to accept webhooks."
/>

0 comments on commit 7feefda

Please sign in to comment.