Fix build and non-random seed
This commit is contained in:
parent
1840e5a786
commit
b0c2c217fe
4 changed files with 13 additions and 9 deletions
|
@ -1,10 +1,11 @@
|
|||
import Router from "koa-router";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import sharp from "sharp";
|
||||
|
||||
import { createAvatar, Style } from "@dicebear/core";
|
||||
import * as openPeeps from "@dicebear/open-peeps";
|
||||
import * as pixelArt from "@dicebear/pixel-art";
|
||||
import * as thumbs from "@dicebear/thumbs";
|
||||
import sharp from "sharp";
|
||||
|
||||
import { isValue, isSize, isStyle } from "../utils/type-guards";
|
||||
|
||||
|
@ -47,7 +48,8 @@ router.get("/random", async (ctx) => {
|
|||
});
|
||||
|
||||
router.get("/:seed", async (ctx) => {
|
||||
const { seed, style = "thumbs", size = "100" } = ctx.query;
|
||||
const { seed } = ctx.params;
|
||||
const { style = "thumbs", size = "100" } = ctx.query;
|
||||
if (!isValue(seed) || !isValidStyle(style) || !isSize(size)) {
|
||||
throw Error("Invalid query");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { ValidationError } from "joi";
|
||||
import Joi from "joi";
|
||||
|
||||
export const isValidationError = (error: unknown): error is ValidationError =>
|
||||
error instanceof ValidationError;
|
||||
export const isValidationError = (
|
||||
error: unknown
|
||||
): error is Joi.ValidationError => error instanceof Joi.ValidationError;
|
||||
|
||||
export const isValue = <T>(value: T | Array<T> | undefined): value is T =>
|
||||
!!value && !Array.isArray(value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue