diff --git a/CHANGELOG.md b/CHANGELOG.md index 09a23ec..a3967fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # 🛠️ CHANGELOG +## 2.2.5 + +- Updated package.json to Next 14 + +- Switched to static semantic versioning in package.json + +- Updated to iron-session 8.0.1 + +- Improved and cleaned up api macro + ## 2.2.4 - Fix default `layout.tsx` suspense boundary. diff --git a/README.md b/README.md index 5179b90..ba451a6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## Automation Tooling for Next, Redux and Prisma ![license](https://img.shields.io/badge/license-AGPLv3-blue.svg) -![version](https://img.shields.io/badge/version-2.2.4-blue.svg) +![version](https://img.shields.io/badge/version-2.2.5-blue.svg) [![CircleCI](https://circleci.com/gh/PrinterFramework/CLI.svg?style=svg)](https://circleci.com/gh/PrinterFramework/CLI) **Printer v1.x.x** is compatible with the old Next patterns. You can review the documentation on the v1 website: [v1.prntr.click/docs](https://v1.prntr.click/docs) diff --git a/dist/src/printer.js b/dist/src/printer.js index 4fdb80e..ec32d30 100755 --- a/dist/src/printer.js +++ b/dist/src/printer.js @@ -59,7 +59,7 @@ var prisma_1 = require("./generators/prisma"); var superagent_1 = require("./generators/superagent"); exports.Printer = new commander_1.Command('🖨️ Printer'); exports.Printer - .version('2.2.4') + .version('2.2.5') .description('🖨️ Printer: Automation Tooling for Next, Redux and Prisma.') .option('-a, --no-action', 'do not inject actions', false) .option('-s, --no-state', 'do not inject state', false); diff --git a/dist/src/templates/api.template b/dist/src/templates/api.template index 68bec5a..7262177 100755 --- a/dist/src/templates/api.template +++ b/dist/src/templates/api.template @@ -1,26 +1,25 @@ -import { NextRequest, NextResponse } from 'next/server' -import { getSession, createResponse } from 'util/session' +import { NextRequest } from 'next/server' +import { getSession } from 'util/session' export async function GET(req: NextRequest) { - const res = new NextResponse() - const session = await getSession(req, res) + const session = await getSession() const { searchParams } = new URL(req.url) - res.headers.set('Content-Type', 'application/json') try { - return createResponse( - res, - JSON.stringify({ + return Response.json( + { status: 'OK', - session - }), + result: null + }, { status: 200 } ) } catch (error) { console.error(error) - return createResponse( - res, - JSON.stringify({ status: 'ERROR', error }), + return Response.json( + { + status: 'ERROR', + error + }, { status: 500 } ) } diff --git a/dist/src/templates/new/package.json.template b/dist/src/templates/new/package.json.template index a7edaaa..d8c7035 100755 --- a/dist/src/templates/new/package.json.template +++ b/dist/src/templates/new/package.json.template @@ -11,34 +11,34 @@ "prisma:update": "npx prisma generate && npx prisma db push" }, "dependencies": { - "@prisma/client": "^5.3.1", - "@reduxjs/toolkit": "^1.9.6", - "iron-session": "8.0.0-alpha.0", - "next": "^13.5.3", - "prisma": "^5.3.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-redux": "^8.1.3", - "sass": "^1.68.0", - "superagent": "^8.1.2" + "@prisma/client": "5.6.0", + "@reduxjs/toolkit": "1.9.7", + "iron-session": "8.0.1", + "next": "14.0.3", + "prisma": "5.6.0", + "react": "18.2.0", + "react-dom": "18.2.0", + "react-redux": "8.1.3", + "sass": "1.69.5", + "superagent": "8.1.2" }, "devDependencies": { - "@types/node": "^20.8.0", - "@types/superagent": "^4.1.19", - "@typescript-eslint/eslint-plugin": "^6.7.3", - "@typescript-eslint/parser": "^6.7.3", - "eslint": "^8.50.0", - "eslint-config-next": "^13.5.3", - "eslint-config-prettier": "^9.0.0", - "eslint-config-standard": "^17.1.0", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-n": "^16.1.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-react": "^7.33.2", - "node-sass": "^9.0.0", - "prettier": "^3.0.3", - "typescript": "^5.2.2" + "@types/node": "20.9.5", + "@types/superagent": "4.1.22", + "@typescript-eslint/eslint-plugin": "6.12.0", + "@typescript-eslint/parser": "6.12.0", + "eslint": "8.54.0", + "eslint-config-next": "14.0.3", + "eslint-config-prettier": "9.0.0", + "eslint-config-standard": "17.1.0", + "eslint-plugin-import": "2.29.0", + "eslint-plugin-n": "16.3.1", + "eslint-plugin-node": "11.1.0", + "eslint-plugin-prettier": "5.0.1", + "eslint-plugin-promise": "6.1.1", + "eslint-plugin-react": "7.33.2", + "node-sass": "9.0.0", + "prettier": "3.1.0", + "typescript": "5.3.2" } } diff --git a/dist/src/templates/new/util/session.ts.template b/dist/src/templates/new/util/session.ts.template index c40eb44..3ea9ce7 100755 --- a/dist/src/templates/new/util/session.ts.template +++ b/dist/src/templates/new/util/session.ts.template @@ -1,16 +1,16 @@ -import { NextRequest, NextResponse } from 'next/server' -import { getIronSession, createResponse } from 'iron-session' +import { getIronSession } from 'iron-session' +import { cookies } from 'next/headers' export const password = process.env.SESSION_SECRET || - '{{password}}' + 'ad75fbbbddbf8005cb60e3089d6f156440f9c8ac1d13ad33a8e4758fdff73ff8' export interface SessionI { counter?: number } -export function getSession(req: NextRequest, res: NextResponse) { - return getIronSession(req, res, { +export function getSession() { + return getIronSession(cookies(), { password, cookieName: 'printer', cookieOptions: { @@ -21,5 +21,3 @@ export function getSession(req: NextRequest, res: NextResponse) { } }) } - -export { createResponse } diff --git a/package.json b/package.json index 4ef8202..932d77f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@printerframework/cli", "description": "🖨️ Automation Tooling for Next, Redux and Prisma.", - "version": "2.2.4", + "version": "2.2.5", "private": false, "preferGlobal": true, "repository": "https://github.com/PrinterFramework/CLI.git", diff --git a/src/printer.ts b/src/printer.ts index 3fabf48..6eb176a 100644 --- a/src/printer.ts +++ b/src/printer.ts @@ -20,7 +20,7 @@ import { SuperagentTypes, injectSupergent } from './generators/superagent' export const Printer = new Command('🖨️ Printer') Printer - .version('2.2.4') + .version('2.2.5') .description('🖨️ Printer: Automation Tooling for Next, Redux and Prisma.') .option('-a, --no-action', 'do not inject actions', false) .option('-s, --no-state', 'do not inject state', false) diff --git a/src/templates/api.template b/src/templates/api.template index 68bec5a..7262177 100644 --- a/src/templates/api.template +++ b/src/templates/api.template @@ -1,26 +1,25 @@ -import { NextRequest, NextResponse } from 'next/server' -import { getSession, createResponse } from 'util/session' +import { NextRequest } from 'next/server' +import { getSession } from 'util/session' export async function GET(req: NextRequest) { - const res = new NextResponse() - const session = await getSession(req, res) + const session = await getSession() const { searchParams } = new URL(req.url) - res.headers.set('Content-Type', 'application/json') try { - return createResponse( - res, - JSON.stringify({ + return Response.json( + { status: 'OK', - session - }), + result: null + }, { status: 200 } ) } catch (error) { console.error(error) - return createResponse( - res, - JSON.stringify({ status: 'ERROR', error }), + return Response.json( + { + status: 'ERROR', + error + }, { status: 500 } ) } diff --git a/src/templates/new/package.json.template b/src/templates/new/package.json.template index a7edaaa..d8c7035 100644 --- a/src/templates/new/package.json.template +++ b/src/templates/new/package.json.template @@ -11,34 +11,34 @@ "prisma:update": "npx prisma generate && npx prisma db push" }, "dependencies": { - "@prisma/client": "^5.3.1", - "@reduxjs/toolkit": "^1.9.6", - "iron-session": "8.0.0-alpha.0", - "next": "^13.5.3", - "prisma": "^5.3.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-redux": "^8.1.3", - "sass": "^1.68.0", - "superagent": "^8.1.2" + "@prisma/client": "5.6.0", + "@reduxjs/toolkit": "1.9.7", + "iron-session": "8.0.1", + "next": "14.0.3", + "prisma": "5.6.0", + "react": "18.2.0", + "react-dom": "18.2.0", + "react-redux": "8.1.3", + "sass": "1.69.5", + "superagent": "8.1.2" }, "devDependencies": { - "@types/node": "^20.8.0", - "@types/superagent": "^4.1.19", - "@typescript-eslint/eslint-plugin": "^6.7.3", - "@typescript-eslint/parser": "^6.7.3", - "eslint": "^8.50.0", - "eslint-config-next": "^13.5.3", - "eslint-config-prettier": "^9.0.0", - "eslint-config-standard": "^17.1.0", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-n": "^16.1.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-react": "^7.33.2", - "node-sass": "^9.0.0", - "prettier": "^3.0.3", - "typescript": "^5.2.2" + "@types/node": "20.9.5", + "@types/superagent": "4.1.22", + "@typescript-eslint/eslint-plugin": "6.12.0", + "@typescript-eslint/parser": "6.12.0", + "eslint": "8.54.0", + "eslint-config-next": "14.0.3", + "eslint-config-prettier": "9.0.0", + "eslint-config-standard": "17.1.0", + "eslint-plugin-import": "2.29.0", + "eslint-plugin-n": "16.3.1", + "eslint-plugin-node": "11.1.0", + "eslint-plugin-prettier": "5.0.1", + "eslint-plugin-promise": "6.1.1", + "eslint-plugin-react": "7.33.2", + "node-sass": "9.0.0", + "prettier": "3.1.0", + "typescript": "5.3.2" } } diff --git a/src/templates/new/util/session.ts.template b/src/templates/new/util/session.ts.template index c40eb44..3ea9ce7 100644 --- a/src/templates/new/util/session.ts.template +++ b/src/templates/new/util/session.ts.template @@ -1,16 +1,16 @@ -import { NextRequest, NextResponse } from 'next/server' -import { getIronSession, createResponse } from 'iron-session' +import { getIronSession } from 'iron-session' +import { cookies } from 'next/headers' export const password = process.env.SESSION_SECRET || - '{{password}}' + 'ad75fbbbddbf8005cb60e3089d6f156440f9c8ac1d13ad33a8e4758fdff73ff8' export interface SessionI { counter?: number } -export function getSession(req: NextRequest, res: NextResponse) { - return getIronSession(req, res, { +export function getSession() { + return getIronSession(cookies(), { password, cookieName: 'printer', cookieOptions: { @@ -21,5 +21,3 @@ export function getSession(req: NextRequest, res: NextResponse) { } }) } - -export { createResponse } diff --git a/tsconfig.json b/tsconfig.json index e9d57d2..5845585 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,4 +21,4 @@ "src/**/*.ts", "test/**/*.ts" ] - } +}