@sdxc/kit 0.0.0-stage → 2026.10.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +93 -2
- package/changelog.jsonl +1097 -0
- package/config.schema.json +89 -0
- package/dist/author.d.ts +36 -0
- package/dist/author.js +107 -0
- package/dist/bin.d.ts +9 -0
- package/dist/bin.js +10 -0
- package/dist/cli.d.ts +33 -0
- package/dist/cli.js +58 -0
- package/dist/commands/create.d.ts +20 -0
- package/dist/commands/create.js +169 -0
- package/dist/commands/init.d.ts +16 -0
- package/dist/commands/init.js +27 -0
- package/dist/commands/make.d.ts +335 -0
- package/dist/commands/make.js +152 -0
- package/dist/commands/run.d.ts +23 -0
- package/dist/commands/run.js +53 -0
- package/dist/commands/ui/add.d.ts +23 -0
- package/dist/commands/ui/add.js +50 -0
- package/dist/commands/ui/diff.d.ts +20 -0
- package/dist/commands/ui/diff.js +28 -0
- package/dist/commands/ui/list.d.ts +24 -0
- package/dist/commands/ui/list.js +45 -0
- package/dist/commands/ui/remove.d.ts +22 -0
- package/dist/commands/ui/remove.js +48 -0
- package/dist/commands/ui/update.d.ts +23 -0
- package/dist/commands/ui/update.js +37 -0
- package/dist/commands/upgrade.d.ts +30 -0
- package/dist/commands/upgrade.js +184 -0
- package/dist/config.d.ts +81 -0
- package/dist/config.js +157 -0
- package/dist/contract.d.ts +161 -0
- package/dist/contract.js +308 -0
- package/dist/create/github.d.ts +63 -0
- package/dist/create/github.js +172 -0
- package/dist/create/target.d.ts +31 -0
- package/dist/create/target.js +56 -0
- package/dist/create/templates.d.ts +69 -0
- package/dist/create/templates.js +251 -0
- package/dist/dependencies.d.ts +34 -0
- package/dist/dependencies.js +76 -0
- package/dist/diff.d.ts +14 -0
- package/dist/diff.js +103 -0
- package/dist/format.d.ts +21 -0
- package/dist/format.js +40 -0
- package/dist/init.d.ts +40 -0
- package/dist/init.js +100 -0
- package/dist/lock.d.ts +74 -0
- package/dist/lock.js +214 -0
- package/dist/make/declare.d.ts +54 -0
- package/dist/make/declare.js +598 -0
- package/dist/make/generate.d.ts +62 -0
- package/dist/make/generate.js +160 -0
- package/dist/make/imports.d.ts +43 -0
- package/dist/make/imports.js +105 -0
- package/dist/make/index.d.ts +43 -0
- package/dist/make/index.js +140 -0
- package/dist/make/kinds.d.ts +40 -0
- package/dist/make/kinds.js +96 -0
- package/dist/make/migrations.d.ts +41 -0
- package/dist/make/migrations.js +116 -0
- package/dist/make/names.d.ts +31 -0
- package/dist/make/names.js +47 -0
- package/dist/make/stubs.d.ts +44 -0
- package/dist/make/stubs.js +89 -0
- package/dist/middleware.d.ts +44 -0
- package/dist/middleware.js +49 -0
- package/dist/package-manager.d.ts +41 -0
- package/dist/package-manager.js +80 -0
- package/dist/project.d.ts +19 -0
- package/dist/project.js +42 -0
- package/dist/releases.d.ts +40 -0
- package/dist/releases.js +110 -0
- package/dist/testing.d.ts +60 -0
- package/dist/testing.js +148 -0
- package/dist/ui/commands.d.ts +114 -0
- package/dist/ui/commands.js +432 -0
- package/dist/ui/imports.d.ts +46 -0
- package/dist/ui/imports.js +160 -0
- package/dist/ui/layout.d.ts +48 -0
- package/dist/ui/layout.js +138 -0
- package/dist/ui/registry.d.ts +58 -0
- package/dist/ui/registry.js +82 -0
- package/dist/upgrade/changelog.d.ts +50 -0
- package/dist/upgrade/changelog.js +69 -0
- package/dist/upgrade/project.d.ts +62 -0
- package/dist/upgrade/project.js +132 -0
- package/dist/upgrade/prompt.d.ts +51 -0
- package/dist/upgrade/prompt.js +227 -0
- package/dist/upgrade/registry.d.ts +33 -0
- package/dist/upgrade/registry.js +50 -0
- package/lock.schema.json +60 -0
- package/package.json +44 -5
- package/registry/ui/accordion.json +15 -0
- package/registry/ui/alert-dialog.json +20 -0
- package/registry/ui/alert.json +15 -0
- package/registry/ui/aspect-ratio.json +13 -0
- package/registry/ui/attachment.json +15 -0
- package/registry/ui/avatar.json +15 -0
- package/registry/ui/badge.json +13 -0
- package/registry/ui/breadcrumbs.json +15 -0
- package/registry/ui/bubble.json +13 -0
- package/registry/ui/button.json +16 -0
- package/registry/ui/calendar.json +16 -0
- package/registry/ui/card.json +18 -0
- package/registry/ui/carousel.json +15 -0
- package/registry/ui/chart.json +13 -0
- package/registry/ui/checkbox-group.json +13 -0
- package/registry/ui/checkbox.json +16 -0
- package/registry/ui/color-area.json +13 -0
- package/registry/ui/color-field.json +20 -0
- package/registry/ui/color-picker.json +17 -0
- package/registry/ui/color-slider.json +13 -0
- package/registry/ui/color-swatch-picker.json +15 -0
- package/registry/ui/color-swatch.json +13 -0
- package/registry/ui/color-wheel.json +13 -0
- package/registry/ui/combobox.json +15 -0
- package/registry/ui/command.json +13 -0
- package/registry/ui/confirm.json +19 -0
- package/registry/ui/context-menu.json +16 -0
- package/registry/ui/date-field.json +19 -0
- package/registry/ui/date-picker.json +15 -0
- package/registry/ui/date-range-picker.json +16 -0
- package/registry/ui/description.json +13 -0
- package/registry/ui/dialog.json +19 -0
- package/registry/ui/disclosure.json +18 -0
- package/registry/ui/drawer.json +18 -0
- package/registry/ui/drop-indicator.json +13 -0
- package/registry/ui/drop-zone.json +13 -0
- package/registry/ui/empty.json +15 -0
- package/registry/ui/field-error.json +13 -0
- package/registry/ui/file-trigger.json +13 -0
- package/registry/ui/form.json +21 -0
- package/registry/ui/grid-list.json +18 -0
- package/registry/ui/group.json +13 -0
- package/registry/ui/header.json +13 -0
- package/registry/ui/heading-scope.json +20 -0
- package/registry/ui/heading.json +15 -0
- package/registry/ui/highlight.json +16 -0
- package/registry/ui/hover-card.json +13 -0
- package/registry/ui/image-placeholder.json +16 -0
- package/registry/ui/input.json +13 -0
- package/registry/ui/item.json +13 -0
- package/registry/ui/keyboard.json +13 -0
- package/registry/ui/label.json +13 -0
- package/registry/ui/link-button.json +16 -0
- package/registry/ui/link.json +13 -0
- package/registry/ui/listbox.json +15 -0
- package/registry/ui/logo.json +15 -0
- package/registry/ui/marker.json +13 -0
- package/registry/ui/menu.json +19 -0
- package/registry/ui/menubar.json +13 -0
- package/registry/ui/message-scroller.json +16 -0
- package/registry/ui/message.json +13 -0
- package/registry/ui/meter.json +13 -0
- package/registry/ui/modal.json +15 -0
- package/registry/ui/nav-link.json +13 -0
- package/registry/ui/navigation-menu.json +15 -0
- package/registry/ui/number-field.json +15 -0
- package/registry/ui/otp-field.json +15 -0
- package/registry/ui/overlay-arrow.json +13 -0
- package/registry/ui/pagination.json +16 -0
- package/registry/ui/popover.json +13 -0
- package/registry/ui/progress-bar.json +13 -0
- package/registry/ui/radio-group.json +13 -0
- package/registry/ui/range-calendar.json +16 -0
- package/registry/ui/resizable.json +13 -0
- package/registry/ui/scroll-area.json +13 -0
- package/registry/ui/search-field.json +16 -0
- package/registry/ui/section.json +13 -0
- package/registry/ui/select.json +13 -0
- package/registry/ui/selection-indicator.json +13 -0
- package/registry/ui/sentinel-row.json +16 -0
- package/registry/ui/separator.json +13 -0
- package/registry/ui/shared-element.json +13 -0
- package/registry/ui/sheet.json +15 -0
- package/registry/ui/shortcut-list.json +18 -0
- package/registry/ui/sidebar.json +20 -0
- package/registry/ui/skeleton.json +13 -0
- package/registry/ui/slider.json +16 -0
- package/registry/ui/spinner.json +13 -0
- package/registry/ui/switch.json +16 -0
- package/registry/ui/table.json +16 -0
- package/registry/ui/tabs.json +17 -0
- package/registry/ui/tag-group.json +18 -0
- package/registry/ui/text-field.json +19 -0
- package/registry/ui/text.json +13 -0
- package/registry/ui/textarea.json +13 -0
- package/registry/ui/time-field.json +19 -0
- package/registry/ui/toast.json +16 -0
- package/registry/ui/toggle-button.json +17 -0
- package/registry/ui/toolbar.json +13 -0
- package/registry/ui/tooltip.json +16 -0
- package/registry/ui/tree.json +18 -0
- package/registry/ui/typeset.json +16 -0
- package/registry/ui/youtube-embed.json +16 -0
- package/stubs/command.stub +16 -0
- package/stubs/command.test.stub +21 -0
- package/stubs/controller.api.stub +21 -0
- package/stubs/controller.api.test.stub +18 -0
- package/stubs/controller.form.stub +63 -0
- package/stubs/controller.form.test.stub +61 -0
- package/stubs/controller.stub +24 -0
- package/stubs/controller.test.stub +18 -0
- package/stubs/email.stub +26 -0
- package/stubs/email.test.stub +21 -0
- package/stubs/factory.stub +13 -0
- package/stubs/initializer.stub +9 -0
- package/stubs/initializer.test.stub +16 -0
- package/stubs/job.cron.stub +16 -0
- package/stubs/job.stub +15 -0
- package/stubs/job.test.stub +18 -0
- package/stubs/mcp.resource.stub +15 -0
- package/stubs/mcp.stub +13 -0
- package/stubs/mcp.test.stub +18 -0
- package/stubs/middleware.stub +16 -0
- package/stubs/middleware.test.stub +16 -0
- package/stubs/migration.stub +1 -0
- package/stubs/model.stub +33 -0
- package/stubs/model.test.stub +18 -0
- package/stubs/policy.stub +16 -0
- package/stubs/policy.test.stub +20 -0
- package/stubs/service.stub +17 -0
- package/stubs/service.test.stub +17 -0
- package/stubs/validator.stub +17 -0
- package/stubs/validator.test.stub +25 -0
- package/templates/app/.env.example +16 -0
- package/templates/app/README.md +84 -0
- package/templates/app/app/commands/about.test.ts +29 -0
- package/templates/app/app/commands/about.ts +34 -0
- package/templates/app/app/commands/db/console.ts +6 -0
- package/templates/app/app/commands/db/migrate.test.ts +30 -0
- package/templates/app/app/commands/db/migrate.ts +55 -0
- package/templates/app/app/commands/index.ts +31 -0
- package/templates/app/app/commands/typegen.test.ts +17 -0
- package/templates/app/app/commands/typegen.ts +16 -0
- package/templates/app/app/http/controllers/api/health.tsx +15 -0
- package/templates/app/app/http/controllers/api/not-found.tsx +16 -0
- package/templates/app/app/http/controllers/api/openapi.tsx +17 -0
- package/templates/app/app/http/controllers/home.tsx +30 -0
- package/templates/app/app/http/controllers/mcp.tsx +16 -0
- package/templates/app/app/http/controllers/not-found.tsx +30 -0
- package/templates/app/app/http/controllers/robots.test.ts +18 -0
- package/templates/app/app/http/controllers/robots.ts +24 -0
- package/templates/app/app/http/controllers/sitemap.test.ts +28 -0
- package/templates/app/app/http/controllers/sitemap.ts +25 -0
- package/templates/app/app/http/middleware/api.ts +10 -0
- package/templates/app/app/http/middleware/page.test.ts +40 -0
- package/templates/app/app/http/middleware/page.ts +49 -0
- package/templates/app/app/http/middleware/server-timing.test.ts +15 -0
- package/templates/app/app/http/middleware/server-timing.ts +42 -0
- package/templates/app/app/initializers/assets.ts +11 -0
- package/templates/app/app/initializers/captcha.ts +11 -0
- package/templates/app/app/initializers/cli.ts +75 -0
- package/templates/app/app/initializers/database.test.ts +18 -0
- package/templates/app/app/initializers/database.ts +18 -0
- package/templates/app/app/initializers/dispatcher.ts +36 -0
- package/templates/app/app/initializers/honeypot.ts +11 -0
- package/templates/app/app/initializers/i18n.test.ts +16 -0
- package/templates/app/app/initializers/i18n.ts +28 -0
- package/templates/app/app/initializers/local-database.test.ts +33 -0
- package/templates/app/app/initializers/local-database.ts +53 -0
- package/templates/app/app/initializers/logger.ts +10 -0
- package/templates/app/app/initializers/mail.test.ts +27 -0
- package/templates/app/app/initializers/mail.ts +11 -0
- package/templates/app/app/initializers/mcp.ts +16 -0
- package/templates/app/app/initializers/openapi.ts +21 -0
- package/templates/app/app/initializers/router.test.ts +61 -0
- package/templates/app/app/initializers/router.tsx +111 -0
- package/templates/app/app/initializers/seo.ts +15 -0
- package/templates/app/app/initializers/session.test.ts +34 -0
- package/templates/app/app/initializers/session.ts +29 -0
- package/templates/app/app/initializers/spam.ts +10 -0
- package/templates/app/app/jobs/index.ts +10 -0
- package/templates/app/app/mcp/resources/index.ts +9 -0
- package/templates/app/app/mcp/tools/index.ts +10 -0
- package/templates/app/app/models/index.ts +10 -0
- package/templates/app/app/services/migrations.test.ts +45 -0
- package/templates/app/app/services/migrations.ts +60 -0
- package/templates/app/app/test/cloudflare-workers.ts +25 -0
- package/templates/app/bootstrap/browser.ts +27 -0
- package/templates/app/bootstrap/cli.ts +9 -0
- package/templates/app/bootstrap/worker.ts +31 -0
- package/templates/app/cloudflare.config.ts +56 -0
- package/templates/app/config/constants.ts +19 -0
- package/templates/app/config/problems.ts +24 -0
- package/templates/app/config/security-policy.ts +34 -0
- package/templates/app/config/security-txt.ts +28 -0
- package/templates/app/database/migrations/.gitkeep +0 -0
- package/templates/app/gitignore +9 -0
- package/templates/app/package.json +68 -0
- package/templates/app/resources/layouts/document.tsx +79 -0
- package/templates/app/resources/locales/en.json +10 -0
- package/templates/app/routes/api.ts +29 -0
- package/templates/app/routes/web.ts +14 -0
- package/templates/app/tsconfig.json +40 -0
- package/templates/app/vite.config.ts +44 -0
package/stubs/model.stub
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} model and its table: describe what a row records and the rules that keep it
|
|
3
|
+
* consistent. Keep the columns in step with the migration that creates the table.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link https://sdxc.dev/docs/data-and-background-work/data-models}
|
|
6
|
+
* @see {@link https://sdxc.dev/api/data-model}{{header}}
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { TableRow } from "remix/data-table";
|
|
10
|
+
|
|
11
|
+
import { column as c, table } from "remix/data-table";
|
|
12
|
+
import { createModel } from "@sdxc/data-model";
|
|
13
|
+
import { generateUUID } from "@sdxc/uuid/v7";
|
|
14
|
+
|
|
15
|
+
/** The `{{snake}}` table, as its migration creates it. */
|
|
16
|
+
export const {{key}}Table = table({
|
|
17
|
+
name: "{{snake}}",
|
|
18
|
+
columns: {
|
|
19
|
+
id: c.text().primaryKey(),
|
|
20
|
+
created_at: c.integer(),
|
|
21
|
+
updated_at: c.integer(),
|
|
22
|
+
// TODO: add the columns the migration creates
|
|
23
|
+
},
|
|
24
|
+
/** `create` and `update` stamp `created_at` and `updated_at` with the database's clock. */
|
|
25
|
+
timestamps: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/** One {{title}} row as it reads back from the database. */
|
|
29
|
+
export type {{Name}}Row = TableRow<typeof {{key}}Table>;
|
|
30
|
+
|
|
31
|
+
export const {{Name}} = createModel({{key}}Table, { generateId: generateUUID });
|
|
32
|
+
|
|
33
|
+
export default {{Name}};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} model.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://sdxc.dev/docs/data-and-background-work/data-models}
|
|
5
|
+
* @see {@link https://sdxc.dev/docs/operations-and-testing/testing}{{header}}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, expect, test } from "vitest";
|
|
9
|
+
|
|
10
|
+
import { {{Name}} } from "{{specifier}}";
|
|
11
|
+
|
|
12
|
+
describe("{{Name}}", () => {
|
|
13
|
+
test("is defined over its table", () => {
|
|
14
|
+
expect({{Name}}).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test.todo("keeps a {{title}} row consistent");
|
|
18
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} policy: describe who may do what, and why the rule sits here.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://sdxc.dev/docs/identity-and-security/authorization}
|
|
5
|
+
* @see {@link https://sdxc.dev/api/authz}{{header}}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Who an authorization rule is asked about; `null` for an anonymous visitor. */
|
|
9
|
+
export interface Actor {
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Whether `actor` passes the {{title}} rule. */
|
|
14
|
+
export function {{key}}(actor: Actor | null): boolean {
|
|
15
|
+
return actor !== null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} policy.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://sdxc.dev/docs/identity-and-security/authorization}
|
|
5
|
+
* @see {@link https://sdxc.dev/docs/operations-and-testing/testing}{{header}}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, expect, test } from "vitest";
|
|
9
|
+
|
|
10
|
+
import { {{key}} } from "{{specifier}}";
|
|
11
|
+
|
|
12
|
+
describe("{{key}}", () => {
|
|
13
|
+
test("refuses an anonymous visitor", () => {
|
|
14
|
+
expect({{key}}(null)).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("allows a signed-in actor", () => {
|
|
18
|
+
expect({{key}}({ id: "1" })).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {{title}}: describe the rule this service carries out across models, and what a caller can
|
|
3
|
+
* rely on when it succeeds.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link https://sdxc.dev/docs/conventions/result-everywhere}
|
|
6
|
+
* @see {@link https://sdxc.dev/api/result}{{header}}
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Result } from "@sdxc/result";
|
|
10
|
+
|
|
11
|
+
import { success } from "@sdxc/result";
|
|
12
|
+
|
|
13
|
+
/** Carries out {{title}}; a failure says why nothing changed. */
|
|
14
|
+
export function {{key}}(): Result<void, Error> {
|
|
15
|
+
// TODO: carry out the rule across models
|
|
16
|
+
return success(undefined);
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} service.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://sdxc.dev/docs/conventions/result-everywhere}
|
|
5
|
+
* @see {@link https://sdxc.dev/docs/operations-and-testing/testing}{{header}}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { isSuccess } from "@sdxc/result";
|
|
9
|
+
import { describe, expect, test } from "vitest";
|
|
10
|
+
|
|
11
|
+
import { {{key}} } from "{{specifier}}";
|
|
12
|
+
|
|
13
|
+
describe("{{key}}", () => {
|
|
14
|
+
test("succeeds", () => {
|
|
15
|
+
expect(isSuccess({{key}}())).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fields the {{title}} form submits, validated before anything trusts them.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://sdxc.dev/docs/building-remix-apps/forms-and-params}
|
|
5
|
+
* @see {@link https://sdxc.dev/api/validate}{{header}}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as s from "remix/data-schema";
|
|
9
|
+
import * as f from "remix/data-schema/form-data";
|
|
10
|
+
|
|
11
|
+
/** The {{title}} fields, as an action receives them. */
|
|
12
|
+
export const {{Name}}Schema = f.object({
|
|
13
|
+
name: f.field(s.string()),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/** A validated {{title}} submission. */
|
|
17
|
+
export type {{Name}}Input = s.InferOutput<typeof {{Name}}Schema>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} form's validation.
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://sdxc.dev/docs/building-remix-apps/forms-and-params}
|
|
5
|
+
* @see {@link https://sdxc.dev/docs/operations-and-testing/testing}{{header}}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { isFailure, isSuccess } from "@sdxc/result";
|
|
9
|
+
import { validate } from "@sdxc/validate";
|
|
10
|
+
import { describe, expect, test } from "vitest";
|
|
11
|
+
|
|
12
|
+
import { {{Name}}Schema } from "{{specifier}}";
|
|
13
|
+
|
|
14
|
+
describe("{{Name}}Schema", () => {
|
|
15
|
+
test("accepts a complete submission", async () => {
|
|
16
|
+
let form = new FormData();
|
|
17
|
+
form.set("name", "Ada");
|
|
18
|
+
|
|
19
|
+
expect(isSuccess(await validate(form, {{Name}}Schema))).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("refuses a submission missing a field", async () => {
|
|
23
|
+
expect(isFailure(await validate(new FormData(), {{Name}}Schema))).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# The Worker's secrets, with values for local development. `sdxc create` copies this file to
|
|
2
|
+
# `.dev.vars`, which `bun dev` reads; copy it yourself in a fresh clone. Set each one for
|
|
3
|
+
# production with `cf workers secrets update <NAME>` before the first deploy.
|
|
4
|
+
|
|
5
|
+
# Signs the session cookie. Use a long random value in production; changing it signs every
|
|
6
|
+
# visitor out.
|
|
7
|
+
SESSION_SECRET=development-session-secret
|
|
8
|
+
|
|
9
|
+
# Signs the honeypot fields every page form carries. Use a long random value in production.
|
|
10
|
+
HONEYPOT_SECRET=development-honeypot-secret
|
|
11
|
+
|
|
12
|
+
# Cloudflare Turnstile, which a form asks a visitor to pass. These are Cloudflare's test keys,
|
|
13
|
+
# which render a visible widget that always passes; create a widget in the Cloudflare dashboard
|
|
14
|
+
# for the production keys.
|
|
15
|
+
TURNSTILE_SITE_KEY=1x00000000000000000000AA
|
|
16
|
+
TURNSTILE_SECRET_KEY=1x0000000000000000000000000000000AA
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# App
|
|
2
|
+
|
|
3
|
+
A Remix v3 app on Cloudflare Workers, built on the `@sdxc/*` packages.
|
|
4
|
+
|
|
5
|
+
## Start
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bun install
|
|
9
|
+
sdxc run typegen
|
|
10
|
+
sdxc run db migrate
|
|
11
|
+
bun dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
In a fresh clone, copy `.env.example` to `.dev.vars` first. Run `sdxc run typegen` again
|
|
15
|
+
whenever you change a binding in `cloudflare.config.ts`.
|
|
16
|
+
|
|
17
|
+
## Everyday commands
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
sdxc make controller about # a page, mapped in routes/web.ts
|
|
21
|
+
sdxc make controller api/keys --routes api # a JSON endpoint
|
|
22
|
+
sdxc make migration create-posts # then: sdxc run db migrate
|
|
23
|
+
sdxc make model post # then: ctx.models.post
|
|
24
|
+
sdxc make job reports/daily --cron "0 8 * * *"
|
|
25
|
+
sdxc make email welcome # then: ctx.email.later(new WelcomeEmail(to, copy))
|
|
26
|
+
sdxc make command users/grant # then: sdxc run users grant
|
|
27
|
+
|
|
28
|
+
sdxc run db console # SQL prompt over the local database
|
|
29
|
+
bun check # format, lint and types
|
|
30
|
+
bun test
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`sdxc make` writes the file where it belongs with a test beside it, and maps it so it works
|
|
34
|
+
right away. `sdxc` comes with the project; `npm add -g @sdxc/kit` puts it on your path.
|
|
35
|
+
|
|
36
|
+
## Where things go
|
|
37
|
+
|
|
38
|
+
| Folder | What lives there |
|
|
39
|
+
| ---------------------- | ----------------------------------------------------------- |
|
|
40
|
+
| `routes/` | URL contracts: `web.ts` for pages, `api.ts` for endpoints |
|
|
41
|
+
| `app/http/` | Controllers, middleware and input validators |
|
|
42
|
+
| `app/models/` | Database models, one per table |
|
|
43
|
+
| `app/jobs/` | Background jobs |
|
|
44
|
+
| `app/emails/` | Emails |
|
|
45
|
+
| `app/commands/` | Commands for `sdxc run` |
|
|
46
|
+
| `app/initializers/` | The one instance of each service: database, mailer, router… |
|
|
47
|
+
| `resources/` | Layouts, components and translations (`resources/locales/`) |
|
|
48
|
+
| `database/migrations/` | SQL migrations |
|
|
49
|
+
| `config/` | Site settings, security policy, security.txt, API problems |
|
|
50
|
+
|
|
51
|
+
## What a handler gets
|
|
52
|
+
|
|
53
|
+
Every request, job and command can read:
|
|
54
|
+
|
|
55
|
+
- `ctx.db` and `ctx.models`: the D1 database and its models.
|
|
56
|
+
- `ctx.email` (requests and commands): sends email, `later()` after the response or
|
|
57
|
+
`await send()` before it. A command prints it instead of sending it.
|
|
58
|
+
- `ctx.log`, with a `trace_id` shared by a request and the jobs it starts.
|
|
59
|
+
- `ctx.timing`: adds entries to the `Server-Timing` header (requests only).
|
|
60
|
+
- `ctx.ip` and `ctx.userAgent` (requests only): the client's address, or `null`, and its parsed
|
|
61
|
+
`User-Agent` header.
|
|
62
|
+
|
|
63
|
+
Pages also get `ctx.session`, `ctx.intl` for translated copy, and forms protected by a
|
|
64
|
+
honeypot, Turnstile and a spam filter. Before a page loads a script, style, image or font from
|
|
65
|
+
another origin, add that origin to `config/security-policy.ts`. API errors use the catalog in
|
|
66
|
+
`config/problems.ts`.
|
|
67
|
+
|
|
68
|
+
## Before the first deploy
|
|
69
|
+
|
|
70
|
+
1. Create the resources and put their ids in `cloudflare.config.ts`:
|
|
71
|
+
`bunx cf d1 create <name>`, `bunx cf kv namespace create <name>`, and
|
|
72
|
+
`bunx cf queues create <name>` (the `name` in `package.json`).
|
|
73
|
+
2. Set every secret in `.env.example` with `bunx cf workers secrets update <NAME>`.
|
|
74
|
+
3. Edit `config/constants.ts`: your domain, site name and description, and a `MAIL_FROM`
|
|
75
|
+
address on a domain with Cloudflare Email Routing.
|
|
76
|
+
4. Put your contact in `config/security-txt.ts`.
|
|
77
|
+
5. Deploy:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
bun check
|
|
81
|
+
bun build
|
|
82
|
+
sdxc run db migrate --remote
|
|
83
|
+
bun cf:deploy
|
|
84
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `about` command, run through the app's command line as `sdxc run about` runs it.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { invoke } from "@sdxc/cli/test";
|
|
6
|
+
import { describe, expect, test } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { cli } from "~/app/initializers/cli";
|
|
9
|
+
|
|
10
|
+
import manifest from "../../package.json" with { type: "json" };
|
|
11
|
+
|
|
12
|
+
describe("about", () => {
|
|
13
|
+
test("prints the app's name and the versions it is built on", async () => {
|
|
14
|
+
let run = await invoke(cli, ["about"]);
|
|
15
|
+
|
|
16
|
+
expect(run.code).toBe(0);
|
|
17
|
+
expect(run.stdout).toContain(manifest.name);
|
|
18
|
+
expect(run.stdout).toContain(`@sdxc/cli ${manifest.dependencies["@sdxc/cli"]}`);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("--json prints the same as one JSON document", async () => {
|
|
22
|
+
let run = await invoke(cli, ["about", "--json"]);
|
|
23
|
+
|
|
24
|
+
expect(JSON.parse(run.stdout)).toMatchObject({
|
|
25
|
+
name: manifest.name,
|
|
26
|
+
remix: manifest.dependencies.remix,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `about`: what this project is built on, read from its own `package.json` and the running
|
|
3
|
+
* process, so a bug report or a support question starts from the exact versions in use.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
7
|
+
|
|
8
|
+
import commandset from "~/app/commands";
|
|
9
|
+
|
|
10
|
+
import manifest from "../../package.json" with { type: "json" };
|
|
11
|
+
|
|
12
|
+
/** The runtime the command line runs on, as `Bun 1.3.0` or `Node 24.1.0`. */
|
|
13
|
+
function runtime(): string {
|
|
14
|
+
let bun = process.versions.bun;
|
|
15
|
+
return bun === undefined ? `Node ${process.versions.node}` : `Bun ${bun}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Prints one line per fact, or with `--json` one document a script can read. */
|
|
19
|
+
export default createCommand(commandset.about, (ctx) => {
|
|
20
|
+
let about = {
|
|
21
|
+
name: manifest.name,
|
|
22
|
+
cli: manifest.dependencies["@sdxc/cli"],
|
|
23
|
+
remix: manifest.dependencies.remix,
|
|
24
|
+
runtime: runtime(),
|
|
25
|
+
};
|
|
26
|
+
if (ctx.flags.json) {
|
|
27
|
+
ctx.stdout(`${JSON.stringify(about, null, 2)}\n`);
|
|
28
|
+
return success();
|
|
29
|
+
}
|
|
30
|
+
ctx.stdout(
|
|
31
|
+
`${about.name}\n @sdxc/cli ${about.cli}\n remix ${about.remix}\n runtime ${about.runtime}\n`,
|
|
32
|
+
);
|
|
33
|
+
return success();
|
|
34
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `db migrate --remote`, which hands the chain to `cf d1 migrations apply` for the production
|
|
3
|
+
* database named in `cloudflare.config.ts`.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { invoke } from "@sdxc/cli/test";
|
|
7
|
+
import { describe, expect, test } from "vitest";
|
|
8
|
+
|
|
9
|
+
import { cli } from "~/app/initializers/cli";
|
|
10
|
+
|
|
11
|
+
describe("db migrate", () => {
|
|
12
|
+
test("--remote applies the chain through cf to the configured database", async () => {
|
|
13
|
+
let run = await invoke(cli, ["db", "migrate", "--remote"], {
|
|
14
|
+
exec: {
|
|
15
|
+
"cf d1 migrations apply 00000000-0000-4000-8000-000000000000 --dir database/migrations": {
|
|
16
|
+
code: 0,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(run.code).toBe(0);
|
|
22
|
+
expect(run.exec[0]?.command.slice(0, 5)).toEqual([
|
|
23
|
+
"cf",
|
|
24
|
+
"d1",
|
|
25
|
+
"migrations",
|
|
26
|
+
"apply",
|
|
27
|
+
"00000000-0000-4000-8000-000000000000",
|
|
28
|
+
]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `db migrate`: applies every migration in `database/migrations/` the database lacks. Locally it
|
|
3
|
+
* writes the SQLite file `bun dev` serves from; with `--remote` it runs `cf d1 migrations apply`
|
|
4
|
+
* against the production database. Safe to run twice: an applied migration is skipped.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
|
|
10
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
11
|
+
import { openDatabase } from "@sdxc/cloudflare-mocks/sqlite";
|
|
12
|
+
import { isFailure } from "@sdxc/result";
|
|
13
|
+
|
|
14
|
+
import commandset from "~/app/commands";
|
|
15
|
+
import { DATABASE_ID, LOCAL_DATABASE_FILE, PROJECT_ROOT } from "~/app/initializers/local-database";
|
|
16
|
+
import { applyMigrations } from "~/app/services/migrations";
|
|
17
|
+
|
|
18
|
+
/** The migration chain `sdxc make migration` writes into, relative to the project's root. */
|
|
19
|
+
const MIGRATIONS_DIRECTORY = "database/migrations";
|
|
20
|
+
|
|
21
|
+
/** Every `.sql` file in the chain, with its SQL. */
|
|
22
|
+
async function readMigrations() {
|
|
23
|
+
let directory = join(PROJECT_ROOT, MIGRATIONS_DIRECTORY);
|
|
24
|
+
let names = (await readdir(directory)).filter((name) => name.endsWith(".sql"));
|
|
25
|
+
return Promise.all(
|
|
26
|
+
names.map(async (name) => ({
|
|
27
|
+
name,
|
|
28
|
+
sql: await readFile(join(directory, name), "utf8"),
|
|
29
|
+
})),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default createCommand(commandset.db.migrate, async (ctx) => {
|
|
34
|
+
if (ctx.flags.remote) {
|
|
35
|
+
let applied = await ctx.exec(
|
|
36
|
+
["cf", "d1", "migrations", "apply", DATABASE_ID, "--dir", MIGRATIONS_DIRECTORY],
|
|
37
|
+
{ cwd: PROJECT_ROOT },
|
|
38
|
+
);
|
|
39
|
+
return isFailure(applied) ? applied : success();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let database = openDatabase(LOCAL_DATABASE_FILE);
|
|
43
|
+
try {
|
|
44
|
+
let applied = applyMigrations(database, await readMigrations());
|
|
45
|
+
if (isFailure(applied)) return applied;
|
|
46
|
+
ctx.stdout(
|
|
47
|
+
applied.data.length === 0
|
|
48
|
+
? "No migrations to apply\n"
|
|
49
|
+
: applied.data.map((name) => `Applied ${name}\n`).join(""),
|
|
50
|
+
);
|
|
51
|
+
return success();
|
|
52
|
+
} finally {
|
|
53
|
+
database.close();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every command the app's command line answers, declared in one contract: the words typed to
|
|
3
|
+
* reach it, its arguments and its flags. Each handler lives in its own file beside this one,
|
|
4
|
+
* and a folder of handlers is a `commands({ … })` group here.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { command, commands, flag } from "@sdxc/cli";
|
|
8
|
+
import { DB_COMMAND } from "@sdxc/database-middleware/cli";
|
|
9
|
+
|
|
10
|
+
/** The app's commands; `sdxc make command <name>` declares one here and maps its handler. */
|
|
11
|
+
export default commands({
|
|
12
|
+
about: command({
|
|
13
|
+
description: "Print the app's name, its @sdxc/cli and remix versions, and the runtime",
|
|
14
|
+
flags: { json: flag.boolean("json", { description: "Print it as JSON" }) },
|
|
15
|
+
}),
|
|
16
|
+
db: commands({
|
|
17
|
+
console: DB_COMMAND,
|
|
18
|
+
migrate: command({
|
|
19
|
+
description: "Apply the migrations in database/migrations the database lacks",
|
|
20
|
+
flags: {
|
|
21
|
+
remote: flag.boolean("remote", {
|
|
22
|
+
description: "Apply them to the production database instead of the local copy",
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
examples: ["db migrate", "db migrate --remote"],
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
typegen: command({
|
|
29
|
+
description: "Write the Worker's env types from cloudflare.config.ts",
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `typegen` command, which hands type generation to `cf` in the project's root.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { invoke } from "@sdxc/cli/test";
|
|
6
|
+
import { describe, expect, test } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { cli } from "~/app/initializers/cli";
|
|
9
|
+
|
|
10
|
+
describe("typegen", () => {
|
|
11
|
+
test("generates the Worker's types with cf", async () => {
|
|
12
|
+
let run = await invoke(cli, ["typegen"], { exec: { "cf workers types": { code: 0 } } });
|
|
13
|
+
|
|
14
|
+
expect(run.code).toBe(0);
|
|
15
|
+
expect(run.exec.map((call) => call.command)).toEqual([["cf", "workers", "types"]]);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `typegen`: writes the Worker's `env` types from `cloudflare.config.ts` through `cf workers
|
|
3
|
+
* types`. Run it after adding or changing a binding or a secret, so `env` and every handler
|
|
4
|
+
* type check against what the Worker receives. Safe to run twice.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
8
|
+
import { isFailure } from "@sdxc/result";
|
|
9
|
+
|
|
10
|
+
import commandset from "~/app/commands";
|
|
11
|
+
import { PROJECT_ROOT } from "~/app/initializers/local-database";
|
|
12
|
+
|
|
13
|
+
export default createCommand(commandset.typegen, async (ctx) => {
|
|
14
|
+
let generated = await ctx.exec(["cf", "workers", "types"], { cwd: PROJECT_ROOT });
|
|
15
|
+
return isFailure(generated) ? generated : success();
|
|
16
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The health check: it answers as soon as the Worker runs, so a monitor tells a deploy that
|
|
3
|
+
* serves from one that fails to start.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createAction } from "remix/router";
|
|
7
|
+
|
|
8
|
+
import api from "~/app/http/middleware/api";
|
|
9
|
+
import routes from "~/routes/api";
|
|
10
|
+
|
|
11
|
+
export default createAction(routes.api.health, {
|
|
12
|
+
middleware: api,
|
|
13
|
+
/** GET /api/health, answered as the `health` operation documents it. */
|
|
14
|
+
handler: () => Response.json({ status: "ok" }),
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The API's 404: an unknown path under `/api` answers an RFC 9457 problem document, which a
|
|
3
|
+
* client parses the same way as every other error the API returns.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createAction } from "remix/router";
|
|
7
|
+
|
|
8
|
+
import api from "~/app/http/middleware/api";
|
|
9
|
+
import problems from "~/config/problems";
|
|
10
|
+
import routes from "~/routes/api";
|
|
11
|
+
|
|
12
|
+
export default createAction(routes.api.notFound, {
|
|
13
|
+
middleware: api,
|
|
14
|
+
/** Any method on an unknown `/api` path answers the `notFound` problem. */
|
|
15
|
+
handler: () => problems.notFound(),
|
|
16
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The API's OpenAPI document, served as JSON or, for `?format=yaml`, YAML. It is built from
|
|
3
|
+
* the operations in `routes/api.ts`, so it describes exactly what the handlers parse.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { openapiHandler } from "@sdxc/openapi/router";
|
|
7
|
+
import { createAction } from "remix/router";
|
|
8
|
+
|
|
9
|
+
import api from "~/app/http/middleware/api";
|
|
10
|
+
import { createApiDocument } from "~/app/initializers/openapi";
|
|
11
|
+
import routes from "~/routes/api";
|
|
12
|
+
|
|
13
|
+
export default createAction(routes.api.openapi, {
|
|
14
|
+
middleware: api,
|
|
15
|
+
/** GET /api/openapi.json, naming the origin the request reached as the API's server. */
|
|
16
|
+
handler: (ctx) => openapiHandler(() => createApiDocument(ctx.url.origin).build())(ctx),
|
|
17
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The home page, the first thing a visitor sees. It renders through the document layout,
|
|
3
|
+
* which links the stylesheets and client entry the page middleware resolved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Trans } from "@sdxc/i18n/ui";
|
|
7
|
+
import { createAction } from "remix/router";
|
|
8
|
+
|
|
9
|
+
import page from "~/app/http/middleware/page";
|
|
10
|
+
import DocumentLayout from "~/resources/layouts/document";
|
|
11
|
+
import routes from "~/routes/web";
|
|
12
|
+
|
|
13
|
+
export default createAction(routes.home, {
|
|
14
|
+
middleware: page,
|
|
15
|
+
/** GET / — the welcome page. */
|
|
16
|
+
handler: (ctx) =>
|
|
17
|
+
ctx.render(
|
|
18
|
+
<DocumentLayout
|
|
19
|
+
assets={ctx.assets}
|
|
20
|
+
intl={ctx.intl}
|
|
21
|
+
url={ctx.url}
|
|
22
|
+
title={ctx.intl.t("home.title")}
|
|
23
|
+
>
|
|
24
|
+
<h1>{ctx.intl.t("home.title")}</h1>
|
|
25
|
+
<p>
|
|
26
|
+
<Trans i18nKey="home.body" components={{ file: <code />, command: <code /> }} />
|
|
27
|
+
</p>
|
|
28
|
+
</DocumentLayout>,
|
|
29
|
+
),
|
|
30
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP endpoint an agent connects to. It forwards each request to the app's MCP server,
|
|
3
|
+
* whose tools and resources live in `app/mcp/`.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createAction } from "remix/router";
|
|
7
|
+
|
|
8
|
+
import api from "~/app/http/middleware/api";
|
|
9
|
+
import mcp from "~/app/initializers/mcp";
|
|
10
|
+
import routes from "~/routes/api";
|
|
11
|
+
|
|
12
|
+
export default createAction(routes.mcp, {
|
|
13
|
+
middleware: api,
|
|
14
|
+
/** POST /mcp, answered over Streamable HTTP. */
|
|
15
|
+
handler: (ctx) => mcp.fetch(ctx),
|
|
16
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 404 page for any path no other route claims, with a way back home. An unknown path
|
|
3
|
+
* under `/api` answers a problem document instead, from its own route.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createAction } from "remix/router";
|
|
7
|
+
|
|
8
|
+
import page from "~/app/http/middleware/page";
|
|
9
|
+
import DocumentLayout from "~/resources/layouts/document";
|
|
10
|
+
import routes from "~/routes/web";
|
|
11
|
+
|
|
12
|
+
export default createAction(routes.notFound, {
|
|
13
|
+
middleware: page,
|
|
14
|
+
/** Any method on an unknown path renders the 404 document. */
|
|
15
|
+
handler: (ctx) =>
|
|
16
|
+
ctx.render(
|
|
17
|
+
<DocumentLayout
|
|
18
|
+
assets={ctx.assets}
|
|
19
|
+
intl={ctx.intl}
|
|
20
|
+
url={ctx.url}
|
|
21
|
+
title={ctx.intl.t("notFound.title")}
|
|
22
|
+
>
|
|
23
|
+
<h1>{ctx.intl.t("notFound.title")}</h1>
|
|
24
|
+
<p>
|
|
25
|
+
<a href={routes.home.href()}>{ctx.intl.t("notFound.back")}</a>
|
|
26
|
+
</p>
|
|
27
|
+
</DocumentLayout>,
|
|
28
|
+
{ status: 404 },
|
|
29
|
+
),
|
|
30
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/robots.txt`, fetched through the app's router.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { createWebRouter } from "~/app/initializers/router";
|
|
8
|
+
|
|
9
|
+
describe("robots", () => {
|
|
10
|
+
test("lets every crawler in and points it at the sitemap on SITE_URL", async () => {
|
|
11
|
+
let response = await createWebRouter().fetch("https://preview.example.net/robots.txt");
|
|
12
|
+
|
|
13
|
+
let body = await response.text();
|
|
14
|
+
expect(response.headers.get("content-type")).toBe("text/plain; charset=utf-8");
|
|
15
|
+
expect(body).toContain("User-agent: *");
|
|
16
|
+
expect(body).toContain("Sitemap: https://example.com/sitemap.xml");
|
|
17
|
+
});
|
|
18
|
+
});
|