feat(20-01): add tags table, tag service/route, register global-items route
- Create tags table in schema with id, name (unique), createdAt - Generate migration for tags table - Create tag.service.ts with getAllTags (id+name, alphabetical order) - Create tags.ts route with GET / handler - Register /api/global-items and /api/tags routes in index.ts - Add auth skip for GET /api/tags and GET /api/global-items
This commit is contained in:
12
src/server/services/tag.service.ts
Normal file
12
src/server/services/tag.service.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { asc } from "drizzle-orm";
|
||||
import { db as prodDb } from "../../db/index.ts";
|
||||
import { tags } from "../../db/schema.ts";
|
||||
|
||||
type Db = typeof prodDb;
|
||||
|
||||
export async function getAllTags(db: Db = prodDb) {
|
||||
return db
|
||||
.select({ id: tags.id, name: tags.name })
|
||||
.from(tags)
|
||||
.orderBy(asc(tags.name));
|
||||
}
|
||||
Reference in New Issue
Block a user