Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/abaca-cli/test/pets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import Router from '@koa/router';
import {absurd, assert, unexpected, unreachable} from '@mtth/stl-errors';
import http from 'http';
import Koa from 'koa';
import koaBody_ from 'koa-body';
import koaBody from 'koa-body';
import fetch from 'node-fetch';
import {Writable} from 'ts-essentials';

const koaBody = koaBody_.default ?? koaBody_;

import {startApp} from './helpers.js';
import {
createSdk,
Expand Down Expand Up @@ -267,7 +265,7 @@ function newRouter(): Router {
return;
}
const id = '' + (pets.size + 1);
pets.set(id, {...ctx.request.body, id});
pets.set(id, {...(ctx.request.body as any), id});
ctx.status = 201;
if (ctx.accepts('text/plain')) {
ctx.body = id;
Expand Down
11 changes: 6 additions & 5 deletions packages/abaca-cli/test/tables.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import Router from '@koa/router';
import {assert} from '@mtth/stl-errors';
import http from 'http';
import Koa from 'koa';
import koaBody_ from 'koa-body';
import koaBody from 'koa-body';
import fetch from 'node-fetch';

import {startApp} from './helpers.js';
import {createSdk, Schema, Sdk} from './tables-sdk.gen.js';

const koaBody = koaBody_.default ?? koaBody_;

describe('tables', () => {
let sdk: Sdk<typeof fetch>;
let app: Koa<any, any>;
Expand Down Expand Up @@ -146,10 +145,12 @@ function newRouter(): Router {
let table: Schema<'Table'> | undefined;
switch (ctx.type) {
case 'application/json':
table = ctx.request.body;
assert(ctx.request.body, 'missing body');
table = ctx.request.body as any;
break;
case 'text/csv':
table = ctx.request.body.split('\n').map((r) => r.split(','));
assert(typeof ctx.request.body == 'string', 'invalid body');
table = {rows: ctx.request.body.split('\n').map((r) => r.split(','))};
break;
}
if (!table) {
Expand Down