import nextConnect from 'next-connect';
import { NextApiRequest, NextApiResponse, PageConfig } from 'next';
import anylogger from 'anylogger';
import '@mmstudio/an000042';
import an45 from '@mmstudio/an000045';
const logger = anylogger('pages/api/upload');
export type Result = {
ok: true;
fileid: string;
} | {
ok: false;
message: string;
};
const handler = nextConnect<NextApiRequest, NextApiResponse<Result>>();
handler.put(async (req, res) => {
logger.debug('upload file');
const [file] = await an45(req);
res.status(200).json({ ok: true, fileid: file.id });
});
export const config = {
api: {
bodyParser: false
}
} as PageConfig;
export default handler;