Giter Club home page Giter Club logo

bun-api-starter's Introduction

bun-api-starter

Bun (๐Ÿ”) API Starter CI

A robust Bun-based API starter built using ElysiaJS framework, and MongoDB as database. ElysiaJS, a type-safe and fast framework. MongoDB, a powerful NoSQL database. This starter offers a solid foundation for your API development, allowing you to focus on your unique business logic.

Getting Started

To install bun and starter packages.

curl -fsSL https://bun.sh/install | bash

bun install

Development

To start the development server run:

$ bun run dev
Environment: development
Bun (๐Ÿ”) API Starter is running at localhost:8000
Info: MongoDB connection successful: starter

Open http://localhost:8000/docs with your browser to see the result.

cURL

curl --request POST \
  --url http://localhost:8000/login \
  --header 'Content-Type: application/json' \
  --data '{
  "email": "[email protected]",
  "password": "secret@123"
}'

Docker

# 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

MongoDB Compass

# connect URI for root user.
mongodb://rootuser:root%40123@localhost:27017/starter?authSource=admin

Troubleshooting

# 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) => {}

Happy Coding

@cham11ng

bun-api-starter's People

Contributors

cham11ng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bun-api-starter's Issues

Add tests for auth

  • login success and failure
  • signup success and failure
  • logout success and failure
  • valid and invalid token response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.