Skip to content

Commit

Permalink
Add news app code; needs more documentation, but is a better represen…
Browse files Browse the repository at this point in the history
…tation of the framework
  • Loading branch information
tireymorris committed Jul 10, 2024
1 parent 01d0e3f commit e1f9b5b
Show file tree
Hide file tree
Showing 26 changed files with 992 additions and 145 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PORT=1234
DEBUG=false
TELEGRAM_BOT_TOKEN=abcd
TELEGRAM_CHAT_ID=efgh
48 changes: 24 additions & 24 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"babelOptions": {
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
},
"env": {
"browser": true,
"node": true
},
"plugins": [
"react"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"rules": {}
}
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"babelOptions": {
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
},
"env": {
"browser": true,
"node": true
},
"plugins": ["react", "@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/explicit-function-return-type": "error"
}
}

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
Expand All @@ -42,5 +43,7 @@ package-lock.json
**/*.bun

server
worker

db.sqlite
*.db
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
# hyperwave

hyperwave combines the benefits of traditional server-rendered applications with the flexibility of modern client-side frameworks.
hyperwave combines the strengths of traditional server-rendered applications with the flexibility of modern client-side frameworks. It is designed to deliver fast, responsive applications while providing a streamlined developer experience.

- **Performance:** Server-side rendering ensures fast, responsive applications, tailored to produce the smallest possible bundles.
- **Developer experience:** HTMX and Tailwind provide a minimalistic and declarative approach to building user interfaces
- **Deployment:** bun applications can be easily deployed on any platform as portable binaries
- Performance: Only 200 lines of JS with zero client side dependencies. Works well in 2G network conditions.
- Developer Experience: tailwind-compatible syntax and html over the wire offer a minimalistic and declarative approach to UI development.
- Deployment: Bun applications can be deployed easily on any platform as portable binaries.

## Getting started
```
$ git clone https://github.com/tireymorris/hyperwave.git
$ cd hyperwave
$ bun install
$ bun dev
```

Follow these steps to start developing with hyperwave:
Navigate to http://localhost:1234 in your browser and start editing server.tsx to observe your changes live.

1. Clone the repository:
remove any of the articles code from the example if you want, it's not many lines. see the server, model files, routes, and db.ts.

```sh
git clone https://github.com/tireymorris/hyperwave.git
cd hyperwave
```

2. Install dependencies:
## hyperwave.js

```sh
bun install
```
dynamically load content on user events, without requiring a page reload.

3. Start the development server:
attaches automatically to any element with an href attribute (besides an anchor/link tag, which is treated as normal)

```sh
bun dev
```
### Usage:

4. Visit `http://localhost:1234` in your browser.
```
<div href="/next-page" target="#content"></div>
```

5. Start editing `server.tsx` to see your changes live.
- `trigger`: Event that triggers loading (e.g., click, scroll).
- `method`: HTTP request method (e.g., GET, POST).
- `debounce`: Delay in milliseconds to optimize performance.
- `offset, limit, data-total`: Manage pagination settings.

```
<div href="/next-page" target="#content" trigger="scroll" method="GET" debounce="50" offset="0" limit="10" data-total="100"></div>
```
Binary file modified bun.lockb
Binary file not shown.
18 changes: 18 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
apps: [
{
name: "hyperwave-server",
script: "./dist/server",
env: {
NODE_ENV: "production",
},
},
{
name: "hyperwave-worker",
script: "./dist/worker",
env: {
NODE_ENV: "production",
},
},
],
};
21 changes: 16 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,38 @@
"name": "hyperwave",
"version": "0.2.1",
"scripts": {
"build": "bun build:css && bun build --compile ./src/server.tsx",
"build": "bun build:css && bun build:server && bun build:worker",
"build:css": "unocss \"src/**/*.tsx\" -o public/styles/uno.css",
"css": "unocss --watch \"src/**/*.tsx\" -o public/styles/uno.css",
"build:server": "bun build --compile ./src/server.tsx --outfile ./dist/server",
"build:worker": "bun build --compile ./src/worker.ts --outfile ./dist/worker",
"css:watch": "unocss --watch \"src/**/*.tsx\" -o public/styles/uno.css",
"db": "bun run src/db.ts",
"dev": "bun install && concurrently --restart-tries=3 \"bun css\" \"nodemon --watch src --ext ts,tsx --exec 'bun run --hot src/server.tsx'\"",
"dev": "bun install && DEBUG=true concurrently --restart-tries=3 \"bun css:watch\" \"bun server:watch\" \"bun worker\"",
"prettier": "bunx prettier --write src/ test/ --plugin prettier-plugin-tailwindcss",
"server:watch": "nodemon --watch src --ext ts,tsx --exec 'bun run --hot src/server.tsx'",
"start": "bun run build && pm2 start; pm2 reload all --update-env",
"start:debug": "DEBUG=true bun run build && pm2 start; pm2 reload all --update-env",
"stop": "pm2 kill",
"server": "bun run --hot src/server.tsx",
"test": "bun run test",
"update-deps": "bunx npm-check-updates -u && bun install"
"test": "NODE_ENV=test bun run test",
"update-deps": "bunx npm-check-updates -u && bun install",
"worker": "bun run src/worker.ts"
},
"dependencies": {
"@unocss/preset-web-fonts": "^0.61.3",
"cheerio": "^1.0.0-rc.12",
"hono": "^4.4.12",
"nodemon": "^3.1.4",
"unocss": "^0.61.3",
"uuid": "^10.0.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/bun": "^1.1.6",
"@unocss/cli": "^0.61.3",
"bun-types": "^1.1.18",
"concurrently": "^8.2.2",
"pm2": "^5.4.2",
"prettier": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.5"
},
Expand Down
Loading

0 comments on commit e1f9b5b

Please sign in to comment.