Skip to content

Commit

Permalink
set allowedfiletypes and filetype for external files (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed Jan 5, 2024
1 parent 870e1d9 commit b87ddcb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ Source code for the API powering [**wanderer.moe**](https://wanderer.moe) — us

### Turso

We use Turso (libsql, fork of SQLite) as our database. You will need to install the [Turso CLI](https://docs.turso.tech/reference/turso-cli#installation) then run `turso dev` to start a local database. You can persist data by passing `--db-file <path>`.
We use Turso (libsql, very lightweight fork of SQLite) as our database. You will need to install the [Turso CLI](https://docs.turso.tech/reference/turso-cli#installation) then run `turso dev` to start a local database. You can persist data by passing `--db-file <path>`.

The Turso CLI can be run on Windows using WSL.
The Turso CLI can be run on Windows using WSL and the `--headless` flag.

The API will connect to the local database if the environment is set to `DEV`, else - it will connect to your production database.
To install `sqld` for dev db `wget https://github.com/libsql/sqld/releases/download/v0.21.9/sqld-installer.sh` or whatever the newest version is, then `sh sqld-installer.sh`.

The API will connect to the local database if the environment is set to `DEV` in `.env`, else - it will connect to your production database.

To generate seed data, generate and migrate, you can run `pnpm drizzle:init:dev`.

### Wrangler

Configuration is in `wrangler.toml`.

You will require either a workers paid plan **or to set your worker to unbound** for authentication and password hashing to work.
You will most likely require a workers paid plan for authentication and password hashing to work.

Required environment variables are viewable in `./src/worker-configuration.d.ts`.

Expand All @@ -46,7 +48,7 @@ Required environment variables are viewable in `./src/worker-configuration.d.ts`

## Authors

- [@dromzeh][Dromzeh]
- [@dromzeh][dromzeh]

## License

Expand All @@ -55,6 +57,6 @@ Required environment variables are viewable in `./src/worker-configuration.d.ts`
[Banner]: https://files.catbox.moe/qa3eus.svg
[Quality]: https://img.shields.io/codefactor/grade/github/wanderer-moe/api?label=quality&style=for-the-badge
[Cloudflare API Token]: https://dash.cloudflare.com/profile/api-tokens
[Dromzeh]: https://github.com/dromzeh
[dromzeh]: https://github.com/dromzeh
[api.wanderer.moe]: https://api.wanderer.moe
[License]: LICENSE
23 changes: 20 additions & 3 deletions src/v2/db/schema/asset/asset-external-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,32 @@ import { createInsertSchema, createSelectSchema } from "drizzle-zod"
NOTE: this allows for users down the line to link files to assets
*/

type AllowedFileTypes = "atlas" | "skel" | "png" | "jpg" | "jpeg" // this is just temporary

export const assetExternalFile = sqliteTable(
tableNames.assetExternalFile,
{
id: text("id").primaryKey().notNull(),
url: text("url").notNull(),
uploadedById: text("uploaded_by").notNull(),
uploadedByName: text("uploaded_by_name").notNull(),
uploadedDate: integer("uploaded_date").notNull(),
uploadedById: text("uploaded_by")
.notNull()
.references(() => authUser.id, {
onUpdate: "cascade",
onDelete: "cascade",
}),
uploadedByName: text("uploaded_by_name")
.notNull()
.references(() => authUser.username, {
onUpdate: "cascade",
onDelete: "cascade",
}),
uploadedDate: text("uploaded_date")
.notNull()
.$defaultFn(() => {
return new Date().toISOString()
}),
fileSize: integer("file_size").default(0).notNull(),
fileType: text("file_type").notNull().$type<AllowedFileTypes>(),
},
(table) => {
return {
Expand Down

0 comments on commit b87ddcb

Please sign in to comment.