-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Express server using Bun runtime
- Loading branch information
1 parent
c5208f4
commit d0291ec
Showing
11 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
run/ | ||
cache/ | ||
lib/ | ||
log/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "express-bun", | ||
"version": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
{ | ||
"lockfile-version": 1, | ||
"manifest": { | ||
"version": 1, | ||
"install": { | ||
"bun": { | ||
"pkg-path": "bun" | ||
} | ||
}, | ||
"hook": { | ||
"on-activate": " export PORT=3000\n echo \"Value of PORT variable is $PORT\"\n bun install\n" | ||
}, | ||
"profile": { | ||
"common": " echo \"it's gettin' Flox in here\"\n" | ||
}, | ||
"options": { | ||
"systems": [ | ||
"aarch64-darwin", | ||
"aarch64-linux", | ||
"x86_64-darwin", | ||
"x86_64-linux" | ||
], | ||
"allow": { | ||
"licenses": [] | ||
}, | ||
"semver": {} | ||
}, | ||
"services": { | ||
"express": { | ||
"command": "bun server.ts --watch", | ||
"vars": null, | ||
"is-daemon": null, | ||
"shutdown": null, | ||
"systems": null | ||
} | ||
} | ||
}, | ||
"packages": [ | ||
{ | ||
"attr_path": "bun", | ||
"broken": false, | ||
"derivation": "/nix/store/bgj47nj2jji1hp0y6fkffqa35gf9d3iz-bun-1.1.29.drv", | ||
"description": "Incredibly fast JavaScript runtime, bundler, transpiler and package manager – all in one", | ||
"install_id": "bun", | ||
"license": "[ MIT, LGPL-2.1-only ]", | ||
"locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", | ||
"name": "bun-1.1.29", | ||
"pname": "bun", | ||
"rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", | ||
"rev_count": 692963, | ||
"rev_date": "2024-10-14T06:48:30Z", | ||
"scrape_date": "2024-10-16T03:55:11Z", | ||
"stabilities": [ | ||
"unstable" | ||
], | ||
"unfree": false, | ||
"version": "1.1.29", | ||
"outputs_to_install": [ | ||
"out" | ||
], | ||
"outputs": { | ||
"out": "/nix/store/q8gjb6x9dgz2vq761dr50aifd69lsyhk-bun-1.1.29" | ||
}, | ||
"system": "aarch64-darwin", | ||
"group": "toplevel", | ||
"priority": 5 | ||
}, | ||
{ | ||
"attr_path": "bun", | ||
"broken": false, | ||
"derivation": "/nix/store/dpmd8j2ha61jfmnrr4sn238hk0lqn4hd-bun-1.1.29.drv", | ||
"description": "Incredibly fast JavaScript runtime, bundler, transpiler and package manager – all in one", | ||
"install_id": "bun", | ||
"license": "[ MIT, LGPL-2.1-only ]", | ||
"locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", | ||
"name": "bun-1.1.29", | ||
"pname": "bun", | ||
"rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", | ||
"rev_count": 692963, | ||
"rev_date": "2024-10-14T06:48:30Z", | ||
"scrape_date": "2024-10-16T03:55:11Z", | ||
"stabilities": [ | ||
"unstable" | ||
], | ||
"unfree": false, | ||
"version": "1.1.29", | ||
"outputs_to_install": [ | ||
"out" | ||
], | ||
"outputs": { | ||
"out": "/nix/store/9dxgpcvzl461f4q3dgz3c1xcl4h4xwjv-bun-1.1.29" | ||
}, | ||
"system": "aarch64-linux", | ||
"group": "toplevel", | ||
"priority": 5 | ||
}, | ||
{ | ||
"attr_path": "bun", | ||
"broken": false, | ||
"derivation": "/nix/store/h1sla4r1r29g4l7hskm056w7jv5wg1bi-bun-1.1.29.drv", | ||
"description": "Incredibly fast JavaScript runtime, bundler, transpiler and package manager – all in one", | ||
"install_id": "bun", | ||
"license": "[ MIT, LGPL-2.1-only ]", | ||
"locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", | ||
"name": "bun-1.1.29", | ||
"pname": "bun", | ||
"rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", | ||
"rev_count": 692963, | ||
"rev_date": "2024-10-14T06:48:30Z", | ||
"scrape_date": "2024-10-16T03:55:11Z", | ||
"stabilities": [ | ||
"unstable" | ||
], | ||
"unfree": false, | ||
"version": "1.1.29", | ||
"outputs_to_install": [ | ||
"out" | ||
], | ||
"outputs": { | ||
"out": "/nix/store/0hdv8bbyw472agzgwysk7df0hra6zzj1-bun-1.1.29" | ||
}, | ||
"system": "x86_64-darwin", | ||
"group": "toplevel", | ||
"priority": 5 | ||
}, | ||
{ | ||
"attr_path": "bun", | ||
"broken": false, | ||
"derivation": "/nix/store/qig6gh0qpb9c8nl79k7fq7dbzw58wzv0-bun-1.1.29.drv", | ||
"description": "Incredibly fast JavaScript runtime, bundler, transpiler and package manager – all in one", | ||
"install_id": "bun", | ||
"license": "[ MIT, LGPL-2.1-only ]", | ||
"locked_url": "https://github.com/flox/nixpkgs?rev=a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", | ||
"name": "bun-1.1.29", | ||
"pname": "bun", | ||
"rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", | ||
"rev_count": 692963, | ||
"rev_date": "2024-10-14T06:48:30Z", | ||
"scrape_date": "2024-10-16T03:55:11Z", | ||
"stabilities": [ | ||
"unstable" | ||
], | ||
"unfree": false, | ||
"version": "1.1.29", | ||
"outputs_to_install": [ | ||
"out" | ||
], | ||
"outputs": { | ||
"out": "/nix/store/1xgl28bhcsvmw14vfyxlrb5qhmlzjifi-bun-1.1.29" | ||
}, | ||
"system": "x86_64-linux", | ||
"group": "toplevel", | ||
"priority": 5 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version = 1 | ||
|
||
[install] | ||
bun.pkg-path = "bun" | ||
|
||
[hook] | ||
on-activate = ''' | ||
export PORT=3000 | ||
echo "Value of PORT variable is $PORT" | ||
bun install | ||
''' | ||
|
||
[profile] | ||
common = ''' | ||
echo "it's gettin' Flox in here" | ||
''' | ||
|
||
[services] | ||
express.command = "bun server.ts --watch" | ||
|
||
[options] | ||
systems = ["aarch64-darwin", "aarch64-linux", "x86_64-darwin", "x86_64-linux"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"arrowParens": "avoid", | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"printWidth": 80, | ||
"endOfLine": "lf" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# express-bun | ||
|
||
To install dependencies: | ||
|
||
```bash | ||
flox activate | ||
``` | ||
|
||
To run: | ||
|
||
```bash | ||
flox services start | ||
# Verify that the server is up and running | ||
curl localhost:3000 | ||
``` | ||
|
||
To view logs: | ||
```bash | ||
flox services logs express | ||
``` | ||
|
||
To stop the server: | ||
```bash | ||
flox services stop | ||
``` | ||
|
||
This project was created using `bun init` in bun v1.1.29. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"dependencies": { | ||
"express": "^4.21.1" | ||
}, | ||
"devDependencies": { | ||
"@types/bun": "^1.1.11", | ||
"@types/express": "^5.0.0", | ||
"prettier": "^3.3.3" | ||
}, | ||
"scripts": { | ||
"prettier": "prettier --write ." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import express, { type Request, type Response } from 'express' | ||
|
||
const app = express() | ||
const { PORT = 3000 } = process.env | ||
|
||
app.get('/', (_req: Request, res: Response) => { | ||
res.status(200).send('Hello, Flox!\n') | ||
}) | ||
|
||
app.get('/ping', (_req: Request, res: Response) => { | ||
res.status(200).send('pong\n') | ||
}) | ||
|
||
app.listen(PORT, () => { | ||
console.log(`Listening on port ${PORT}...`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
|
||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
|
||
// Some stricter flags | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noPropertyAccessFromIndexSignature": true | ||
} | ||
} |