Initial commit
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# Fresh build directory
|
||||
_fresh/
|
||||
# npm + other dependencies
|
||||
node_modules/
|
||||
vendor/
|
||||
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"denoland.vscode-deno",
|
||||
"bradlc.vscode-tailwindcss"
|
||||
]
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"deno.enable": true,
|
||||
"deno.lint": true,
|
||||
"editor.defaultFormatter": "denoland.vscode-deno",
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "denoland.vscode-deno"
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "denoland.vscode-deno"
|
||||
},
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "denoland.vscode-deno"
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "denoland.vscode-deno"
|
||||
},
|
||||
"[css]": {
|
||||
"editor.defaultFormatter": "denoland.vscode-deno"
|
||||
},
|
||||
"css.lint.unknownAtRules": "ignore"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
## Commands
|
||||
|
||||
- `deno task dev`: dev server (Vite)
|
||||
- `deno task check`: `deno fmt --check`, `deno lint`, and `deno check`. Run this after making changes.
|
||||
- `deno task build`: production build into `_fresh/`
|
||||
|
||||
### Formatting
|
||||
|
||||
`deno fmt` with **tabs**, indent width 4, line width 120, LF line endings (set in `deno.json`). Use double quotes,
|
||||
semicolons and trailing commas.
|
||||
|
||||
### Naming
|
||||
|
||||
- **snake_case** for variables, functions, parameters, props and object/DB fields: `parse_date_dmy`, `selected_section`,
|
||||
`user_id`, `hint_text`.
|
||||
- **PascalCase** for components, interfaces, types and zod schemas
|
||||
- **UPPER_SNAKE** for env/config constants: `FILE_UPLOAD_PATH`, `DEV_MODE`.
|
||||
- Props interfaces are named `<Component>Props` and declared right above the component.
|
||||
|
||||
### Language
|
||||
|
||||
- Everything is in english, always
|
||||
|
||||
### Imports
|
||||
|
||||
- Use the `@/` alias for project files: `import { db } from "@/src/db.ts";`. Imports between files inside `src/` may be
|
||||
relative (`./db.ts`).
|
||||
- Always include the `.ts`/`.tsx` extension.
|
||||
- Put third-party imports first, then a blank line, then local imports.
|
||||
|
||||
### Comments
|
||||
|
||||
Keep comments sparse. Write a short one only when the code doesn't explain itself (e.g. `// Throws if invalid token`).
|
||||
|
||||
### Frontend
|
||||
|
||||
- Use Preact **signals** (`useSignal`, `useComputed`, `Signal` props) for state, not `useState`/`useEffect`.
|
||||
- Components are `export default function Name(props: NameProps)`.
|
||||
- Put code in an island only when it needs client interactivity. Everything else goes in `components/`.
|
||||
- Style with Tailwind classes inline. Use theme colors (`primary-600`, `gray-700`, `error-600`, ...) and the existing
|
||||
primitives (`Button` with `variant`/`size`, `InputField`, `SelectField`, `TextAreaField`, `Link`, `Table`) rather than
|
||||
raw elements. Merge class overrides with `twMerge`.
|
||||
- Avoid React-specific libraries. Vite aliases react to preact, but prefer native Preact solutions.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Very cool encryption service
|
||||
|
||||
Your new Fresh project is ready to go. You can follow the Fresh "Getting Started" guide here:
|
||||
https://fresh.deno.dev/docs/getting-started
|
||||
|
||||
### Usage
|
||||
|
||||
Make sure to install Deno: https://docs.deno.com/runtime/getting_started/installation
|
||||
|
||||
Then start the project in development mode:
|
||||
|
||||
```
|
||||
deno task dev
|
||||
```
|
||||
|
||||
This will watch the project directory and restart as necessary.
|
||||
@@ -0,0 +1,10 @@
|
||||
@import "tailwindcss";
|
||||
.fresh-gradient {
|
||||
background-color: rgb(134, 239, 172);
|
||||
background-image: linear-gradient(
|
||||
to right bottom,
|
||||
rgb(219, 234, 254),
|
||||
rgb(187, 247, 208),
|
||||
rgb(254, 249, 195)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// Import CSS files here for hot module reloading to work.
|
||||
import "./assets/styles.css";
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"nodeModulesDir": "manual",
|
||||
"tasks": {
|
||||
"check": "deno fmt --check . && deno lint . && deno check",
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"start": "deno serve -A _fresh/server.js",
|
||||
"update": "deno run -A -r jsr:@fresh/update ."
|
||||
},
|
||||
"lint": {
|
||||
"rules": {
|
||||
"tags": [
|
||||
"fresh",
|
||||
"recommended"
|
||||
]
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
"**/_fresh/*"
|
||||
],
|
||||
"imports": {
|
||||
"@/": "./",
|
||||
"fresh": "jsr:@fresh/core@^2.3.3",
|
||||
"preact": "npm:preact@^10.29.1",
|
||||
"@preact/signals": "npm:@preact/signals@^2.9.0",
|
||||
"@fresh/plugin-vite": "jsr:@fresh/plugin-vite@^1.1.2",
|
||||
"vite": "npm:vite@^7.1.3",
|
||||
"tailwindcss": "npm:tailwindcss@^4.1.10",
|
||||
"@tailwindcss/vite": "npm:@tailwindcss/vite@^4.1.12"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.asynciterable",
|
||||
"dom.iterable",
|
||||
"deno.ns"
|
||||
],
|
||||
"jsx": "precompile",
|
||||
"jsxImportSource": "preact",
|
||||
"jsxPrecompileSkipElements": [
|
||||
"a",
|
||||
"img",
|
||||
"source",
|
||||
"body",
|
||||
"html",
|
||||
"head",
|
||||
"title",
|
||||
"meta",
|
||||
"script",
|
||||
"link",
|
||||
"style",
|
||||
"base",
|
||||
"noscript",
|
||||
"template"
|
||||
],
|
||||
"types": [
|
||||
"vite/client"
|
||||
]
|
||||
},
|
||||
"fmt": {
|
||||
"useTabs": true,
|
||||
"indentWidth": 4,
|
||||
"lineWidth": 120,
|
||||
"newLineKind": "lf"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { App, staticFiles } from "fresh";
|
||||
import { define, type State } from "./utils.ts";
|
||||
|
||||
export const app = new App<State>();
|
||||
|
||||
app.use(staticFiles());
|
||||
|
||||
// Pass a shared value from a middleware
|
||||
app.use(async (ctx) => {
|
||||
ctx.state.shared = "hello";
|
||||
return await ctx.next();
|
||||
});
|
||||
|
||||
// this is the same as the /api/:name route defined via a file. feel free to delete this!
|
||||
app.get("/api2/:name", (ctx) => {
|
||||
const name = ctx.params.name;
|
||||
return new Response(
|
||||
`Hello, ${name.charAt(0).toUpperCase() + name.slice(1)}!`,
|
||||
);
|
||||
});
|
||||
|
||||
// this can also be defined via a file. feel free to delete this!
|
||||
const exampleLoggerMiddleware = define.middleware((ctx) => {
|
||||
console.log(`${ctx.req.method} ${ctx.req.url}`);
|
||||
return ctx.next();
|
||||
});
|
||||
app.use(exampleLoggerMiddleware);
|
||||
|
||||
// Include file-system based routes here
|
||||
app.fsRoutes();
|
||||
@@ -0,0 +1,16 @@
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
export default define.page(function ({ Component }) {
|
||||
return (
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>vces</title>
|
||||
</head>
|
||||
<body>
|
||||
<Component />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
export default define.page(function (ctx) {
|
||||
return <div></div>;
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { createDefine } from "fresh";
|
||||
|
||||
// This specifies the type of "ctx.state" which is used to share
|
||||
// data among middlewares, layouts and routes.
|
||||
export interface State {
|
||||
shared: string;
|
||||
}
|
||||
|
||||
export const define = createDefine<State>();
|
||||
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [fresh(), tailwindcss()],
|
||||
});
|
||||
Reference in New Issue
Block a user