generated from warmachine028/github-super-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initialized bun express server
- Loading branch information
1 parent
a293c40
commit f824f9e
Showing
15 changed files
with
291 additions
and
7 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,42 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
**/*.trace | ||
**/*.zip | ||
**/*.tar.gz | ||
**/*.tgz | ||
**/*.log | ||
package-lock.json | ||
**/*.bun |
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,15 @@ | ||
# Elysia with Bun runtime | ||
|
||
## Getting Started | ||
To get started with this template, simply paste this command into your terminal: | ||
```bash | ||
bun create elysia ./elysia-example | ||
``` | ||
|
||
## Development | ||
To start the development server run: | ||
```bash | ||
bun run dev | ||
``` | ||
|
||
Open http://localhost:3000/ with your browser to see the result. |
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,24 @@ | ||
{ | ||
"name": "react-query-demo", | ||
"version": "1.0.50", | ||
"type": "module", | ||
"scripts": { | ||
"test": "bun --watch test", | ||
"dev": "bun --watch src/index.ts", | ||
"start": "bun run src/index.ts" | ||
}, | ||
"dependencies": { | ||
"@elysiajs/cors": "^1.1.1", | ||
"@elysiajs/cron": "^1.1.1", | ||
"@elysiajs/swagger": "^1.1.5", | ||
"elysia": "latest" | ||
}, | ||
"devDependencies": { | ||
"bun-types": "latest" | ||
}, | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"typescript": "^5.6.3" | ||
}, | ||
"module": "src/index.js" | ||
} |
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,9 @@ | ||
type GetPostsParams = { | ||
query: { | ||
cursor: string | ||
limit: number | ||
} | ||
} | ||
export const getPosts = async ({ query: { cursor, limit } }: GetPostsParams) => { | ||
console.log(cursor, limit) | ||
} |
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,44 @@ | ||
import { Elysia, t } from 'elysia' | ||
import { swagger } from '@elysiajs/swagger' | ||
import { cors } from '@elysiajs/cors' | ||
import { cron } from '@elysiajs/cron' | ||
import { postRoutes } from '@/routes' | ||
|
||
const port = Bun.env.PORT || 5000 | ||
|
||
new Elysia() | ||
.use( | ||
// Create a cron job to ping the server every 14 minutes | ||
cron({ | ||
name: 'Ping Server', | ||
pattern: '*/14 * * * *', | ||
async run() { | ||
try { | ||
const response = await fetch('https://react-query-demoo.vercel.app') | ||
if (response.ok) { | ||
console.log('Server pinged successfully') | ||
} else { | ||
console.error('Failed to ping server:', response.status, response.statusText) | ||
} | ||
} catch (error) { | ||
console.error('Error pinging server:', error) | ||
} | ||
} | ||
}) | ||
) | ||
.use(cors()) | ||
.use( | ||
swagger({ | ||
path: '/docs', | ||
documentation: { | ||
info: { | ||
title: 'React Query Demo Documentation', | ||
version: '1.0.0' | ||
} | ||
} | ||
}) | ||
) | ||
.get('/favicon.ico', () => Bun.file('public/favicon.ico')) | ||
.get('/', () => '💾 Hello from React Query Demo server') | ||
.use(postRoutes) | ||
.listen(port, () => console.log(`🦊 Elysia is running at http://localhost:${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,10 @@ | ||
import { Elysia, t } from 'elysia' | ||
import { getPosts } from '@/controllers' | ||
|
||
export const postRoutes = new Elysia({ prefix: '/posts' }).get('/', getPosts, { | ||
// | ||
query: t.Object({ | ||
skip: t.Optional(t.String()), | ||
limit: t.Optional(t.Number()) | ||
}) | ||
}) |
Oops, something went wrong.