bun api starter
1.0.0
使用Elysiajs框架构建的基于BUN的API启动器,将MongoDB作为数据库。 Elysiajs,一种安全和快速的框架。 MongoDB,一个强大的NOSQL数据库。该入门者为您的API开发提供了坚实的基础,使您可以专注于独特的业务逻辑。
安装面包和入门软件包。
curl -fsSL https://bun.sh/install | bash
bun install启动开发服务器运行:
$ bun run dev
Environment: development
Bun (?) API Starter is running at localhost:8000
Info: MongoDB connection successful: starter打开http:// localhost:8000/docs使用浏览器查看结果。
curl --request POST
--url http://localhost:8000/login
--header ' Content-Type: application/json '
--data ' {
"email": "[email protected]",
"password": "secret@123"
} ' # development
$ docker compose up -d dev
[+] Running 2/3
⠋ Network bun-api-starter_default Created 1.0s
✔ Container starter-mongodb Started 0.5s
✔ Container starter-dev Started 0.9s
# check logs
$ docker compose logs -f # production
docker build --target production -t bun-api-starter-prod .
docker run -d --rm --env-file .env.docker
-p 8080:8000
-t bun-api-starter-prod:latest # connect URI for root user.
mongodb://rootuser:root%40123@localhost:27017/starter ? authSource=admin # on default export error
const app = new Elysia ();
export default app ;
# double bun server initiated.
$ Bun (?) API Starter is running at localhost:8000
Started server http://localhost:3000
# do this
export const app = new Elysia (); // exception not captured onError.
function controller ( context : Context ) { }
// do this
const controller = ( context : Context ) => { } @cham11ng