Skip to content

Commit

Permalink
finished metadata file stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshay committed Oct 8, 2023
1 parent 4054f82 commit c3940df
Show file tree
Hide file tree
Showing 35 changed files with 1,480 additions and 640 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-students-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astro-aws/constructs": patch
---

Use metadata file from adapter to configure constructs
5 changes: 5 additions & 0 deletions .changeset/poor-meals-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astro-aws/adapter": patch
---

Write a metadata file for constructs package
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
matrix:
node_version:
- 18
- 20
cmd:
- build
- test
Expand Down
1 change: 0 additions & 1 deletion .prettierrc.cjs

This file was deleted.

10 changes: 5 additions & 5 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
"start": "astro dev"
},
"dependencies": {
"@astrojs/starlight": "^0.10.1",
"astro": "^3.1.1",
"@astrojs/starlight": "^0.11.0",
"astro": "^3.2.3",
"sharp": "^0.32.6"
},
"devDependencies": {
"@astro-aws/adapter": "workspace:^",
"eslint": "^8.49.0",
"eslint": "^8.51.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.1"
"rimraf": "^5.0.5"
},
"engines": {
"node": "18.x"
"node": "18.x || 20.x"
}
}
2 changes: 2 additions & 0 deletions apps/docs/src/content/docs/guides/01-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ description: Getting started guide

Astro AWS is an [Astro](https://astro.build/) SSR adapter and constructs for deploying your Astro application to AWS.

> **IMPORTANT NOTE:** These packages only provide the bare minimum AWS CDK configuration to get your application running. Everything that does not need to be configured uses the default values AWS provides.
## Start your first Astro project

Create a new Astro project using the `create-astro` CLI then add the Astro AWS adapter.
Expand Down
8 changes: 4 additions & 4 deletions apps/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"dependencies": {
"@astro-aws/constructs": "workspace:^",
"@astro-aws/docs": "workspace:^",
"aws-cdk": "^2.96.2",
"aws-cdk-lib": "^2.96.2",
"constructs": "^10.2.70",
"eslint": "^8.49.0",
"aws-cdk": "^2.100.0",
"aws-cdk-lib": "^2.100.0",
"constructs": "^10.3.0",
"eslint": "^8.51.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2",
"workspace-tools": "^0.35.2"
Expand Down
6 changes: 1 addition & 5 deletions apps/infra/src/lib/constants/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,36 @@ const ENVIRONMENT_PROPS: Record<Environment, AstroAWSStackProps> = {
alias: "static.dev",
environment: Environments.DEV,
hostedZoneName: "astro-aws.org",
output: "static",
package: "@astro-aws/docs",
},
[Environments.EDGE]: {
...base,
alias: "edge.dev",
edge: true,
env: {
...base.env,
region: "us-east-1",
},
environment: Environments.EDGE,
hostedZoneName: "astro-aws.org",
output: "edge",
package: "@astro-aws/examples-base",
},
[Environments.PROD]: {
...base,
environment: Environments.PROD,
hostedZoneName: "astro-aws.org",
output: "static",
package: "@astro-aws/docs",
},
[Environments.PERSONAL]: {
...base,
environment: Environments.PERSONAL,
output: "static",
package: "@astro-aws/docs",
},
[Environments.SSR]: {
...base,
alias: "ssr.dev",
environment: Environments.SSR,
hostedZoneName: "astro-aws.org",
output: "server",
package: "@astro-aws/examples-base",
},
} as const
Expand Down
7 changes: 3 additions & 4 deletions apps/infra/src/lib/stacks/website-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class WebsiteStack extends Stack {
alias,
cloudwatchDashboard,
environment,
output,
edge,
certificate,
hostedZone,
} = props
Expand Down Expand Up @@ -112,16 +112,15 @@ export class WebsiteStack extends Stack {
: undefined,
},
lambdaFunction: {
architecture:
output === "edge" ? Architecture.X86_64 : Architecture.ARM_64,
architecture: edge ? Architecture.X86_64 : Architecture.ARM_64,
},
s3Bucket: {
serverAccessLogsBucket: accessLogBucket,
serverAccessLogsPrefix: "s3/",
},
},
edge,
outDir: `${this.#getWorkspacePath(props.package)}/dist`,
output,
})

if (hostedZone) {
Expand Down
2 changes: 1 addition & 1 deletion apps/infra/src/lib/types/astro-aws-stack-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type AstroAWSStackProps = Readonly<
}
environment: Environment
hostedZoneName?: string
output: "edge" | "server" | "static"
edge?: boolean
package: string
skipDashboard?: boolean
}
Expand Down
2 changes: 2 additions & 0 deletions examples/base/astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { defineConfig } from "astro/config"
import aws from "@astro-aws/adapter"
import tailwind from "@astrojs/tailwind"

// https://astro.build/config
export default defineConfig({
adapter: aws({
logFnRequest: true,
logFnResponse: true,
}),
integrations: [tailwind()],
output: "hybrid",
})
12 changes: 8 additions & 4 deletions examples/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@
"start": "astro dev"
},
"dependencies": {
"astro": "^3.1.1"
"@astrojs/tailwind": "^5.0.1",
"@faker-js/faker": "^8.1.0",
"astro": "^3.2.3",
"daisyui": "^3.9.2",
"tailwindcss": "^3.3.3"
},
"devDependencies": {
"@astro-aws/adapter": "workspace:^",
"@astrojs/check": "^0.2.0",
"eslint": "^8.49.0",
"eslint": "^8.51.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.1",
"rimraf": "^5.0.5",
"typescript": "^5.2.2"
},
"engines": {
"node": "18.x"
"node": "18.x || 20.x"
}
}
61 changes: 0 additions & 61 deletions examples/base/src/components/Card.astro

This file was deleted.

18 changes: 18 additions & 0 deletions examples/base/src/components/home/PersonRow.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
import { generateRandomPersonAsync } from "../../mocks/person";
export type Props = {
row: number;
}
const { row } = Astro.props;
const person = await generateRandomPersonAsync();
---

<tr>
<th>{row}</th>
<td>{person.name}</td>
<td>{person.email}</td>
<td>{person.phone}</td>
</tr>
7 changes: 7 additions & 0 deletions examples/base/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
/// <reference types="astro/client" />
declare namespace App {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Locals {
title: string
rows: number[]
}
}
40 changes: 9 additions & 31 deletions examples/base/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,14 @@ const { title } = Astro.props;
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
</head>
<body>
<slot />
<body class="py-4">
<div class="max-w-4xl mx-auto w-full">
<nav>
<div class="navbar bg-neutral text-neutral-content rounded-lg">
<a class="btn btn-ghost normal-case text-xl" href="/">Astro AWS</a>
</div>
</nav>
<slot />
</div>
</body>
</html>
<style is:global>
:root {
--accent: 136, 58, 234;
--accent-light: 224, 204, 250;
--accent-dark: 49, 10, 101;
--accent-gradient: linear-gradient(
45deg,
rgb(var(--accent)),
rgb(var(--accent-light)) 30%,
white 60%
);
}
html {
font-family: system-ui, sans-serif;
background: #13151a;
background-size: 224px;
}
code {
font-family:
Menlo,
Monaco,
Lucida Console,
Liberation Mono,
DejaVu Sans Mono,
Bitstream Vera Sans Mono,
Courier New,
monospace;
}
</style>
12 changes: 12 additions & 0 deletions examples/base/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// eslint-disable-next-line import/no-unresolved
import { defineMiddleware } from "astro:middleware"

export const onRequest = defineMiddleware(async ({ locals }, next) => {
// eslint-disable-next-line no-param-reassign
locals.title = "New title"
// eslint-disable-next-line no-param-reassign
locals.rows = Array.from({ length: 100 }).map((_, i) => i + 1)

// return a Response or the result of calling `next()`
return next()
})
13 changes: 13 additions & 0 deletions examples/base/src/mocks/person.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { faker } from "@faker-js/faker"

const generateRandomPerson = () => ({
address: faker.location.streetAddress(),
email: faker.internet.email(),
name: faker.person.fullName(),
phone: faker.phone.number(),
})

// eslint-disable-next-line @typescript-eslint/require-await
const generateRandomPersonAsync = async () => generateRandomPerson()

export { generateRandomPerson, generateRandomPersonAsync }
Loading

0 comments on commit c3940df

Please sign in to comment.