fix handlers
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { rest } from 'msw';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { umbLanguagesData } from '../data/languages.data';
|
||||
import type { LanguageDetails } from '@umbraco-cms/models';
|
||||
import { Language } from '@umbraco-cms/backend-api';
|
||||
import { umbracoPath } from '@umbraco-cms/utils';
|
||||
|
||||
// TODO: add schema
|
||||
export const handlers = [
|
||||
rest.get('/umbraco/management/api/v1/language', (req, res, ctx) => {
|
||||
rest.get(umbracoPath('/language'), (req, res, ctx) => {
|
||||
const skip = req.url.searchParams.get('skip');
|
||||
const skipNumber = skip ? Number.parseInt(skip) : undefined;
|
||||
const take = req.url.searchParams.get('take');
|
||||
@@ -21,7 +22,7 @@ export const handlers = [
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.get('/umbraco/management/api/v1/language/:key', (req, res, ctx) => {
|
||||
rest.get(umbracoPath('/language/:key'), (req, res, ctx) => {
|
||||
const key = req.params.key as string;
|
||||
|
||||
if (!key) return;
|
||||
@@ -30,7 +31,7 @@ export const handlers = [
|
||||
return res(ctx.status(200), ctx.json(item));
|
||||
}),
|
||||
|
||||
rest.post<LanguageDetails>('/umbraco/management/api/v1/language', async (req, res, ctx) => {
|
||||
rest.post<Language>(umbracoPath('/language'), async (req, res, ctx) => {
|
||||
const data = await req.json();
|
||||
|
||||
if (!data) return;
|
||||
@@ -43,7 +44,7 @@ export const handlers = [
|
||||
return res(ctx.status(200), ctx.json(saved[0]));
|
||||
}),
|
||||
|
||||
rest.put<LanguageDetails>('/umbraco/management/api/v1/language/:key', async (req, res, ctx) => {
|
||||
rest.put<Language>(umbracoPath('/language/:key'), async (req, res, ctx) => {
|
||||
const data = await req.json();
|
||||
|
||||
if (!data) return;
|
||||
@@ -53,13 +54,7 @@ export const handlers = [
|
||||
return res(ctx.status(200), ctx.json(saved[0]));
|
||||
}),
|
||||
|
||||
rest.delete<LanguageDetails>('/umbraco/management/api/v1/language', async (req, res, ctx) => {
|
||||
const data = await req.json();
|
||||
|
||||
if (!data) return;
|
||||
|
||||
const deleted = umbLanguagesData.delete(data);
|
||||
|
||||
return res(ctx.status(200), ctx.json(deleted));
|
||||
rest.delete(umbracoPath('/language/:key'), async (req, res, ctx) => {
|
||||
return res(ctx.status(200));
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user