Skip to content

Commit

Permalink
Backend init
Browse files Browse the repository at this point in the history
  • Loading branch information
ecumene committed Aug 4, 2024
1 parent 02d4d6c commit cb8dc36
Show file tree
Hide file tree
Showing 21 changed files with 900 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DB=sqlite/bestbubbly.sqlite
GITHUB_OAUTH_CLIENT_ID=
GITHUB_OAUTH_CLIENT_SECRET=
45 changes: 45 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
.env

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

/sqlite/*.sqlite*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun
15 changes: 15 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Elysia with Bun runtime

## Getting Started
To get started with this template, simply paste this command into your terminal:
```bash
bun create elysia ./elysia-example
```

## Development
To start the development server run:
```bash
bun run dev
```

Open http://localhost:3000/ with your browser to see the result.
Binary file added backend/bun.lockb
Binary file not shown.
10 changes: 10 additions & 0 deletions backend/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Config } from "drizzle-kit";

export default {
dialect: "sqlite",
schema: "src/db/schema.ts",
breakpoints: true,
dbCredentials: {
url: process.env.DB || "sqlite/bestbubbly.sqlite",
},
} satisfies Config;
37 changes: 37 additions & 0 deletions backend/drizzle/0000_clear_jasper_sitwell.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
CREATE TABLE `scopes` (
`id` integer PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`scope` text NOT NULL,
`user_uuid` text NOT NULL,
`token_type` text NOT NULL,
`expires_in` integer NOT NULL,
`access_token` text NOT NULL,
`created_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `sessions` (
`id` integer PRIMARY KEY NOT NULL,
`user_id` integer,
`created_at` datetime DEFAULT (current_timestamp) NOT NULL
);
--> statement-breakpoint
CREATE TABLE `user_oauth_providers` (
`id` integer PRIMARY KEY NOT NULL,
`user_id` integer NOT NULL,
`provider` text NOT NULL,
`provider_user_id` text NOT NULL,
`created_at` datetime DEFAULT (current_timestamp) NOT NULL,
`updated_at` datetime DEFAULT (current_timestamp) NOT NULL
);
--> statement-breakpoint
CREATE TABLE `users` (
`id` integer PRIMARY KEY NOT NULL,
`email` text,
`name` text,
`avatar_url` text,
`github_username` text,
`created_at` datetime DEFAULT (current_timestamp) NOT NULL,
`updated_at` datetime DEFAULT (current_timestamp) NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `scopes_access_token_unique` ON `scopes` (`access_token`);
234 changes: 234 additions & 0 deletions backend/drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
{
"version": "6",
"dialect": "sqlite",
"id": "883ddde4-da36-4376-9382-c286edf84817",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"scopes": {
"name": "scopes",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_uuid": {
"name": "user_uuid",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires_in": {
"name": "expires_in",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"scopes_access_token_unique": {
"name": "scopes_access_token_unique",
"columns": [
"access_token"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"sessions": {
"name": "sessions",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "datetime",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(current_timestamp)"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user_oauth_providers": {
"name": "user_oauth_providers",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_user_id": {
"name": "provider_user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "datetime",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(current_timestamp)"
},
"updated_at": {
"name": "updated_at",
"type": "datetime",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(current_timestamp)"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"users": {
"name": "users",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"avatar_url": {
"name": "avatar_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"github_username": {
"name": "github_username",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "datetime",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(current_timestamp)"
},
"updated_at": {
"name": "updated_at",
"type": "datetime",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(current_timestamp)"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
13 changes: 13 additions & 0 deletions backend/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1722809673107,
"tag": "0000_clear_jasper_sitwell",
"breakpoints": true
}
]
}
21 changes: 21 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "app",
"version": "1.0.50",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"generate": "bunx drizzle-kit generate --dialect sqlite --schema ./src/db/schema.ts",
"migrate": "bun src/db/migrate.ts",
"dev": "bun run --watch src/index.ts"
},
"dependencies": {
"@bogeychan/elysia-oauth2": "^0.0.20",
"drizzle-orm": "^0.32.1",
"elysia": "latest",
"sql-log-prettifier": "^0.1.2"
},
"devDependencies": {
"@types/bun": "^1.1.6",
"drizzle-kit": "^0.23.1"
},
"module": "src/index.js"
}
Empty file added backend/sqlite.db
Empty file.
Empty file added backend/sqlite/.gitkeep
Empty file.
Loading

0 comments on commit cb8dc36

Please sign in to comment.