Skip to content

Commit

Permalink
feat: Add Express server using Bun runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
brendaneamon committed Oct 16, 2024
1 parent c5208f4 commit f74e38d
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 0 deletions.
4 changes: 4 additions & 0 deletions express-bun/.flox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
run/
cache/
lib/
log/
4 changes: 4 additions & 0 deletions express-bun/.flox/env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "express-bun",
"version": 1
}
156 changes: 156 additions & 0 deletions express-bun/.flox/env/manifest.lock
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=8080\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
}
]
}
22 changes: 22 additions & 0 deletions express-bun/.flox/env/manifest.toml
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"]
1 change: 1 addition & 0 deletions express-bun/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
10 changes: 10 additions & 0 deletions express-bun/.prettierrc
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"
}
Binary file added express-bun/bun.lockb
Binary file not shown.
17 changes: 17 additions & 0 deletions express-bun/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"dependencies": {
"express": "^4.21.1"
},
"devDependencies": {
"@types/bun": "^1.1.11",
"@types/express": "^5.0.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.3.3"
},
"scripts": {
"lint": "eslint .",
"format": "prettier --write ."
}
}
16 changes: 16 additions & 0 deletions express-bun/server.ts
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}...`)
})
27 changes: 27 additions & 0 deletions express-bun/tsconfig.json
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,
},
}

0 comments on commit f74e38d

Please sign in to comment.