Fix build and non-random seed
This commit is contained in:
parent
1840e5a786
commit
b0c2c217fe
4 changed files with 13 additions and 9 deletions
|
@ -3,9 +3,10 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npx tsc",
|
"build": "npx tsc",
|
||||||
"start": "node dist/index.js",
|
"start": "node --experimental-specifier-resolution=node dist/index.js",
|
||||||
"dev": "tsx watch src/index.ts",
|
"dev": "tsx watch src/index.ts",
|
||||||
"preinstall": "yarn config set ignore-engines true"
|
"preinstall": "yarn config set ignore-engines true"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import Router from "koa-router";
|
import Router from "koa-router";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
import sharp from "sharp";
|
||||||
|
|
||||||
import { createAvatar, Style } from "@dicebear/core";
|
import { createAvatar, Style } from "@dicebear/core";
|
||||||
import * as openPeeps from "@dicebear/open-peeps";
|
import * as openPeeps from "@dicebear/open-peeps";
|
||||||
import * as pixelArt from "@dicebear/pixel-art";
|
import * as pixelArt from "@dicebear/pixel-art";
|
||||||
import * as thumbs from "@dicebear/thumbs";
|
import * as thumbs from "@dicebear/thumbs";
|
||||||
import sharp from "sharp";
|
|
||||||
|
|
||||||
import { isValue, isSize, isStyle } from "../utils/type-guards";
|
import { isValue, isSize, isStyle } from "../utils/type-guards";
|
||||||
|
|
||||||
|
@ -47,7 +48,8 @@ router.get("/random", async (ctx) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/:seed", 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)) {
|
if (!isValue(seed) || !isValidStyle(style) || !isSize(size)) {
|
||||||
throw Error("Invalid query");
|
throw Error("Invalid query");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { ValidationError } from "joi";
|
import Joi from "joi";
|
||||||
|
|
||||||
export const isValidationError = (error: unknown): error is ValidationError =>
|
export const isValidationError = (
|
||||||
error instanceof ValidationError;
|
error: unknown
|
||||||
|
): error is Joi.ValidationError => error instanceof Joi.ValidationError;
|
||||||
|
|
||||||
export const isValue = <T>(value: T | Array<T> | undefined): value is T =>
|
export const isValue = <T>(value: T | Array<T> | undefined): value is T =>
|
||||||
!!value && !Array.isArray(value);
|
!!value && !Array.isArray(value);
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||||
|
|
||||||
/* Modules */
|
/* Modules */
|
||||||
"module": "commonjs", /* Specify what module code is generated. */
|
"module": "esnext", /* Specify what module code is generated. */
|
||||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||||
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||||
|
|
Loading…
Reference in a new issue