mirror of
https://github.com/strapi/strapi.git
synced 2025-12-16 09:45:08 +00:00
Update typings
This commit is contained in:
parent
6fe5a1e0cd
commit
5247ed90d1
@ -96,11 +96,12 @@ async function createAdmin({ email, password, firstname, lastname }) {
|
|||||||
const isTSProject = await tsUtils.isUsingTypeScript(appDir);
|
const isTSProject = await tsUtils.isUsingTypeScript(appDir);
|
||||||
const outDir = await tsUtils.resolveOutDir(appDir);
|
const outDir = await tsUtils.resolveOutDir(appDir);
|
||||||
|
|
||||||
if (isTSProject)
|
if (isTSProject) {
|
||||||
await tsUtils.compile(appDir, {
|
await tsUtils.compile(appDir, {
|
||||||
watch: false,
|
watch: false,
|
||||||
configOptions: { options: { incremental: true } },
|
configOptions: { options: { incremental: true } },
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const distDir = isTSProject ? outDir : appDir;
|
const distDir = isTSProject ? outDir : appDir;
|
||||||
|
|
||||||
|
|||||||
@ -1,29 +1,27 @@
|
|||||||
import { Context } from 'koa';
|
import { Context, Next } from 'koa';
|
||||||
|
|
||||||
type ControllerResponse<T = unknown> = T | Promise<T> | undefined;
|
type ControllerResponse<T = unknown> = T | Promise<T> | undefined;
|
||||||
|
|
||||||
interface BaseController {
|
interface Controller {
|
||||||
transformResponse(data: object, meta: object): object;
|
transformResponse(data: object, meta: object): object;
|
||||||
sanitizeOutput(data: object, ctx: Context): Promise<object>;
|
sanitizeOutput(data: object, ctx: Context): Promise<object>;
|
||||||
sanitizeInput(data: object, ctx: Context): Promise<object>;
|
sanitizeInput(data: object, ctx: Context): Promise<object>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SingleTypeController extends BaseController {
|
export interface SingleTypeController extends Controller {
|
||||||
find(ctx: Context): ControllerResponse;
|
find?(ctx: Context, next: Next): ControllerResponse;
|
||||||
update(ctx: Context): ControllerResponse;
|
update?(ctx: Context, next: Next): ControllerResponse;
|
||||||
delete(ctx: Context): ControllerResponse;
|
delete?(ctx: Context, next: Next): ControllerResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CollectionTypeController extends BaseController {
|
export interface CollectionTypeController extends Controller {
|
||||||
find(ctx: Context): ControllerResponse;
|
find?(ctx: Context, next: Next): ControllerResponse;
|
||||||
findOne(ctx: Context): ControllerResponse;
|
findOne?(ctx: Context, next: Next): ControllerResponse;
|
||||||
create(ctx: Context): ControllerResponse;
|
create?(ctx: Context, next: Next): ControllerResponse;
|
||||||
update(ctx: Context): ControllerResponse;
|
update?(ctx: Context, next: Next): ControllerResponse;
|
||||||
delete(ctx: Context): ControllerResponse;
|
delete?(ctx: Context, next: Next): ControllerResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Controller = SingleTypeController | CollectionTypeController;
|
|
||||||
|
|
||||||
export type GenericController = Partial<Controller> & {
|
export type GenericController = Partial<Controller> & {
|
||||||
[method: string | number | symbol]: (ctx: Context) => unknown;
|
[method: string | number | symbol]: (ctx: Context) => unknown;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,7 +2,9 @@
|
|||||||
* `{{ name }}` middleware.
|
* `{{ name }}` middleware.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default (config, { strapi }) => {
|
import '@strapi/strapi';
|
||||||
|
|
||||||
|
export default (config, { strapi }: { strapi: Strapi }) => {
|
||||||
// Add your own logic here.
|
// Add your own logic here.
|
||||||
return async (ctx, next) => {
|
return async (ctx, next) => {
|
||||||
strapi.log.info('In {{ name }} middleware.');
|
strapi.log.info('In {{ name }} middleware.');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user