chore: move to monorepo structure

This commit is contained in:
Alessio Gravili
2023-08-23 12:20:30 +02:00
parent e24ad67168
commit a67278b29f
1398 changed files with 2392 additions and 16005 deletions

View File

@@ -1,65 +0,0 @@
import { buildConfigWithDefaults } from '../buildConfigWithDefaults';
import { openAccess } from '../helpers/configHelpers';
import { Config } from '../../src/config/types';
const config: Config = {
collections: [
{
slug: 'pages',
access: openAccess,
endpoints: [
{
path: '/hello',
method: 'get',
handler: (_, res): void => {
res.json({ message: 'hi' });
},
custom: { examples: [{ type: 'response', value: { message: 'hi' } }] },
},
],
fields: [
{
name: 'title',
type: 'text',
custom: { description: 'The title of this page' },
},
],
custom: { externalLink: 'https://foo.bar' },
},
],
globals: [
{
slug: 'my-global',
endpoints: [{
path: '/greet',
method: 'get',
handler: (req, res): void => {
const { name } = req.query;
res.json({ message: `Hi ${name}!` });
},
custom: { params: [{ in: 'query', name: 'name', type: 'string' }] },
}],
fields: [{
name: 'title',
type: 'text',
custom: { description: 'The title of my global' },
},
],
custom: { foo: 'bar' },
},
],
endpoints: [
{
path: '/config',
method: 'get',
root: true,
handler: (req, res): void => {
res.json(req.payload.config);
},
custom: { description: 'Get the sanitized payload config' },
},
],
custom: { name: 'Customer portal' },
};
export default buildConfigWithDefaults(config);

View File

@@ -1,66 +0,0 @@
import { initPayloadTest } from '../helpers/configHelpers';
import payload from '../../src';
require('isomorphic-fetch');
describe('Config', () => {
beforeAll(async () => {
await initPayloadTest({ __dirname, init: { local: true } });
});
describe('payload config', () => {
it('allows a custom field at the config root', () => {
const { config } = payload;
expect(config.custom).toEqual({ name: 'Customer portal' });
});
it('allows a custom field in the root endpoints', () => {
const [endpoint] = payload.config.endpoints;
expect(endpoint.custom).toEqual({ description: 'Get the sanitized payload config' });
});
});
describe('collection config', () => {
it('allows a custom field in collections', () => {
const [collection] = payload.config.collections;
expect(collection.custom).toEqual({ externalLink: 'https://foo.bar' });
});
it('allows a custom field in collection endpoints', () => {
const [collection] = payload.config.collections;
const [endpoint] = collection.endpoints;
expect(endpoint.custom).toEqual({ examples: [{ type: 'response', value: { message: 'hi' } }] });
});
it('allows a custom field in collection fields', () => {
const [collection] = payload.config.collections;
const [field] = collection.fields;
expect(field.custom).toEqual({ description: 'The title of this page' });
});
});
describe('global config', () => {
it('allows a custom field in globals', () => {
const [global] = payload.config.globals;
expect(global.custom).toEqual({ foo: 'bar' });
});
it('allows a custom field in global endpoints', () => {
const [global] = payload.config.globals;
const [endpoint] = global.endpoints;
expect(endpoint.custom).toEqual({ params: [{ in: 'query', name: 'name', type: 'string' }] });
});
it('allows a custom field in global fields', () => {
const [global] = payload.config.globals;
const [field] = global.fields;
expect(field.custom).toEqual({ description: 'The title of my global' });
});
});
});