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) => {