Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
docs: update solid quick start
Browse files Browse the repository at this point in the history
  • Loading branch information
jayair committed Oct 15, 2024
1 parent 0ce2c5b commit 25349a9
Show file tree
Hide file tree
Showing 25 changed files with 148 additions and 79 deletions.
24 changes: 0 additions & 24 deletions examples/aws-solid-start/package.json

This file was deleted.

16 changes: 0 additions & 16 deletions examples/aws-solid-start/sst-env.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ dist
.output
.vercel
.netlify
netlify
.vinxi
app.config.timestamp_*.js

# Environment
.env
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions examples/aws-solid/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "example-basic",
"type": "module",
"scripts": {
"build": "vinxi build",
"dev": "vinxi dev",
"start": "vinxi start",
"version": "vinxi version"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.670.0",
"@aws-sdk/s3-request-presigner": "^3.670.0",
"@solidjs/meta": "^0.29.4",
"@solidjs/router": "^0.14.8",
"@solidjs/start": "^1.0.8",
"solid-js": "^1.9.1",
"sst": "latest",
"vinxi": "^0.4.3"
},
"engines": {
"node": ">=18"
},
"overrides": {
"nitropack": "npm:nitropack-nightly@latest"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,3 @@ p {
max-width: none;
}
}

.increment {
font-family: inherit;
font-size: inherit;
padding: 1em 2em;
color: #335d92;
background-color: rgba(68, 107, 158, 0.1);
border-radius: 2em;
border: 2px solid rgba(68, 107, 158, 0);
outline: none;
width: 200px;
font-variant-numeric: tabular-nums;
}

.increment:focus {
border: 2px solid #335d92;
}

.increment:active {
background-color: rgba(68, 107, 158, 0.2);
}
22 changes: 22 additions & 0 deletions examples/aws-solid/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { MetaProvider, Title } from "@solidjs/meta";
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start/router";
import { Suspense } from "solid-js";
import "./app.css";

export default function App() {
return (
<Router
root={props => (
<MetaProvider>
<Title>SolidStart - Basic</Title>
<a href="/">Index</a>
<a href="/about">About</a>
<Suspense>{props.children}</Suspense>
</MetaProvider>
)}
>
<FileRoutes />
</Router>
);
}
21 changes: 21 additions & 0 deletions examples/aws-solid/src/components/Counter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.increment {
font-family: inherit;
font-size: inherit;
padding: 1em 2em;
color: #335d92;
background-color: rgba(68, 107, 158, 0.1);
border-radius: 2em;
border: 2px solid rgba(68, 107, 158, 0);
outline: none;
width: 200px;
font-variant-numeric: tabular-nums;
cursor: pointer;
}

.increment:focus {
border: 2px solid #335d92;
}

.increment:active {
background-color: rgba(68, 107, 158, 0.2);
}
11 changes: 11 additions & 0 deletions examples/aws-solid/src/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createSignal } from "solid-js";
import "./Counter.css";

export default function Counter() {
const [count, setCount] = createSignal(0);
return (
<button class="increment" onClick={() => setCount(count() + 1)} type="button">
Clicks: {count()}
</button>
);
}
19 changes: 19 additions & 0 deletions examples/aws-solid/src/routes/[...404].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Title } from "@solidjs/meta";
import { HttpStatusCode } from "@solidjs/start";

export default function NotFound() {
return (
<main>
<Title>Not Found</Title>
<HttpStatusCode code={404} />
<h1>Page Not Found</h1>
<p>
Visit{" "}
<a href="https://start.solidjs.com" target="_blank">
start.solidjs.com
</a>{" "}
to learn how to build SolidStart apps.
</p>
</main>
);
}
10 changes: 10 additions & 0 deletions examples/aws-solid/src/routes/about.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Title } from "@solidjs/meta";

export default function Home() {
return (
<main>
<Title>About</Title>
<h1>About</h1>
</main>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Resource } from "sst";
import { createAsync } from "@solidjs/router";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import "./app.css";

async function presignedUrl() {
"use server";
Expand All @@ -17,7 +16,7 @@ export const route = {
load: () => presignedUrl(),
};

export default function App() {
export default function Home() {
const url = createAsync(() => presignedUrl());

return (
Expand Down
17 changes: 17 additions & 0 deletions examples/aws-solid/sst-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* This file is auto-generated by SST. Do not edit. */
/* tslint:disable */
/* eslint-disable */
import "sst"
export {}
declare module "sst" {
export interface Resource {
"MyBucket": {
"name": string
"type": "sst.aws.Bucket"
}
"MyWeb": {
"type": "sst.aws.SolidStart"
"url": string
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
export default $config({
app(input) {
return {
name: "aws-solid-start",
name: "aws-solid",
removal: input?.stage === "production" ? "retain" : "remove",
home: "aws",
};
},
async run() {
new sst.aws.SolidStart("MyWeb");
const bucket = new sst.aws.Bucket("MyBucket", {
access: "public"
});
new sst.aws.SolidStart("MyWeb", {
link: [bucket],
});
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
Expand Down
Binary file modified www/src/assets/docs/start/start-solidstart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion www/src/content/docs/docs/start/aws/astro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ To deploy our app we'll add a `Dockerfile`.
<details>
<summary>View Dockerfile</summary>

```Dockerfile title="Dockerfile"
```dockerfile title="Dockerfile"
# From https://docs.astro.build/en/recipes/docker/

FROM node:lts AS base
Expand Down
2 changes: 1 addition & 1 deletion www/src/content/docs/docs/start/aws/nuxt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ To deploy our app we'll add a `Dockerfile`.
<details>
<summary>View Dockerfile</summary>

```Dockerfile title="Dockerfile"
```dockerfile title="Dockerfile"
FROM node:lts AS base

WORKDIR /src
Expand Down
2 changes: 1 addition & 1 deletion www/src/content/docs/docs/start/aws/remix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ To deploy our app we'll add a `Dockerfile`.
<details>
<summary>View Dockerfile</summary>

```Dockerfile title="Dockerfile"
```dockerfile title="Dockerfile"
# Based on https://github.com/remix-run/blues-stack/blob/main/Dockerfile

# base node image
Expand Down
18 changes: 9 additions & 9 deletions www/src/content/docs/docs/start/aws/solid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We'll use both to build a couple of simple apps below.
We are going to create a SolidStart app, add an S3 Bucket for file uploads, and deploy it using the `SolidStart` component.

:::tip[View source]
You can [view the source](https://github.com/sst/ion/tree/dev/examples/aws-solid-start) of this example in our repo.
You can [view the source](https://github.com/sst/ion/tree/dev/examples/aws-solid) of this example in our repo.
:::

Before you get started, make sure to [configure your AWS credentials](/docs/iam-credentials#credentials).
Expand All @@ -33,7 +33,7 @@ npm init solid@latest aws-solid-start
cd aws-solid-start
```

We are picking the **_bare_**, and **_TypeScript_** options.
We are picking the **SolidStart**, **_basic_**, and **_TypeScript_** options.

---

Expand Down Expand Up @@ -98,9 +98,9 @@ new sst.aws.SolidStart("MyWeb", {

### 3. Generate a pre-signed URL

When our app loads, we'll generate a pre-signed URL for the file upload and use it in our form. Add this below the imports in `src/app.tsx`.
When our app loads, we'll generate a pre-signed URL for the file upload and use it in our form. Add this below the imports in `src/routes/index.tsx`.

```tsx title="src/app.tsx" {5}
```ts title="src/routes/index.tsx" {5}
async function presignedUrl() {
"use server";
const command = new PutObjectCommand({
Expand Down Expand Up @@ -138,10 +138,10 @@ npm install @solidjs/router @aws-sdk/client-s3 @aws-sdk/s3-request-presigner

### 4. Create an upload form

Add a form to upload files to the presigned URL. Replace the `App()` component in `src/app.tsx` with:
Add a form to upload files to the presigned URL. Replace the `Home` component in `src/routes/index.tsx` with:

```tsx title="src/app.tsx"
export default function App() {
```tsx title="src/routes/index.tsx"
export default function Home() {
const url = createAsync(() => presignedUrl());

return (
Expand Down Expand Up @@ -214,7 +214,7 @@ npm init solid@latest aws-solid-start
cd aws-solid-start
```

We are picking the **_basic_**, and **_TypeScript_** options.
We are picking the **SolidStart**, **_basic_**, and **_TypeScript_** options.

---

Expand Down Expand Up @@ -384,7 +384,7 @@ To deploy our app we'll add a `Dockerfile`.
<details>
<summary>View Dockerfile</summary>

```Dockerfile title="Dockerfile"
```dockerfile title="Dockerfile"
FROM node:lts AS base

WORKDIR /src
Expand Down

0 comments on commit 25349a9

Please sign in to comment.