This commit is contained in:
tamaina 2022-01-14 20:12:50 +09:00
parent 37bae7b929
commit 97dc9bfa70
3 changed files with 42 additions and 42 deletions

View file

@ -101,7 +101,7 @@ export type SchemaType<p extends Schema> =
p['type'] extends 'string' ? p['type'] extends 'string' ?
p['enum'] extends ReadonlyArray<string> ? p['enum'] extends ReadonlyArray<string> ?
NullOrUndefined<p, p['enum'][number]> : NullOrUndefined<p, p['enum'][number]> :
NullOrUndefined<p, string> : NullOrUndefined<p, string | Date> :
p['type'] extends 'boolean' ? NullOrUndefined<p, boolean> : p['type'] extends 'boolean' ? NullOrUndefined<p, boolean> :
p['type'] extends 'array' ? NullOrUndefined<p, MyType<NonNullable<p['items']>>[]> : p['type'] extends 'array' ? NullOrUndefined<p, MyType<NonNullable<p['items']>>[]> :
p['type'] extends 'object' ? ( p['type'] extends 'object' ? (

View file

@ -18,87 +18,87 @@ export type Param = {
}; };
export interface IEndpointMeta { export interface IEndpointMeta {
stability?: string; //'deprecated' | 'experimental' | 'stable'; readonly stability?: 'deprecated' | 'experimental' | 'stable';
tags?: string[]; readonly tags?: ReadonlyArray<string>;
params?: { readonly params?: {
[key: string]: Param; readonly [key: string]: Param;
}; };
errors?: { readonly errors?: {
[key: string]: { readonly [key: string]: {
message: string; readonly message: string;
code: string; readonly code: string;
id: string; readonly id: string;
}; };
}; };
res?: Schema; readonly res?: Schema;
/** /**
* *
* false * false
*/ */
requireCredential?: boolean; readonly requireCredential?: boolean;
/** /**
* 使 * 使
*/ */
requireAdmin?: boolean; readonly requireAdmin?: boolean;
/** /**
* 使 * 使
*/ */
requireModerator?: boolean; readonly requireModerator?: boolean;
/** /**
* *
* *
* withCredential false * withCredential false
*/ */
limit?: { readonly limit?: {
/** /**
* *
*/ */
key?: string; readonly key?: string;
/** /**
* (ms) * (ms)
* max * max
*/ */
duration?: number; readonly duration?: number;
/** /**
* durationで指定した期間内にいくつまでリクエストできるのか * durationで指定した期間内にいくつまでリクエストできるのか
* duration * duration
*/ */
max?: number; readonly max?: number;
/** /**
* (ms) * (ms)
*/ */
minInterval?: number; readonly minInterval?: number;
}; };
/** /**
* *
* false * false
*/ */
requireFile?: boolean; readonly requireFile?: boolean;
/** /**
* *
* false * false
*/ */
secure?: boolean; readonly secure?: boolean;
/** /**
* *
* *
*/ */
kind?: string; readonly kind?: string;
} }
export interface IEndpoint { export interface IEndpoint {

View file

@ -7,7 +7,7 @@ import { makePaginationQuery } from '../common/make-pagination-query';
export const meta = { export const meta = {
tags: ['meta'], tags: ['meta'],
requireCredential: false as const, requireCredential: false,
params: { params: {
limit: { limit: {
@ -30,48 +30,48 @@ export const meta = {
}, },
res: { res: {
type: 'array' as const, type: 'array',
optional: false as const, nullable: false as const, optional: false, nullable: false,
items: { items: {
type: 'object' as const, type: 'object',
optional: false as const, nullable: false as const, optional: false, nullable: false,
properties: { properties: {
id: { id: {
type: 'string' as const, type: 'string',
optional: false as const, nullable: false as const, optional: false, nullable: false,
format: 'id', format: 'id',
example: 'xxxxxxxxxx', example: 'xxxxxxxxxx',
}, },
createdAt: { createdAt: {
type: 'string' as const, type: 'string',
optional: false as const, nullable: false as const, optional: false, nullable: false,
format: 'date-time', format: 'date-time',
}, },
updatedAt: { updatedAt: {
type: 'string' as const, type: 'string',
optional: false as const, nullable: true as const, optional: false, nullable: true,
format: 'date-time', format: 'date-time',
}, },
text: { text: {
type: 'string' as const, type: 'string',
optional: false as const, nullable: false as const, optional: false, nullable: false,
}, },
title: { title: {
type: 'string' as const, type: 'string',
optional: false as const, nullable: false as const, optional: false, nullable: false,
}, },
imageUrl: { imageUrl: {
type: 'string' as const, type: 'string',
optional: false as const, nullable: true as const, optional: false, nullable: true,
}, },
isRead: { isRead: {
type: 'boolean' as const, type: 'boolean',
optional: false as const, nullable: false as const, optional: true, nullable: false,
}, },
}, },
}, },
}, },
}; } as const;
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, user) => { export default define(meta, async (ps, user) => {