Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lost22git/test-elysia
https://github.com/lost22git/test-elysia
bun cors elysia prisma sqlite swagger typebox
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lost22git/test-elysia
- Owner: lost22git
- Created: 2023-09-09T14:31:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-13T20:20:05.000Z (about 1 year ago)
- Last Synced: 2023-10-15T11:31:20.967Z (about 1 year ago)
- Topics: bun, cors, elysia, prisma, sqlite, swagger, typebox
- Language: TypeScript
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dev app
## install bun
```shell
rtx install bunrtx use -g bun
```## create test-elysia project
```shell
bun create elysia test-elysiacd test-elysia
```## install prisma
```shell
bun install prisma --save-dev
```### init prisma
```shell
bun x prisma init --datasource-provider sqlite
```### edit `./prisma/schema.prisma` file
```prisma
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schemagenerator client {
provider = "prisma-client-js"
}datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}model Fighter {
id Int @id @default(autoincrement())
name String @unique
skill String
created_at DateTime @default(now())
updated_at DateTime?@@map("fighter")
}
```### edit .env file
```env
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-stringsDATABASE_URL="file:./fighter.db"
```### sync schema to db and generate migrate scripts
```shell
bun x prisma migrate dev --name init-fighter-schema
```### generate prisma client code
```shell
bun x prisma generate
```### use PrismaClient in your ts code
```typescript
import { PrismaClient } from '@prisma/client'const prisma = new PrismaClient()
```# run app
## start app with one instance
```shell
bun src/index.ts
```
or```shell
bun start
```or
```shell
./deploy.sh 1
```## start app with the specified number of instances
```shell
# start with 4 instances
./deploy.sh 4
```