New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nextjs-server-modules

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nextjs-server-modules - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

nsm/generated_routes.ts

3

bin.js
#!/usr/bin/env node
require("./dist/lib/cli.js").default()
require("esbuild-runner/register")
require("./lib/cli.js").default()

@@ -31,4 +31,5 @@ const glob = require("glob-promise")

await require(`${dir}/.nsm/scripts/generate-routes.js`).generateRoutes()
await require(`${dir}/.nsm/scripts/copy-nextjs-config.js`).copyNextjsConfig()
}
module.exports = { build, default: build }

@@ -12,2 +12,4 @@ import routes from "./generated_routes"

import wrappers from "@seamapi/wrappers"
import resolveRewrites from "./nextjs-middleware/resolve-rewrites"
import nextConfig from "./next.config"

@@ -21,6 +23,24 @@ const debug = Debug("nsm")

}
const routeMatcher = getRouteMatcher(routes)
const server = micro(async (req: IncomingMessage, res) => {
const query = querystring.parse(req.url.split("?").slice(1).join("?"))
debug(`got request for "${req.url}"`)
const resolveResult = resolveRewrites(
req.url,
Object.keys(routes),
{
afterFiles: [],
beforeFiles: [],
fallback: [],
...(nextConfig as any).rewrites,
},
query,
(s) => s
)
req.url = resolveResult.resolvedHref || req.url
debug(`resolved request to "${req.url}"`)
req.url = req.url.split("?")[0]
if (req.url.startsWith("/_next/static")) {

@@ -27,0 +47,0 @@ req.url = req.url.replace(/^\/_next\/static/, "")

@@ -1,2 +0,1 @@

const glob = require("glob-promise")
const path = require("path")

@@ -8,23 +7,19 @@ const prettier = require("prettier")

const pagesDir = path.resolve(__dirname, "../../.next/server/pages")
const allPageFiles = (await glob("**/*", { cwd: pagesDir })).filter(
(fp) => !fp.endsWith(".nft.json") && fp.includes(".")
const pagesManifest = JSON.parse(
await fs.readFile(path.resolve(pagesDir, "../pages-manifest.json"))
)
const routesFile = prettier.format(
`const path = require("path")
`import path from "path"
Object.defineProperty(exports, "__esModule", {
value: true,
})
exports.default = void 0
var _default = {
${allPageFiles
.map((fp) =>
fp.startsWith("api")
? `"/${fp.split(".js")[0]}": require("../.next/server/pages/${fp}")`
: `"/${fp}": path.resolve(__dirname, "../.next/server/pages/${fp}")`
export default {
${Object.entries(pagesManifest)
.map(([route, fp]) =>
fp.startsWith("pages/api")
? `"${route}": require("../${fp}")`
: `"${route}": path.resolve(__dirname, "../.next/server/${fp}")`
)
.join(",")}
}
exports.default = _default

@@ -36,3 +31,3 @@ `,

await fs.writeFile(
path.resolve(__dirname, "../generated_routes.js"),
path.resolve(__dirname, "../generated_routes.ts"),
routesFile

@@ -39,0 +34,0 @@ )

@@ -66,1 +66,21 @@ // https://github.com/vercel/next.js/blob/bb6d4d71fd419b64e2a3ce4d3496f2150f9ff86b/packages/next/shared/lib/utils.ts

) => void | Promise<void>
export type RouteHas =
| {
type: "header" | "query" | "cookie"
key: string
value?: string
}
| {
type: "host"
key?: undefined
value: string
}
export type Rewrite = {
source: string
destination: string
basePath?: false
locale?: false
has?: RouteHas[]
}
{
"name": "nextjs-server-modules",
"version": "1.3.2",
"version": "1.4.0",
"main": "bin.js",

@@ -8,3 +8,3 @@ "repository": "git@github.com:hello-seam/nextjs-server-modules.git",

"scripts": {
"build": "rimraf ./dist && swc ./lib -d ./dist/lib && swc ./nsm -d ./dist/nsm"
"build:old": "rimraf ./dist && swc ./lib -d ./dist/lib && swc ./nsm -d ./dist/nsm"
},

@@ -37,2 +37,3 @@ "bin": {

"@seamapi/wrappers": "^1.0.1",
"path-to-regexp": "^6.2.0",
"cookie": "^0.4.1",

@@ -39,0 +40,0 @@ "debug": "^4.3.3",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc