feat: supports root endpoints

This commit is contained in:
Jacob Fletcher
2022-09-22 10:43:20 -04:00
parent 686085496a
commit 52cd3b4a7e
12 changed files with 150 additions and 17 deletions

View File

@@ -16,14 +16,19 @@ export interface Global {
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "posts".
* via the `definition` "group-globals-one".
*/
export interface Post {
export interface GroupGlobalsOne {
id: string;
title?: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "group-globals-two".
*/
export interface GroupGlobalsTwo {
id: string;
title?: string;
description?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
@@ -39,3 +44,55 @@ export interface User {
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "posts".
*/
export interface Post {
id: string;
title?: string;
description?: string;
number?: number;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "group-one-collection-ones".
*/
export interface GroupOneCollectionOne {
id: string;
title?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "group-one-collection-twos".
*/
export interface GroupOneCollectionTwo {
id: string;
title?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "group-two-collection-ones".
*/
export interface GroupTwoCollectionOne {
id: string;
title?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "group-two-collection-twos".
*/
export interface GroupTwoCollectionTwo {
id: string;
title?: string;
createdAt: string;
updatedAt: string;
}

View File

@@ -3,14 +3,16 @@ import { devUser } from '../credentials';
import { buildConfig } from '../buildConfig';
import { openAccess } from '../helpers/configHelpers';
import { PayloadRequest } from '../../src/express/types';
import { Config } from '../../src/config/types';
export const collectionSlug = 'endpoints';
export const globalSlug = 'global-endpoints';
export const globalEndpoint = 'global';
export const applicationEndpoint = 'path';
export const rootEndpoint = 'root';
export default buildConfig({
const MyConfig: Config = {
collections: [
{
slug: collectionSlug,
@@ -77,6 +79,21 @@ export default buildConfig({
res.json(req.body);
},
},
{
path: `/${applicationEndpoint}`,
method: 'get',
handler: (req: PayloadRequest, res: Response): void => {
res.json({ message: 'Hello, world!' });
},
},
{
path: `/${rootEndpoint}`,
method: 'get',
root: true,
handler: (req: PayloadRequest, res: Response): void => {
res.json({ message: 'Root.' });
},
},
],
onInit: async (payload) => {
await payload.create({
@@ -87,4 +104,6 @@ export default buildConfig({
},
});
},
});
}
export default buildConfig(MyConfig);

View File

@@ -16,6 +16,10 @@ export interface ArrayField {
text: string;
id?: string;
}[];
collapsedArray: {
text: string;
id?: string;
}[];
localized: {
text: string;
id?: string;
@@ -80,6 +84,49 @@ export interface BlockField {
blockType: 'tabs';
}
)[];
collapsedByDefaultBlocks: (
| {
text: string;
richText?: {
[k: string]: unknown;
}[];
id?: string;
blockName?: string;
blockType: 'text';
}
| {
number: number;
id?: string;
blockName?: string;
blockType: 'number';
}
| {
subBlocks: (
| {
text: string;
id?: string;
blockName?: string;
blockType: 'text';
}
| {
number: number;
id?: string;
blockName?: string;
blockType: 'number';
}
)[];
id?: string;
blockName?: string;
blockType: 'subBlocks';
}
| {
textInCollapsible?: string;
textInRow?: string;
id?: string;
blockName?: string;
blockType: 'tabs';
}
)[];
localizedBlocks: (
| {
text: string;
@@ -153,6 +200,7 @@ export interface CollapsibleField {
textWithinSubGroup?: string;
};
};
someText?: string;
createdAt: string;
updatedAt: string;
}