hoangvvo / next-connect

The TypeScript-ready, minimal router and middleware layer for Next.js, Micro, Vercel, or Node.js http/http2
https://www.npmjs.com/package/next-connect
MIT License
1.64k stars 65 forks source link

Migration guide from 0.13.0? #225

Open yeikel opened 1 year ago

yeikel commented 1 year ago

Hi team,

I inherited a project using 0.13.0 and I just noticed that we had a milestone major release 1.0.0

Are there breaking changes with this version?

Is there any documentation about the changes needed?

Thanks!

faouziMohamed commented 1 year ago

I migrate my small project following this example https://github.com/hoangvvo/next-connect/blob/main/examples/nextjs/src/pages/api/users/index.ts

redimongo commented 1 year ago

I am having an issue migrating because we use nc and multer

import nc from "next-connect";
const sharp = require('sharp');
import multer from "multer";
import { connectToDatabase, disconnectFromDatabase } from '../../../libraries/mongodb';
import { Double, MongoClient, ObjectId } from 'mongodb'
const { Configuration, OpenAIApi } = require("openai");
const { exec } = require("child_process");
import { nanoid } from 'nanoid';
import { Storage } from '@google-cloud/storage';
const path = require('path');
const publicUrls = [];   
const showInfo = [];   

const configuration = new Configuration({
  apiKey: process.env.OPENAI_KEY,
});

const delay = ms => new Promise(resolve => setTimeout(resolve, ms))

export const config = {
  api: {
      responseLimit: false,
      bodyParser: false,
  },
};

const handler = nc({ attachParams: true });
let storage = multer.memoryStorage({});
const maxSize = 2000 * 1024 * 1024;

let upload = multer({
  storage: storage,
  limits: { fileSize: maxSize },

});

let uploadFile = upload.any();
handler.use(uploadFile);

handler.post(async (req, res) => {

Could anyone help with how to update the start of this code to be the latest?

jmsherry commented 10 months ago

What happened to attachParams?