Giter Site home page Giter Site logo

suryapratapsinghsuryavanshi / bunjs_in_production Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 1.0 159 KB

A Bun.js and bun:sqlite based is a demo Production application you can deploy anywhere you want.

Home Page: https://bun.axtras.cloud/

License: MIT License

TypeScript 24.28% HTML 69.17% Shell 6.55%
bun bun-boilerplate bun-js bun-starter bun-template cron-jobs cronjob crontab pm2 sqlite

bunjs_in_production's Introduction

BunJs In Production

A Bun.js and bun:sqlite based is a demo Production application you can deploy anywhere you want.

This is a simple application that generates a unique token with the help of a sole-token, but the package wants a run time to execute the code behind token generation so as to be choose bunjs over nodejs because they can execute code faster or the user can generate code as par request so it is essential to execute the code as faster as we can. And be use database to manage the uniqueness of token, this is not nessory but for demonstration be use Sqlite SqliteDB with bun I think this is a great example here to deal with JSON data in the SQLite Database.

Read More About Bun.js: Bun.sh
Read More About TypeScript: TypeScript
Read More About SQLite: bun:sqlite, SQLite
Read More About Process-Manager-2: PM2

In this web application we do not create a real application here we only see some cases where the bun can help, and how the bun can execute javascript faster as compared to Node.Js or any other JS runtime.

Tech Stack, I choose for this application:
- TypeScript: Because I love to write code in ts, and bun support typescript out of the box.
- For Backend TypeScript runtime, you already know we are using Bun.Js as runtime.
- Database: Bun supports in-built SQLite so I used it because other databases like Redis or MongoDB consume a lot of bandwidth and are not currently compatible with Bun.
- Server side processing: Process Manager 2

Objectively, I can say that currently, BunJs cannot replace NodeJs, but if most of the bugs that occur in the development phase as well as the deployment phase can be fixed, then it can be a good competitor of NodeJs.

For Development

bun create Start a new project with bun.
bun run <file | script> Run JavaScript with bun, a package.json script, or a bin.
bun add <dependency> Add a dependency to package.json.
bun remove <dependency> Remove a dependency to package.json.
bun instal <dependency> Install dependencies for a package.json.

For Deployment

Add those scripts of your package.json file

"scripts": {
    "start": "bun ./src/index.ts",
    "build": "bun bun ./src/index.ts ./src/index.html ./src/db.ts && ./node_modules.bun > node_modules.js",
    "deploy": "npm install -g pm2 && pm2 start bun --name \"bun_in_production\" -- start"
}

bun <file | script> file_name.[ts, js, tsx, jsx]: for running a file.
bun bun <files> is a default bundler for external dependencies.
pm2 for the server-side processing of bun.js.
pm2 start bun --name \"bun_in_production\" -- start start bun script wiht pm2.

For Cron job

You can add the auto-pull.sh to your cron job, it make further development faster.

crontab -e

# add below code

*/2 * * * * bash /home/BunJs_In_Production/auto-pull.sh

Web App Preview | Bun In Production

Web-app


Credits

License

This project is under an MIT license.

bunjs_in_production's People

Contributors

suryapratapsinghsuryavanshi avatar

Stargazers

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

Watchers

 avatar  avatar

bunjs_in_production's Issues

Enhance Usability

Enhance the usability of this, bun-based production-ready web app.

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.