Skip to content

secus217/elysia-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elysia with Bun runtime template v3

Run it ?

  1. Run directly source code with bun
bun install
bun dev #with watch mode
bun start #without watch mode
  1. Run via docker
docker build -t elysia-bun-runtime-template-v3 .
docker run -p 3000:3000 elysia-bun-runtime-template-v3

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

Features updated via v2

import {Elysia} from "elysia";

new Elysia()
  .get("/admin", async ({user}) => {
    return user
  }, {
    checkAuth: ['admin'], //this route only allow admin role
    detail: {
      tags: ["User"],
      security: [
        {JwtAuth: []}
      ],
    },
  })
  .get("/admin", async ({user}) => {
    return user
  }, {
    checkAuth: ['user'], //this route only allow user role
    detail: {
      tags: ["User"],
      security: [
        {JwtAuth: []}
      ],
    },
  })
  • Other features from last version still same:
    • Auto parse response to JSON if response is mikro-orm entity
    • Global try catch so feel free to throw error in your code (no need try catch)
    • Use Elysia decorate to singleton the service class. or you can do it your self base on use case
  • This template use postgres database, you can change it to any database you want by change it base on the mikro-orm document: https://mikro-orm.io/docs/quick-start

Testing

  • Implementing...

Observability

  • Implementing...

Created by CodingCat, happy coding!# elysia-template git init git add . git commit -m first commit git branch -M main git remote add origin git@github.com:secus217/elysia-template.git git push -u origin main

elysia-template

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published