♻️(backend) rename convert-markdown endpoint
Renamed the `convert-markdown` endpoint to `convert` as a general-purpose conversion endpoint for integration with DocSpec conversion (DOCX import), without altering its existing functionality. In a future contribution, this endpoint will not only support conversion from Markdown -> BlockNote -> Yjs but also directly BlockNote -> Yjs. Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
This commit is contained in:
@@ -21,9 +21,9 @@ describe('Server Tests', () => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
test('POST /api/convert-markdown with incorrect API key should return 403', async () => {
|
||||
test('POST /api/convert with incorrect API key should return 403', async () => {
|
||||
const response = await request(app as any)
|
||||
.post('/api/convert-markdown')
|
||||
.post('/api/convert')
|
||||
.set('Origin', origin)
|
||||
.set('Authorization', 'wrong-api-key');
|
||||
|
||||
@@ -31,9 +31,9 @@ describe('Server Tests', () => {
|
||||
expect(response.body.error).toBe('Forbidden: Invalid API Key');
|
||||
});
|
||||
|
||||
test('POST /api/convert-markdown with a Bearer token', async () => {
|
||||
test('POST /api/convert with a Bearer token', async () => {
|
||||
const response = await request(app as any)
|
||||
.post('/api/convert-markdown')
|
||||
.post('/api/convert')
|
||||
.set('Origin', origin)
|
||||
.set('Authorization', 'Bearer test-secret-api-key');
|
||||
|
||||
@@ -41,9 +41,9 @@ describe('Server Tests', () => {
|
||||
expect(response.status).toBe(403);
|
||||
});
|
||||
|
||||
test('POST /api/convert-markdown with missing body param content', async () => {
|
||||
test('POST /api/convert with missing body param content', async () => {
|
||||
const response = await request(app as any)
|
||||
.post('/api/convert-markdown')
|
||||
.post('/api/convert')
|
||||
.set('Origin', origin)
|
||||
.set('Authorization', 'yprovider-api-key');
|
||||
|
||||
@@ -51,9 +51,9 @@ describe('Server Tests', () => {
|
||||
expect(response.body.error).toBe('Invalid request: missing content');
|
||||
});
|
||||
|
||||
test('POST /api/convert-markdown with body param content being an empty string', async () => {
|
||||
test('POST /api/convert with body param content being an empty string', async () => {
|
||||
const response = await request(app as any)
|
||||
.post('/api/convert-markdown')
|
||||
.post('/api/convert')
|
||||
.set('Origin', origin)
|
||||
.set('Authorization', 'yprovider-api-key')
|
||||
.send({
|
||||
@@ -39,20 +39,20 @@ describe('Server Tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow JSON payloads up to 500kb for the CONVERT_MARKDOWN route', async () => {
|
||||
it('should allow JSON payloads up to 500kb for the CONVERT route', async () => {
|
||||
const largePayload = 'a'.repeat(400 * 1024); // 400kb payload
|
||||
const response = await request(app)
|
||||
.post(routes.CONVERT_MARKDOWN)
|
||||
.post(routes.CONVERT)
|
||||
.send({ data: largePayload })
|
||||
.set('Content-Type', 'application/json');
|
||||
|
||||
expect(response.status).not.toBe(413);
|
||||
});
|
||||
|
||||
it('should reject JSON payloads larger than 500kb for the CONVERT_MARKDOWN route', async () => {
|
||||
it('should reject JSON payloads larger than 500kb for the CONVERT route', async () => {
|
||||
const oversizedPayload = 'a'.repeat(501 * 1024); // 501kb payload
|
||||
const response = await request(app)
|
||||
.post(routes.CONVERT_MARKDOWN)
|
||||
.post(routes.CONVERT)
|
||||
.send({ data: oversizedPayload })
|
||||
.set('Content-Type', 'application/json');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user