corrections to schemas
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import BlogPostController from "@/server/controllers/blogpost.controller";
|
||||
|
||||
export default async function DevLogIndex({ query }: { query: { category?: string }}) {
|
||||
const { category } = query;
|
||||
export default async function DevLogIndex() {
|
||||
const controller = new BlogPostController();
|
||||
const posts = await controller.getAll();
|
||||
|
||||
@@ -10,11 +9,10 @@ export default async function DevLogIndex({ query }: { query: { category?: strin
|
||||
<h1>Dev Log</h1>
|
||||
<p>Coming soon...</p>
|
||||
|
||||
{ category ? <p>Searching by category {category}</p> : null }
|
||||
{ posts?.map((post, idx) => {
|
||||
return (
|
||||
<div key={idx}>
|
||||
<a href={`/log/${post._id.toHexString()}`}>{post.title}</a>
|
||||
<a href={`/log/${post._id.toString()}`}>{post.title}</a>
|
||||
<p>{post.author}</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@ export default function FullMusicList({ allResults }: { allResults?: Maybe<Parti
|
||||
? allResults.map((result, idx) => {
|
||||
return (
|
||||
<div key={idx}>
|
||||
<Link href={`/listen/${result.id}`}>{result.name}</Link>
|
||||
<Link href={`/listen/${result._id?.toString()}`}>{result.name}</Link>
|
||||
</div>
|
||||
)
|
||||
}) : <p>No music available for streaming.</p>
|
||||
|
||||
4
env.mjs
4
env.mjs
@@ -6,8 +6,8 @@ const env = createEnv({
|
||||
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
|
||||
|
||||
MONGO_URL: z.string().url(),
|
||||
MONGO_USER: z.string(),
|
||||
MONGO_PASSWORD: z.string(),
|
||||
MONGO_USER: z.string().optional(),
|
||||
MONGO_PASSWORD: z.string().optional(),
|
||||
|
||||
POSTGRES_URL: z.string().url(),
|
||||
POSTGRES_USER: z.string(),
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { S3Client } from '@aws-sdk/client-s3';
|
||||
// import Redis from 'ioredis';
|
||||
import pg from 'pg';
|
||||
import { createDBClient } from '../db/createClient';
|
||||
import { Maybe, must } from '@/util/helpers';
|
||||
import { createS3Client } from '../s3';
|
||||
import createRedisClient from '../cache/createClient';
|
||||
import { Maybe } from '@/util/helpers';
|
||||
import { ParseParams, SafeParseReturnType } from 'zod';
|
||||
import { MongoClient, WithId, Filter, InsertOneResult } from 'mongodb';
|
||||
|
||||
@@ -27,8 +22,6 @@ export default abstract class BaseController<T extends { _id?: any, [key: string
|
||||
}
|
||||
|
||||
async getAll() {
|
||||
'use server';
|
||||
|
||||
let result: Maybe<WithId<T>[]>;
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { env } from "@/env.mjs";
|
||||
import { MongoClient } from "mongodb";
|
||||
import { MongoClient, MongoClientOptions } from "mongodb";
|
||||
|
||||
export function createDBClient() {
|
||||
return new MongoClient(env.MONGO_URL, {
|
||||
auth: {
|
||||
username: env.MONGO_USER,
|
||||
password: env.MONGO_PASSWORD,
|
||||
}
|
||||
})
|
||||
export function createDBClient(opts?: MongoClientOptions) {
|
||||
return new MongoClient(env.MONGO_URL, opts)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ import { z } from 'zod';
|
||||
const filePathMatcher = /^[1-9]{1,3}\.(wav|mp3|(jpe?g)|png)$/;
|
||||
const ZFileName = z.string().regex(filePathMatcher);
|
||||
|
||||
const ObjectId = z.string().regex(/^[0-9a-fA-F]{24}$/);
|
||||
|
||||
export const ZMusicStreamingEntry = z.object({
|
||||
_id: z.any(),
|
||||
_id: ObjectId.optional(),
|
||||
name: z.string().max(100),
|
||||
shortdescription: z.string().max(100),
|
||||
longdescription: z.string().max(1000),
|
||||
@@ -19,7 +21,7 @@ export const ZMusicStreamingEntry = z.object({
|
||||
});
|
||||
|
||||
export const ZBlogPost = z.object({
|
||||
_id: z.any(),
|
||||
_id: ObjectId.optional(),
|
||||
title: z.string().max(100),
|
||||
author: z.string().max(100),
|
||||
content: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user